summaryrefslogtreecommitdiff
path: root/source3/torture
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-07-11 18:01:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:19:14 -0500
commitfbdcf2663b56007a438ac4f0d8d82436b1bfe688 (patch)
tree4e42c1f061391cea3d640152fd240682cbf4fd9a /source3/torture
parent5bf62a0c3cc95abe918f3e772bb10e0a90fdce22 (diff)
downloadsamba-fbdcf2663b56007a438ac4f0d8d82436b1bfe688.tar.gz
samba-fbdcf2663b56007a438ac4f0d8d82436b1bfe688.tar.bz2
samba-fbdcf2663b56007a438ac4f0d8d82436b1bfe688.zip
r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need
to do the upper layer directories but this is what everyone is waiting for.... Jeremy. (This used to be commit 9dafb7f48ca3e7af956b0a7d1720c2546fc4cfb8)
Diffstat (limited to 'source3/torture')
-rw-r--r--source3/torture/cmd_vfs.c24
-rw-r--r--source3/torture/locktest.c12
-rw-r--r--source3/torture/locktest2.c1
-rw-r--r--source3/torture/masktest.c2
-rw-r--r--source3/torture/nsstest.c52
-rw-r--r--source3/torture/pdbtest.c392
-rw-r--r--source3/torture/rpctorture.c2
-rw-r--r--source3/torture/scanner.c12
-rw-r--r--source3/torture/torture.c126
-rw-r--r--source3/torture/vfstest.c2
10 files changed, 541 insertions, 84 deletions
diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c
index cc683977e8..6cecd693f8 100644
--- a/source3/torture/cmd_vfs.c
+++ b/source3/torture/cmd_vfs.c
@@ -94,7 +94,7 @@ static NTSTATUS cmd_show_data(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int ar
static NTSTATUS cmd_connect(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
- SMB_VFS_CONNECT(vfs->conn, lp_servicename(vfs->conn->service), "vfstest");
+ SMB_VFS_CONNECT(vfs->conn, lp_servicename(SNUM(vfs->conn)), "vfstest");
return NT_STATUS_OK;
}
@@ -200,9 +200,10 @@ static NTSTATUS cmd_closedir(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int arg
static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
- int flags, fd;
+ int flags;
mode_t mode;
const char *flagstr;
+ files_struct *fsp;
mode = 00400;
@@ -278,18 +279,21 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
}
}
- fd = SMB_VFS_OPEN(vfs->conn, argv[1], flags, mode);
- if (fd == -1) {
+ fsp = SMB_MALLOC_P(struct files_struct);
+ fsp->fsp_name = SMB_STRDUP(argv[1]);
+ fsp->fh = SMB_MALLOC_P(struct fd_handle);
+ fsp->conn = vfs->conn;
+
+ fsp->fh->fd = SMB_VFS_OPEN(vfs->conn, argv[1], fsp, flags, mode);
+ if (fsp->fh->fd == -1) {
printf("open: error=%d (%s)\n", errno, strerror(errno));
+ SAFE_FREE(fsp->fh);
+ SAFE_FREE(fsp);
return NT_STATUS_UNSUCCESSFUL;
}
- vfs->files[fd] = SMB_MALLOC_P(struct files_struct);
- vfs->files[fd]->fsp_name = SMB_STRDUP(argv[1]);
- vfs->files[fd]->fh = SMB_MALLOC_P(struct fd_handle);
- vfs->files[fd]->fh->fd = fd;
- vfs->files[fd]->conn = vfs->conn;
- printf("open: fd=%d\n", fd);
+ vfs->files[fsp->fh->fd] = fsp;
+ printf("open: fd=%d\n", fsp->fh->fd);
return NT_STATUS_OK;
}
diff --git a/source3/torture/locktest.c b/source3/torture/locktest.c
index b946e48666..3559a55a46 100644
--- a/source3/torture/locktest.c
+++ b/source3/torture/locktest.c
@@ -113,9 +113,13 @@ static struct record preset[] = {
static struct record *recorded;
-static void print_brl(SMB_DEV_T dev, SMB_INO_T ino, struct process_id pid,
- enum brl_type lock_type,
- br_off start, br_off size)
+static void print_brl(SMB_DEV_T dev,
+ SMB_INO_T ino,
+ struct process_id pid,
+ enum brl_type lock_type,
+ enum brl_flavour lock_flav,
+ br_off start,
+ br_off size)
{
#if NASTY_POSIX_LOCK_HACK
{
@@ -178,7 +182,7 @@ static struct cli_state *connect_one(char *share, int snum)
zero_ip(&ip);
/* have to open a new connection */
- if (!(c=cli_initialise(NULL)) || !cli_connect(c, server_n, &ip)) {
+ if (!(c=cli_initialise()) || !cli_connect(c, server_n, &ip)) {
DEBUG(0,("Connection to %s failed\n", server_n));
return NULL;
}
diff --git a/source3/torture/locktest2.c b/source3/torture/locktest2.c
index 519acebe8e..5f2f2499ac 100644
--- a/source3/torture/locktest2.c
+++ b/source3/torture/locktest2.c
@@ -135,6 +135,7 @@ static BOOL try_unlock(struct cli_state *c, int fstype,
static void print_brl(SMB_DEV_T dev, SMB_INO_T ino, struct process_id pid,
enum brl_type lock_type,
+ enum brl_flavour lock_flav,
br_off start, br_off size)
{
printf("%6d %05x:%05x %s %.0f:%.0f(%.0f)\n",
diff --git a/source3/torture/masktest.c b/source3/torture/masktest.c
index ffc9a20e71..44d26cdc5a 100644
--- a/source3/torture/masktest.c
+++ b/source3/torture/masktest.c
@@ -184,7 +184,7 @@ struct cli_state *connect_one(char *share)
zero_ip(&ip);
/* have to open a new connection */
- if (!(c=cli_initialise(NULL)) || !cli_connect(c, server_n, &ip)) {
+ if (!(c=cli_initialise()) || !cli_connect(c, server_n, &ip)) {
DEBUG(0,("Connection to %s failed\n", server_n));
return NULL;
}
diff --git a/source3/torture/nsstest.c b/source3/torture/nsstest.c
index d2b17f0f63..7673f92209 100644
--- a/source3/torture/nsstest.c
+++ b/source3/torture/nsstest.c
@@ -62,7 +62,9 @@ static void report_nss_error(const char *who, NSS_STATUS status)
static struct passwd *nss_getpwent(void)
{
NSS_STATUS (*_nss_getpwent_r)(struct passwd *, char *,
- size_t , int *) = find_fn("getpwent_r");
+ size_t , int *) =
+ (NSS_STATUS (*)(struct passwd *, char *,
+ size_t, int *))find_fn("getpwent_r");
static struct passwd pwd;
static char buf[1000];
NSS_STATUS status;
@@ -84,7 +86,9 @@ static struct passwd *nss_getpwent(void)
static struct passwd *nss_getpwnam(const char *name)
{
NSS_STATUS (*_nss_getpwnam_r)(const char *, struct passwd *, char *,
- size_t , int *) = find_fn("getpwnam_r");
+ size_t , int *) =
+ (NSS_STATUS (*)(const char *, struct passwd *, char *,
+ size_t, int *))find_fn("getpwnam_r");
static struct passwd pwd;
static char buf[1000];
NSS_STATUS status;
@@ -106,7 +110,9 @@ static struct passwd *nss_getpwnam(const char *name)
static struct passwd *nss_getpwuid(uid_t uid)
{
NSS_STATUS (*_nss_getpwuid_r)(uid_t , struct passwd *, char *,
- size_t , int *) = find_fn("getpwuid_r");
+ size_t , int *) =
+ (NSS_STATUS (*)(uid_t, struct passwd *, char *,
+ size_t, int *))find_fn("getpwuid_r");
static struct passwd pwd;
static char buf[1000];
NSS_STATUS status;
@@ -127,7 +133,8 @@ static struct passwd *nss_getpwuid(uid_t uid)
static void nss_setpwent(void)
{
- NSS_STATUS (*_nss_setpwent)(void) = find_fn("setpwent");
+ NSS_STATUS (*_nss_setpwent)(void) =
+ (NSS_STATUS(*)(void))find_fn("setpwent");
NSS_STATUS status;
if (!_nss_setpwent)
@@ -141,7 +148,8 @@ static void nss_setpwent(void)
static void nss_endpwent(void)
{
- NSS_STATUS (*_nss_endpwent)(void) = find_fn("endpwent");
+ NSS_STATUS (*_nss_endpwent)(void) =
+ (NSS_STATUS (*)(void))find_fn("endpwent");
NSS_STATUS status;
if (!_nss_endpwent)
@@ -157,7 +165,9 @@ static void nss_endpwent(void)
static struct group *nss_getgrent(void)
{
NSS_STATUS (*_nss_getgrent_r)(struct group *, char *,
- size_t , int *) = find_fn("getgrent_r");
+ size_t , int *) =
+ (NSS_STATUS (*)(struct group *, char *,
+ size_t, int *))find_fn("getgrent_r");
static struct group grp;
static char *buf;
static int buflen = 1024;
@@ -167,13 +177,13 @@ static struct group *nss_getgrent(void)
return NULL;
if (!buf)
- buf = SMB_MALLOC(buflen);
+ buf = SMB_MALLOC_ARRAY(char, buflen);
again:
status = _nss_getgrent_r(&grp, buf, buflen, &nss_errno);
if (status == NSS_STATUS_TRYAGAIN) {
buflen *= 2;
- buf = SMB_REALLOC(buf, buflen);
+ buf = SMB_REALLOC_ARRAY(buf, char, buflen);
if (!buf) {
return NULL;
}
@@ -192,7 +202,9 @@ again:
static struct group *nss_getgrnam(const char *name)
{
NSS_STATUS (*_nss_getgrnam_r)(const char *, struct group *, char *,
- size_t , int *) = find_fn("getgrnam_r");
+ size_t , int *) =
+ (NSS_STATUS (*)(const char *, struct group *, char *,
+ size_t, int *))find_fn("getgrnam_r");
static struct group grp;
static char *buf;
static int buflen = 1000;
@@ -202,12 +214,12 @@ static struct group *nss_getgrnam(const char *name)
return NULL;
if (!buf)
- buf = SMB_MALLOC(buflen);
+ buf = SMB_MALLOC_ARRAY(char, buflen);
again:
status = _nss_getgrnam_r(name, &grp, buf, buflen, &nss_errno);
if (status == NSS_STATUS_TRYAGAIN) {
buflen *= 2;
- buf = SMB_REALLOC(buf, buflen);
+ buf = SMB_REALLOC_ARRAY(buf, char, buflen);
if (!buf) {
return NULL;
}
@@ -226,7 +238,9 @@ again:
static struct group *nss_getgrgid(gid_t gid)
{
NSS_STATUS (*_nss_getgrgid_r)(gid_t , struct group *, char *,
- size_t , int *) = find_fn("getgrgid_r");
+ size_t , int *) =
+ (NSS_STATUS (*)(gid_t, struct group *, char *,
+ size_t, int *))find_fn("getgrgid_r");
static struct group grp;
static char *buf;
static int buflen = 1000;
@@ -236,13 +250,13 @@ static struct group *nss_getgrgid(gid_t gid)
return NULL;
if (!buf)
- buf = SMB_MALLOC(buflen);
+ buf = SMB_MALLOC_ARRAY(char, buflen);
again:
status = _nss_getgrgid_r(gid, &grp, buf, buflen, &nss_errno);
if (status == NSS_STATUS_TRYAGAIN) {
buflen *= 2;
- buf = SMB_REALLOC(buf, buflen);
+ buf = SMB_REALLOC_ARRAY(buf, char, buflen);
if (!buf) {
return NULL;
}
@@ -260,7 +274,8 @@ again:
static void nss_setgrent(void)
{
- NSS_STATUS (*_nss_setgrent)(void) = find_fn("setgrent");
+ NSS_STATUS (*_nss_setgrent)(void) =
+ (NSS_STATUS (*)(void))find_fn("setgrent");
NSS_STATUS status;
if (!_nss_setgrent)
@@ -274,7 +289,8 @@ static void nss_setgrent(void)
static void nss_endgrent(void)
{
- NSS_STATUS (*_nss_endgrent)(void) = find_fn("endgrent");
+ NSS_STATUS (*_nss_endgrent)(void) =
+ (NSS_STATUS (*)(void))find_fn("endgrent");
NSS_STATUS status;
if (!_nss_endgrent)
@@ -290,7 +306,9 @@ static int nss_initgroups(char *user, gid_t group, gid_t **groups, long int *sta
{
NSS_STATUS (*_nss_initgroups)(char *, gid_t , long int *,
long int *, gid_t **, long int , int *) =
- find_fn("initgroups_dyn");
+ (NSS_STATUS (*)(char *, gid_t, long int *,
+ long int *, gid_t **,
+ long int, int *))find_fn("initgroups_dyn");
NSS_STATUS status;
if (!_nss_initgroups)
diff --git a/source3/torture/pdbtest.c b/source3/torture/pdbtest.c
new file mode 100644
index 0000000000..e1a35b7912
--- /dev/null
+++ b/source3/torture/pdbtest.c
@@ -0,0 +1,392 @@
+/*
+ Unix SMB/CIFS implementation.
+ passdb testing utility
+
+ Copyright (C) Wilco Baan Hofman 2006
+ Copyright (C) Jelmer Vernooij 2006
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+
+#include "includes.h"
+
+static BOOL samu_correct(struct samu *s1, struct samu *s2)
+{
+ BOOL ret = True;
+ uint32 s1_len, s2_len;
+ const char *s1_buf, *s2_buf;
+ const uint8 *d1_buf, *d2_buf;
+
+ /* Check Unix username */
+ s1_buf = pdb_get_username(s1);
+ s2_buf = pdb_get_username(s2);
+ if (s2_buf == NULL && s1_buf != NULL) {
+ DEBUG(0, ("Username is not set\n"));
+ ret = False;
+ } else if (s1_buf == NULL) {
+ /* Do nothing */
+ } else if (strcmp(s1_buf,s2_buf)) {
+ DEBUG(0, ("Username not written correctly, want %s, got \"%s\"\n",
+ pdb_get_username(s1),
+ pdb_get_username(s2)));
+ ret = False;
+ }
+
+ /* Check NT username */
+ s1_buf = pdb_get_nt_username(s1);
+ s2_buf = pdb_get_nt_username(s2);
+ if (s2_buf == NULL && s1_buf != NULL) {
+ DEBUG(0, ("NT Username is not set\n"));
+ ret = False;
+ } else if (s1_buf == NULL) {
+ /* Do nothing */
+ } else if (strcmp(s1_buf, s2_buf)) {
+ DEBUG(0, ("NT Username not written correctly, want \"%s\", got \"%s\"\n",
+ pdb_get_nt_username(s1),
+ pdb_get_nt_username(s2)));
+ ret = False;
+ }
+
+ /* Check acct ctrl */
+ if (pdb_get_acct_ctrl(s1) != pdb_get_acct_ctrl(s2)) {
+ DEBUG(0, ("Acct ctrl field not written correctly, want %d (0x%X), got %d (0x%X)\n",
+ pdb_get_acct_ctrl(s1),
+ pdb_get_acct_ctrl(s1),
+ pdb_get_acct_ctrl(s2),
+ pdb_get_acct_ctrl(s2)));
+ ret = False;
+ }
+
+ /* Check NT password */
+ d1_buf = pdb_get_nt_passwd(s1);
+ d2_buf = pdb_get_nt_passwd(s2);
+ if (d2_buf == NULL && d1_buf != NULL) {
+ DEBUG(0, ("NT password is not set\n"));
+ ret = False;
+ } else if (d1_buf == NULL) {
+ /* Do nothing */
+ } else if (memcmp(d1_buf, d2_buf, NT_HASH_LEN)) {
+ DEBUG(0, ("NT password not written correctly\n"));
+ ret = False;
+ }
+
+ /* Check lanman password */
+ d1_buf = pdb_get_lanman_passwd(s1);
+ d2_buf = pdb_get_lanman_passwd(s2);
+ if (d2_buf == NULL && d1_buf != NULL) {
+ DEBUG(0, ("Lanman password is not set\n"));
+ } else if (d1_buf == NULL) {
+ /* Do nothing */
+ } else if (memcmp(d1_buf, d2_buf, NT_HASH_LEN)) {
+ DEBUG(0, ("Lanman password not written correctly\n"));
+ ret = False;
+ }
+
+ /* Check password history */
+ d1_buf = pdb_get_pw_history(s1, &s1_len);
+ d2_buf = pdb_get_pw_history(s2, &s2_len);
+ if (d2_buf == NULL && d1_buf != NULL) {
+ DEBUG(0, ("Password history is not set\n"));
+ } else if (d1_buf == NULL) {
+ /* Do nothing */
+ } else if (s1_len != s1_len) {
+ DEBUG(0, ("Password history not written correctly, lengths differ, want %d, got %d\n",
+ s1_len, s2_len));
+ ret = False;
+ } else if (strncmp(s1_buf, s2_buf, s1_len)) {
+ DEBUG(0, ("Password history not written correctly\n"));
+ ret = False;
+ }
+
+ /* Check logon time */
+ if (pdb_get_logon_time(s1) != pdb_get_logon_time(s2)) {
+ DEBUG(0, ("Logon time is not written correctly\n"));
+ ret = False;
+ }
+
+ /* Check logoff time */
+ if (pdb_get_logoff_time(s1) != pdb_get_logoff_time(s2)) {
+ DEBUG(0, ("Logoff time is not written correctly\n"));
+ ret = False;
+ }
+
+ /* Check kickoff time */
+ if (pdb_get_kickoff_time(s1) != pdb_get_logoff_time(s2)) {
+ DEBUG(0, ("Kickoff time is not written correctly\n"));
+ ret = False;
+ }
+
+ /* Check bad password time */
+ if (pdb_get_bad_password_time(s1) != pdb_get_bad_password_time(s2)) {
+ DEBUG(0, ("Bad password time is not written correctly\n"));
+ ret = False;
+ }
+
+ /* Check password last set time */
+ if (pdb_get_pass_last_set_time(s1) != pdb_get_pass_last_set_time(s2)) {
+ DEBUG(0, ("Password last set time is not written correctly\n"));
+ ret = False;
+ }
+
+ /* Check password can change time */
+ if (pdb_get_pass_can_change_time(s1) != pdb_get_pass_can_change_time(s2)) {
+ DEBUG(0, ("Password can change time is not written correctly\n"));
+ ret = False;
+ }
+
+ /* Check password must change time */
+ if (pdb_get_pass_must_change_time(s1) != pdb_get_pass_must_change_time(s2)) {
+ DEBUG(0, ("Password must change time is not written correctly\n"));
+ ret = False;
+ }
+
+ /* Check logon divs */
+ if (pdb_get_logon_divs(s1) != pdb_get_logon_divs(s2)) {
+ DEBUG(0, ("Logon divs not written correctly\n"));
+ ret = False;
+ }
+
+ /* Check logon hours */
+ if (pdb_get_hours_len(s1) != pdb_get_hours_len(s2)) {
+ DEBUG(0, ("Logon hours length not written correctly\n"));
+ ret = False;
+ } else if (pdb_get_hours_len(s1) != 0) {
+ d1_buf = pdb_get_hours(s1);
+ d2_buf = pdb_get_hours(s2);
+ if (d2_buf == NULL && d2_buf != NULL) {
+ DEBUG(0, ("Logon hours is not set\n"));
+ ret = False;
+ } else if (d1_buf == NULL) {
+ /* Do nothing */
+ } else if (memcmp(d1_buf, d2_buf, MAX_HOURS_LEN)) {
+ DEBUG(0, ("Logon hours is not written correctly\n"));
+ ret = False;
+ }
+ }
+
+ /* Check profile path */
+ s1_buf = pdb_get_profile_path(s1);
+ s2_buf = pdb_get_profile_path(s2);
+ if (s2_buf == NULL && s1_buf != NULL) {
+ DEBUG(0, ("Profile path is not set\n"));
+ ret = False;
+ } else if (s1_buf == NULL) {
+ /* Do nothing */
+ } else if (strcmp(s1_buf, s2_buf)) {
+ DEBUG(0, ("Profile path is not written correctly\n"));
+ ret = False;
+ }
+
+ /* Check home dir */
+ s1_buf = pdb_get_homedir(s1);
+ s2_buf = pdb_get_homedir(s2);
+ if (s2_buf == NULL && s1_buf != NULL) {
+ DEBUG(0, ("Home dir is not set\n"));
+ ret = False;
+ } else if (s1_buf == NULL) {
+ /* Do nothing */
+ } else if (strcmp(s1_buf, s2_buf)) {
+ DEBUG(0, ("Home dir is not written correctly\n"));
+ ret = False;
+ }
+
+ /* Check logon script */
+ s1_buf = pdb_get_logon_script(s1);
+ s2_buf = pdb_get_logon_script(s2);
+ if (s2_buf == NULL && s1_buf != NULL) {
+ DEBUG(0, ("Logon script not set\n"));
+ ret = False;
+ } else if (s1_buf == NULL) {
+ /* Do nothing */
+ } else if (strcmp(s1_buf, s2_buf)) {
+ DEBUG(0, ("Logon script is not written correctly\n"));
+ ret = False;
+ }
+
+ /* TODO Check user and group sids */
+
+ return ret;
+}
+
+
+int main(int argc, char **argv)
+{
+ TALLOC_CTX *ctx;
+ struct samu *out = NULL;
+ struct samu *in = NULL;
+ NTSTATUS rv;
+ int i;
+ struct timeval tv;
+ BOOL error = False;
+ struct passwd *pwd;
+ uint8 *buf;
+ uint32 expire, min_age, history;
+ struct pdb_methods *pdb;
+ poptContext pc;
+ static char *backend = NULL;
+ static const char *unix_user = "nobody";
+ struct poptOption long_options[] = {
+ {"username", 'u', POPT_ARG_STRING, &unix_user, 0, "Unix user to use for testing", "USERNAME" },
+ {"backend", 'b', POPT_ARG_STRING, &backend, 0, "Backend to use if not default", "BACKEND[:SETTINGS]" },
+ POPT_AUTOHELP
+ POPT_COMMON_SAMBA
+ POPT_TABLEEND
+ };
+
+ load_case_tables();
+
+ pc = poptGetContext("vfstest", argc, (const char **) argv,
+ long_options, 0);
+
+ poptSetOtherOptionHelp(pc, "backend[:settings] username");
+
+ while(poptGetNextOpt(pc) != -1);
+
+ poptFreeContext(pc);
+
+ /* Load configuration */
+ lp_load(dyn_CONFIGFILE, False, False, True, True);
+ setup_logging("pdbtest", True);
+
+ if (backend == NULL) {
+ backend = lp_passdb_backend();
+ }
+
+ rv = make_pdb_method_name(&pdb, backend);
+ if (NT_STATUS_IS_ERR(rv)) {
+ fprintf(stderr, "Error initializing '%s': %s\n", backend, get_friendly_nt_error_msg(rv));
+ exit(1);
+ }
+
+ ctx = talloc_init("PDBTEST");
+
+ if (!(out = samu_new(ctx))) {
+ fprintf(stderr, "Can't create samu structure.\n");
+ exit(1);
+ }
+
+ if ((pwd = getpwnam_alloc(ctx, unix_user)) == NULL) {
+ fprintf(stderr, "Error getting user information for %s\n", unix_user);
+ exit(1);
+ }
+
+ samu_set_unix(out, pwd);
+
+ pdb_set_profile_path(out, "\\\\torture\\profile", PDB_SET);
+ pdb_set_homedir(out, "\\\\torture\\home", PDB_SET);
+ pdb_set_logon_script(out, "torture_script.cmd", PDB_SET);
+
+ pdb_get_account_policy(AP_PASSWORD_HISTORY, &history);
+ if (history * PW_HISTORY_ENTRY_LEN < NT_HASH_LEN) {
+ buf = TALLOC(ctx, NT_HASH_LEN);
+ } else {
+ buf = TALLOC(ctx, history * PW_HISTORY_ENTRY_LEN);
+ }
+
+ /* Generate some random hashes */
+ GetTimeOfDay(&tv);
+ srand(tv.tv_usec);
+ for (i = 0; i < NT_HASH_LEN; i++) {
+ buf[i] = (uint8) rand();
+ }
+ pdb_set_nt_passwd(out, buf, PDB_SET);
+ for (i = 0; i < LM_HASH_LEN; i++) {
+ buf[i] = (uint8) rand();
+ }
+ pdb_set_lanman_passwd(out, buf, PDB_SET);
+ for (i = 0; i < history * PW_HISTORY_ENTRY_LEN; i++) {
+ buf[i] = (uint8) rand();
+ }
+ pdb_set_pw_history(out, buf, history, PDB_SET);
+
+ pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &expire);
+ pdb_get_account_policy(AP_MIN_PASSWORD_AGE, &min_age);
+ pdb_set_pass_last_set_time(out, time(NULL), PDB_SET);
+
+ if (expire == 0 || expire == (uint32)-1) {
+ pdb_set_pass_must_change_time(out, get_time_t_max(), PDB_SET);
+ } else {
+ pdb_set_pass_must_change_time(out, time(NULL)+expire, PDB_SET);
+ }
+
+ if (min_age == (uint32)-1) {
+ pdb_set_pass_can_change_time(out, 0, PDB_SET);
+ } else {
+ pdb_set_pass_can_change_time(out, time(NULL)+min_age, PDB_SET);
+ }
+
+ /* Create account */
+ if (!NT_STATUS_IS_OK(rv = pdb->add_sam_account(pdb, out))) {
+ fprintf(stderr, "Error in add_sam_account: %s\n",
+ get_friendly_nt_error_msg(rv));
+ exit(1);
+ }
+
+ if (!(in = samu_new(ctx))) {
+ fprintf(stderr, "Can't create samu structure.\n");
+ exit(1);
+ }
+
+ /* Get account information through getsampwnam() */
+ if (NT_STATUS_IS_ERR(pdb->getsampwnam(pdb, in, out->username))) {
+ fprintf(stderr, "Error getting sampw of added user %s.\n",
+ out->username);
+ if (!NT_STATUS_IS_OK(rv = pdb->delete_sam_account(pdb, out))) {
+ fprintf(stderr, "Error in delete_sam_account %s\n",
+ get_friendly_nt_error_msg(rv));
+ }
+ TALLOC_FREE(ctx);
+ }
+
+ /* Verify integrity */
+ if (samu_correct(out, in)) {
+ printf("User info written correctly\n");
+ } else {
+ printf("User info NOT written correctly\n");
+ error = True;
+ }
+
+ /* Delete account */
+ if (!NT_STATUS_IS_OK(rv = pdb->delete_sam_account(pdb, out))) {
+ fprintf(stderr, "Error in delete_sam_account %s\n",
+ get_friendly_nt_error_msg(rv));
+ }
+
+ pdb->setsampwent(pdb, False, 0);
+ while (NT_STATUS_IS_OK(pdb->getsampwent(pdb, out))) {
+ if (pdb_get_username(out) == NULL) {
+ fprintf(stderr, "Got bad username through getsampwent()\n");
+ error = True;
+ break;
+ }
+ if (NT_STATUS_IS_ERR(pdb->getsampwnam(pdb, in, pdb_get_username(out)))) {
+ fprintf(stderr, "Error getting samu through getsampwnam() of an account we got through getsampwent!\n");
+ error = True;
+ continue;
+ }
+ if (!samu_correct(out, in)) {
+ printf("Record gotten through getsampwnam() differs from same record through getsampwent()\n");
+ }
+ }
+ pdb->endsampwent(pdb);
+
+ TALLOC_FREE(ctx);
+
+ if (error) {
+ return 1;
+ }
+ return 0;
+}
diff --git a/source3/torture/rpctorture.c b/source3/torture/rpctorture.c
index d69cc8eb8d..98f2dc105f 100644
--- a/source3/torture/rpctorture.c
+++ b/source3/torture/rpctorture.c
@@ -493,7 +493,7 @@ enum client_action
strupper_m(global_myname);
fstrcpy(cli_info.myhostname, global_myname);
- DEBUG(3,("%s client started (version %s)\n",timestring(False),SAMBA_VERSION_STRING));
+ DEBUG(3,("%s client started (version %s)\n",current_timestring(False),SAMBA_VERSION_STRING));
if (*smb_cli->domain == 0)
{
diff --git a/source3/torture/scanner.c b/source3/torture/scanner.c
index 1893be8369..1510cd70f4 100644
--- a/source3/torture/scanner.c
+++ b/source3/torture/scanner.c
@@ -49,7 +49,7 @@ static NTSTATUS try_trans2(struct cli_state *cli,
int op,
char *param, char *data,
int param_len, int data_len,
- int *rparam_len, int *rdata_len)
+ unsigned int *rparam_len, unsigned int *rdata_len)
{
uint16 setup = op;
char *rparam=NULL, *rdata=NULL;
@@ -80,7 +80,7 @@ static NTSTATUS try_trans2_len(struct cli_state *cli,
int op, int level,
char *param, char *data,
int param_len, int *data_len,
- int *rparam_len, int *rdata_len)
+ unsigned int *rparam_len, unsigned int *rdata_len)
{
NTSTATUS ret=NT_STATUS_OK;
@@ -115,7 +115,7 @@ static BOOL scan_trans2(struct cli_state *cli, int op, int level,
{
int data_len = 0;
int param_len = 0;
- int rparam_len, rdata_len;
+ unsigned int rparam_len, rdata_len;
pstring param, data;
NTSTATUS status;
@@ -253,7 +253,7 @@ static NTSTATUS try_nttrans(struct cli_state *cli,
int op,
char *param, char *data,
int param_len, int data_len,
- int *rparam_len, int *rdata_len)
+ unsigned int *rparam_len, unsigned int *rdata_len)
{
char *rparam=NULL, *rdata=NULL;
@@ -282,7 +282,7 @@ static NTSTATUS try_nttrans_len(struct cli_state *cli,
int op, int level,
char *param, char *data,
int param_len, int *data_len,
- int *rparam_len, int *rdata_len)
+ unsigned int *rparam_len, unsigned int *rdata_len)
{
NTSTATUS ret=NT_STATUS_OK;
@@ -317,7 +317,7 @@ static BOOL scan_nttrans(struct cli_state *cli, int op, int level,
{
int data_len = 0;
int param_len = 0;
- int rparam_len, rdata_len;
+ unsigned int rparam_len, rdata_len;
pstring param, data;
NTSTATUS status;
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 0b3bfc18f4..25e249ed2e 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -94,28 +94,27 @@ void *shm_setup(int size)
}
-static BOOL open_nbt_connection(struct cli_state *c)
+static struct cli_state *open_nbt_connection(void)
{
struct nmb_name called, calling;
struct in_addr ip;
-
- ZERO_STRUCTP(c);
+ struct cli_state *c;
make_nmb_name(&calling, myname, 0x0);
make_nmb_name(&called , host, 0x20);
zero_ip(&ip);
- if (!cli_initialise(c)) {
+ if (!(c = cli_initialise())) {
printf("Failed initialize cli_struct to connect with %s\n", host);
- return False;
+ return NULL;
}
c->port = port_to_use;
if (!cli_connect(c, host, &ip)) {
printf("Failed to connect with %s\n", host);
- return False;
+ return NULL;
}
c->use_kerberos = use_kerberos;
@@ -131,7 +130,7 @@ static BOOL open_nbt_connection(struct cli_state *c)
*/
if (!cli_connect(c, host, &ip)) {
printf("Failed to connect with %s\n", host);
- return False;
+ return NULL;
}
make_nmb_name(&called, "*SMBSERVER", 0x20);
@@ -140,11 +139,11 @@ static BOOL open_nbt_connection(struct cli_state *c)
printf("We tried with a called name of %s & %s\n",
host, "*SMBSERVER");
cli_shutdown(c);
- return False;
+ return NULL;
}
}
- return True;
+ return c;
}
BOOL torture_open_connection(struct cli_state **c)
@@ -462,8 +461,8 @@ static BOOL rw_torture2(struct cli_state *c1, struct cli_state *c2)
int fnum1;
int fnum2;
int i;
- uchar buf[131072];
- uchar buf_rd[131072];
+ char buf[131072];
+ char buf_rd[131072];
BOOL correct = True;
ssize_t bytes_read;
@@ -494,7 +493,7 @@ static BOOL rw_torture2(struct cli_state *c1, struct cli_state *c2)
printf("%d\r", i); fflush(stdout);
}
- generate_random_buffer(buf, buf_size);
+ generate_random_buffer((unsigned char *)buf, buf_size);
if (cli_write(c1, fnum1, 0, buf, 0, buf_size) != buf_size) {
printf("write failed (%s)\n", cli_errstr(c1));
@@ -2174,20 +2173,20 @@ static void rand_buf(char *buf, int len)
static BOOL run_negprot_nowait(int dummy)
{
int i;
- static struct cli_state cli;
+ static struct cli_state *cli;
BOOL correct = True;
printf("starting negprot nowait test\n");
- if (!open_nbt_connection(&cli)) {
+ if (!(cli = open_nbt_connection())) {
return False;
}
for (i=0;i<50000;i++) {
- cli_negprot_send(&cli);
+ cli_negprot_send(cli);
}
- if (!torture_close_connection(&cli)) {
+ if (!torture_close_connection(cli)) {
correct = False;
}
@@ -2202,7 +2201,7 @@ static BOOL run_randomipc(int dummy)
{
char *rparam = NULL;
char *rdata = NULL;
- int rdrcnt,rprcnt;
+ unsigned int rdrcnt,rprcnt;
pstring param;
int api, param_len, i;
struct cli_state *cli;
@@ -4418,7 +4417,8 @@ static BOOL run_eatest(int dummy)
for (i = 0; i < num_eas; i++) {
printf("%d: ea_name = %s. Val = ", i, ea_list[i].name);
- dump_data(0, ea_list[i].value.data, ea_list[i].value.length);
+ dump_data(0, (char *)ea_list[i].value.data,
+ ea_list[i].value.length);
}
/* Setting EA's to zero length deletes them. Test this */
@@ -4445,7 +4445,8 @@ static BOOL run_eatest(int dummy)
printf("num_eas = %d\n", num_eas);
for (i = 0; i < num_eas; i++) {
printf("%d: ea_name = %s. Val = ", i, ea_list[i].name);
- dump_data(0, ea_list[i].value.data, ea_list[i].value.length);
+ dump_data(0, (char *)ea_list[i].value.data,
+ ea_list[i].value.length);
}
if (num_eas != 0) {
@@ -4550,8 +4551,8 @@ static BOOL run_dirtest1(int dummy)
static BOOL run_error_map_extract(int dummy) {
- static struct cli_state c_dos;
- static struct cli_state c_nt;
+ static struct cli_state *c_dos;
+ static struct cli_state *c_nt;
uint32 error;
@@ -4564,81 +4565,81 @@ static BOOL run_error_map_extract(int dummy) {
/* NT-Error connection */
- if (!open_nbt_connection(&c_nt)) {
+ if (!(c_nt = open_nbt_connection())) {
return False;
}
- c_nt.use_spnego = False;
+ c_nt->use_spnego = False;
- if (!cli_negprot(&c_nt)) {
- printf("%s rejected the NT-error negprot (%s)\n",host, cli_errstr(&c_nt));
- cli_shutdown(&c_nt);
+ if (!cli_negprot(c_nt)) {
+ printf("%s rejected the NT-error negprot (%s)\n",host, cli_errstr(c_nt));
+ cli_shutdown(c_nt);
return False;
}
- if (!cli_session_setup(&c_nt, "", "", 0, "", 0,
+ if (!cli_session_setup(c_nt, "", "", 0, "", 0,
workgroup)) {
- printf("%s rejected the NT-error initial session setup (%s)\n",host, cli_errstr(&c_nt));
+ printf("%s rejected the NT-error initial session setup (%s)\n",host, cli_errstr(c_nt));
return False;
}
/* DOS-Error connection */
- if (!open_nbt_connection(&c_dos)) {
+ if (!(c_dos = open_nbt_connection())) {
return False;
}
- c_dos.use_spnego = False;
- c_dos.force_dos_errors = True;
+ c_dos->use_spnego = False;
+ c_dos->force_dos_errors = True;
- if (!cli_negprot(&c_dos)) {
- printf("%s rejected the DOS-error negprot (%s)\n",host, cli_errstr(&c_dos));
- cli_shutdown(&c_dos);
+ if (!cli_negprot(c_dos)) {
+ printf("%s rejected the DOS-error negprot (%s)\n",host, cli_errstr(c_dos));
+ cli_shutdown(c_dos);
return False;
}
- if (!cli_session_setup(&c_dos, "", "", 0, "", 0,
+ if (!cli_session_setup(c_dos, "", "", 0, "", 0,
workgroup)) {
- printf("%s rejected the DOS-error initial session setup (%s)\n",host, cli_errstr(&c_dos));
+ printf("%s rejected the DOS-error initial session setup (%s)\n",host, cli_errstr(c_dos));
return False;
}
for (error=(0xc0000000 | 0x1); error < (0xc0000000| 0xFFF); error++) {
fstr_sprintf(user, "%X", error);
- if (cli_session_setup(&c_nt, user,
+ if (cli_session_setup(c_nt, user,
password, strlen(password),
password, strlen(password),
workgroup)) {
printf("/** Session setup succeeded. This shouldn't happen...*/\n");
}
- flgs2 = SVAL(c_nt.inbuf,smb_flg2);
+ flgs2 = SVAL(c_nt->inbuf,smb_flg2);
/* Case #1: 32-bit NT errors */
if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) {
- nt_status = NT_STATUS(IVAL(c_nt.inbuf,smb_rcls));
+ nt_status = NT_STATUS(IVAL(c_nt->inbuf,smb_rcls));
} else {
printf("/** Dos error on NT connection! (%s) */\n",
- cli_errstr(&c_nt));
+ cli_errstr(c_nt));
nt_status = NT_STATUS(0xc0000000);
}
- if (cli_session_setup(&c_dos, user,
+ if (cli_session_setup(c_dos, user,
password, strlen(password),
password, strlen(password),
workgroup)) {
printf("/** Session setup succeeded. This shouldn't happen...*/\n");
}
- flgs2 = SVAL(c_dos.inbuf,smb_flg2), errnum;
+ flgs2 = SVAL(c_dos->inbuf,smb_flg2), errnum;
/* Case #1: 32-bit NT errors */
if (flgs2 & FLAGS2_32_BIT_ERROR_CODES) {
printf("/** NT error on DOS connection! (%s) */\n",
- cli_errstr(&c_nt));
+ cli_errstr(c_nt));
errnum = errclass = 0;
} else {
- cli_dos_error(&c_dos, &errclass, &errnum);
+ cli_dos_error(c_dos, &errclass, &errnum);
}
if (NT_STATUS_V(nt_status) != error) {
@@ -4655,6 +4656,42 @@ static BOOL run_error_map_extract(int dummy) {
return True;
}
+static BOOL run_local_substitute(int dummy)
+{
+ TALLOC_CTX *mem_ctx;
+ int diff = 0;
+
+ if ((mem_ctx = talloc_init("run_local_subst")) == NULL) {
+ printf("talloc_init failed\n");
+ return False;
+ }
+
+ diff |= strcmp(talloc_sub_specified(mem_ctx, "%U", "bla", "", -1, -1),
+ "bla");
+ diff |= strcmp(talloc_sub_specified(mem_ctx, "%u%U", "bla", "", -1, -1),
+ "blabla");
+ diff |= strcmp(talloc_sub_specified(mem_ctx, "%g", "", "", -1, -1),
+ "NO_GROUP");
+ diff |= strcmp(talloc_sub_specified(mem_ctx, "%G", "", "", -1, -1),
+ "NO_GROUP");
+ diff |= strcmp(talloc_sub_specified(mem_ctx, "%g", "", "", -1, 0),
+ gidtoname(0));
+ diff |= strcmp(talloc_sub_specified(mem_ctx, "%G", "", "", -1, 0),
+ gidtoname(0));
+ diff |= strcmp(talloc_sub_specified(mem_ctx, "%D%u", "u", "dom", -1, 0),
+ "domu");
+ diff |= strcmp(talloc_sub_specified(mem_ctx, "%i %I", "", "", -1, -1),
+ "0.0.0.0 0.0.0.0");
+
+ /* Different captialization rules in sub_basic... */
+
+ diff |= strcmp(talloc_sub_basic(mem_ctx, "BLA", "dom", "%U%D"),
+ "blaDOM");
+
+ TALLOC_FREE(mem_ctx);
+ return (diff == 0);
+}
+
static double create_procs(BOOL (*fn)(int), BOOL *result)
{
int i, status;
@@ -4805,6 +4842,7 @@ static struct {
{"CHKPATH", torture_chkpath_test, 0},
{"FDSESS", run_fdsesstest, 0},
{ "EATEST", run_eatest, 0},
+ { "LOCAL-SUBSTITUTE", run_local_substitute, 0},
{NULL, NULL, 0}};
diff --git a/source3/torture/vfstest.c b/source3/torture/vfstest.c
index 61bb4b0bf6..fa0545988e 100644
--- a/source3/torture/vfstest.c
+++ b/source3/torture/vfstest.c
@@ -575,6 +575,6 @@ int main(int argc, char *argv[])
process_cmd(&vfs, line);
}
- free(vfs.conn);
+ conn_free(vfs.conn);
return 0;
}