summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-08-09 20:51:16 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:57:48 -0500
commit9c41274ace0a1dd88b113ce2bf84b33b0c528efa (patch)
tree3029ae61eacacbd79fb3bb53226d820542f7258f /source4/torture
parent0f32036afef72cbf0050ddd057ed986f9ef35976 (diff)
downloadsamba-9c41274ace0a1dd88b113ce2bf84b33b0c528efa.tar.gz
samba-9c41274ace0a1dd88b113ce2bf84b33b0c528efa.tar.bz2
samba-9c41274ace0a1dd88b113ce2bf84b33b0c528efa.zip
r1676: - improved the handling of username/password in locktest and gentest
- use lp_maxprotocol() in the libcli/raw/ negotiate code, so we obey the smb.conf "max protocol" option - better handling of -M option in masktest (This used to be commit 8685a584c92ab73a35b29a8c719f1ec207562837)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/config.mk3
-rw-r--r--source4/torture/gentest.c8
-rw-r--r--source4/torture/locktest.c62
-rw-r--r--source4/torture/masktest.c9
4 files changed, 35 insertions, 47 deletions
diff --git a/source4/torture/config.mk b/source4/torture/config.mk
index 77d01f75c0..c520ef755b 100644
--- a/source4/torture/config.mk
+++ b/source4/torture/config.mk
@@ -151,7 +151,8 @@ REQUIRED_SUBSYSTEMS = \
# Start BINARY locktest
[BINARY::locktest]
OBJ_FILES = \
- torture/locktest.o
+ torture/locktest.o \
+ torture/torture_util.o
REQUIRED_SUBSYSTEMS = \
LIBSMB \
CONFIG \
diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c
index 53dd83ac15..d414863d82 100644
--- a/source4/torture/gentest.c
+++ b/source4/torture/gentest.c
@@ -2068,7 +2068,7 @@ static void usage(void)
"Usage:\n\
gentest2 //server1/share1 //server2/share2 [options..]\n\
options:\n\
- -U user%%pass (must be specified twice)\n\
+ -U user%%pass (can be specified twice)\n\
-s seed\n\
-o numops\n\
-a (show all ops)\n\
@@ -2179,10 +2179,14 @@ static void usage(void)
}
}
- if (!servers[0].username || !servers[1].username) {
+ if (!servers[0].username) {
usage();
return -1;
}
+ if (!servers[1].username) {
+ servers[1].username = servers[0].username;
+ servers[1].password = servers[0].password;
+ }
printf("seed=%u\n", options.seed);
diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c
index e56684a5a4..494688dfb5 100644
--- a/source4/torture/locktest.c
+++ b/source4/torture/locktest.c
@@ -20,11 +20,6 @@
#include "includes.h"
-static fstring password[2];
-static fstring username[2];
-static int got_user;
-static int got_pass;
-static BOOL use_kerberos;
static int numops = 1000;
static BOOL showall;
static BOOL analyze;
@@ -49,6 +44,11 @@ static BOOL zero_zero;
#define NASTY_POSIX_LOCK_HACK 0
+static struct {
+ char *username;
+ char *password;
+} servers[NSERVERS];
+
enum lock_op {OP_LOCK, OP_UNLOCK, OP_REOPEN};
struct record {
@@ -118,15 +118,12 @@ static struct smbcli_state *connect_one(char *share, int snum)
slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), snum);
- if (use_kerberos)
- flags |= SMBCLI_FULL_CONNECTION_USE_KERBEROS;
-
do {
status = smbcli_full_connection(&c, myname,
server, NULL,
share, "?????",
- username[snum], lp_workgroup(),
- password[snum], flags, NULL);
+ servers[snum].username, lp_workgroup(),
+ servers[snum].password, flags, NULL);
if (!NT_STATUS_IS_OK(status)) {
sleep(2);
}
@@ -437,7 +434,6 @@ static void usage(void)
locktest //server1/share1 //server2/share2 [options..]\n\
options:\n\
-U user%%pass (may be specified twice)\n\
- -k use kerberos\n\
-s seed\n\
-o numops\n\
-u hide unlock fails\n\
@@ -459,8 +455,7 @@ static void usage(void)
{
char *share[NSERVERS];
int opt;
- char *p;
- int seed, server;
+ int seed, server, i;
setlinebuf(stdout);
@@ -484,35 +479,17 @@ static void usage(void)
lp_load(dyn_CONFIGFILE,True,False,False);
load_interfaces();
- if (getenv("USER")) {
- fstrcpy(username[0],getenv("USER"));
- fstrcpy(username[1],getenv("USER"));
- }
-
seed = time(NULL);
- while ((opt = getopt(argc, argv, "U:s:ho:aAW:OkR:B:M:EZW:")) != EOF) {
+ while ((opt = getopt(argc, argv, "U:s:ho:aAW:OR:B:M:EZW:")) != EOF) {
switch (opt) {
- case 'k':
-#ifdef HAVE_KRB5
- use_kerberos = True;
-#else
- d_printf("No kerberos support compiled in\n");
- exit(1);
-#endif
- break;
case 'U':
- got_user = 1;
- if (got_pass == 2) {
- d_printf("Max of 2 usernames\n");
- exit(1);
- }
- fstrcpy(username[got_pass],optarg);
- p = strchr_m(username[got_pass],'%');
- if (p) {
- *p = 0;
- fstrcpy(password[got_pass], p+1);
- got_pass++;
+ i = servers[0].username?1:0;
+ if (!split_username(optarg,
+ &servers[i].username,
+ &servers[i].password)) {
+ printf("Must supply USER%%PASS\n");
+ return -1;
}
break;
case 'R':
@@ -560,7 +537,14 @@ static void usage(void)
}
}
- if(use_kerberos && !got_user) got_pass = True;
+ if (!servers[0].username) {
+ usage();
+ return -1;
+ }
+ if (!servers[1].username) {
+ servers[1].username = servers[0].username;
+ servers[1].password = servers[0].password;
+ }
argc -= optind;
argv += optind;
diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c
index 4c219c630e..ee7e25ebbd 100644
--- a/source4/torture/masktest.c
+++ b/source4/torture/masktest.c
@@ -22,7 +22,6 @@
static fstring password;
static fstring username;
-static int max_protocol = PROTOCOL_NT1;
static BOOL showall = False;
static BOOL old_list = False;
static const char *maskchars = "<>\"?*abc.";
@@ -130,7 +129,7 @@ static BOOL reg_match_one(struct smbcli_state *cli, const char *pattern, const c
if (strcmp(pattern,".") == 0) return False;
- if (max_protocol <= PROTOCOL_LANMAN2) {
+ if (cli->transport->negotiate.protocol <= PROTOCOL_LANMAN1) {
return ms_fnmatch_lanman(pattern, file)==0;
}
@@ -208,7 +207,7 @@ static void get_real_name(struct smbcli_state *cli,
pstring long_name, fstring short_name)
{
const char *mask;
- if (max_protocol <= PROTOCOL_LANMAN1) {
+ if (cli->transport->negotiate.protocol <= PROTOCOL_LANMAN1) {
mask = "\\masktest\\*.*";
} else {
mask = "\\masktest\\*";
@@ -410,7 +409,7 @@ static void usage(void)
verbose++;
break;
case 'M':
- max_protocol = interpret_protocol(optarg, max_protocol);
+ lp_set_cmdline("max protocol", optarg);
break;
case 'U':
fstrcpy(username,optarg);
@@ -455,7 +454,7 @@ static void usage(void)
}
/* need to init seed after connect as clientgen uses random numbers */
- DEBUG(0,("seed=%d\n", seed));
+ DEBUG(0,("seed=%d format --- --- (server, correct)\n", seed));
srandom(seed);
test_mask(argc, argv, cli);