diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-03-21 23:35:58 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:11:09 -0500 |
commit | 13b0776f60f6a0f35a4afc2b3d3c6b5ec9c1ca6a (patch) | |
tree | 8eddfcb0dd18a9cee4c1de4fbd3ee98f05cd27e6 /source4/torture | |
parent | 05bc2d7b2c11a3583a6d1221cfbd618eb6730518 (diff) | |
download | samba-13b0776f60f6a0f35a4afc2b3d3c6b5ec9c1ca6a.tar.gz samba-13b0776f60f6a0f35a4afc2b3d3c6b5ec9c1ca6a.tar.bz2 samba-13b0776f60f6a0f35a4afc2b3d3c6b5ec9c1ca6a.zip |
r5929: Use cli_credentials for the SMB functions as well.
Fix a couple of bugs in the new cli_credentials code
(This used to be commit 4ad481cfe5cde514d2ef9646147239f3faaa6173)
Diffstat (limited to 'source4/torture')
-rw-r--r-- | source4/torture/gentest.c | 29 | ||||
-rw-r--r-- | source4/torture/locktest.c | 16 | ||||
-rw-r--r-- | source4/torture/masktest.c | 19 | ||||
-rw-r--r-- | source4/torture/torture.c | 12 |
4 files changed, 22 insertions, 54 deletions
diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c index 19fa03df8c..92d6da9fef 100644 --- a/source4/torture/gentest.c +++ b/source4/torture/gentest.c @@ -60,8 +60,7 @@ static struct { struct smbcli_state *cli[NINSTANCES]; char *server_name; char *share_name; - char *username; - char *password; + struct cli_credentials credentials; } servers[NSERVERS]; /* the seeds and flags for each operation */ @@ -176,14 +175,13 @@ static BOOL connect_servers(void) NTSTATUS status; printf("Connecting to \\\\%s\\%s as %s - instance %d\n", servers[i].server_name, servers[i].share_name, - servers[i].username, j); + servers[i].credentials.username, j); + status = smbcli_full_connection(NULL, &servers[i].cli[j], "gentest", servers[i].server_name, - servers[i].share_name, NULL, - servers[i].username, - lp_workgroup(), - servers[i].password); + servers[i].share_name, NULL, + &servers[i].credentials); if (!NT_STATUS_IS_OK(status)) { printf("Failed to connect to \\\\%s\\%s - %s\n", servers[i].server_name, servers[i].share_name, @@ -2137,13 +2135,8 @@ static void usage(void) while ((opt = getopt(argc, argv, "U:s:o:ad:i:AOhS:LFXC")) != EOF) { switch (opt) { case 'U': - i = servers[0].username?1:0; - if (!split_username(optarg, - &servers[i].username, - &servers[i].password)) { - printf("Must supply USER%%PASS\n"); - return -1; - } + i = servers[0].credentials.username?1:0; + cli_credentials_parse_string(&servers[0].credentials, optarg, CRED_SPECIFIED); break; case 'd': DEBUGLEVEL = atoi(optarg); @@ -2193,13 +2186,13 @@ static void usage(void) gentest_init_subsystems; - if (!servers[0].username) { + if (!servers[0].credentials.username) { usage(); return -1; } - if (!servers[1].username) { - servers[1].username = servers[0].username; - servers[1].password = servers[0].password; + if (!servers[1].credentials.username) { + servers[1].credentials.username = servers[0].credentials.username; + servers[1].credentials.password = servers[0].credentials.password; } printf("seed=%u\n", options.seed); diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c index 74f348638c..005f9af71b 100644 --- a/source4/torture/locktest.c +++ b/source4/torture/locktest.c @@ -47,10 +47,7 @@ static BOOL zero_zero; #define NASTY_POSIX_LOCK_HACK 0 -static struct { - char *username; - char *password; -} servers[NSERVERS]; +static struct cli_credentials servers[NSERVERS]; enum lock_op {OP_LOCK, OP_UNLOCK, OP_REOPEN}; @@ -124,8 +121,7 @@ static struct smbcli_state *connect_one(char *share, int snum) status = smbcli_full_connection(NULL, &c, myname, server, share, NULL, - servers[snum].username, lp_workgroup(), - servers[snum].password); + &servers[snum]); if (!NT_STATUS_IS_OK(status)) { sleep(2); } @@ -487,12 +483,8 @@ static void usage(void) switch (opt) { case 'U': i = servers[0].username?1:0; - if (!split_username(optarg, - &servers[i].username, - &servers[i].password)) { - printf("Must supply USER%%PASS\n"); - return -1; - } + cli_credentials_parse_string(&servers[0], optarg, CRED_SPECIFIED); + break; case 'R': lock_range = strtol(optarg, NULL, 0); diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c index 4c71385ad0..00a0c2688d 100644 --- a/source4/torture/masktest.c +++ b/source4/torture/masktest.c @@ -25,8 +25,7 @@ #include "libcli/raw/libcliraw.h" #include "system/time.h" -static fstring password; -static fstring username; +static struct cli_credentials credentials; static BOOL showall = False; static BOOL old_list = False; static const char *maskchars = "<>\"?*abc."; @@ -81,8 +80,7 @@ static struct smbcli_state *connect_one(char *share) status = smbcli_full_connection(NULL, &c, "masktest", server, share, NULL, - username, lp_workgroup(), - password); + &credentials); if (!NT_STATUS_IS_OK(status)) { return NULL; @@ -274,7 +272,6 @@ static void usage(void) char *share; struct smbcli_state *cli; int opt; - char *p; int seed; setlinebuf(stdout); @@ -300,9 +297,8 @@ static void usage(void) lp_load(dyn_CONFIGFILE,True,False,False); load_interfaces(); - if (getenv("USER")) { - fstrcpy(username,getenv("USER")); - } + ZERO_STRUCT(credentials); + cli_credentials_guess(&credentials); seed = time(NULL); @@ -326,12 +322,7 @@ static void usage(void) lp_set_cmdline("max protocol", optarg); break; case 'U': - fstrcpy(username,optarg); - p = strchr_m(username,'%'); - if (p) { - *p = 0; - fstrcpy(password, p+1); - } + cli_credentials_parse_string(&credentials, optarg, CRED_SPECIFIED); break; case 's': seed = atoi(optarg); diff --git a/source4/torture/torture.c b/source4/torture/torture.c index dce91452f1..cdc9efbf7c 100644 --- a/source4/torture/torture.c +++ b/source4/torture/torture.c @@ -80,16 +80,12 @@ BOOL torture_open_connection_share(struct smbcli_state **c, const char *sharename) { NTSTATUS status; - const char *username = cli_credentials_get_username(cmdline_credentials); - const char *userdomain = cli_credentials_get_domain(cmdline_credentials); - const char *password = cli_credentials_get_password(cmdline_credentials); status = smbcli_full_connection(NULL, c, lp_netbios_name(), hostname, sharename, NULL, - username, username[0]?userdomain:"", - password); + cmdline_credentials); if (!NT_STATUS_IS_OK(status)) { printf("Failed to open connection - %s\n", nt_errstr(status)); return False; @@ -726,16 +722,12 @@ static BOOL run_tcon_devtype_test(void) BOOL ret = True; const char *host = lp_parm_string(-1, "torture", "host"); const char *share = lp_parm_string(-1, "torture", "share"); - const char *username = cli_credentials_get_username(cmdline_credentials); - const char *userdomain = cli_credentials_get_domain(cmdline_credentials); - const char *password = cli_credentials_get_password(cmdline_credentials); status = smbcli_full_connection(NULL, &cli1, lp_netbios_name(), host, share, NULL, - username, userdomain, - password); + cmdline_credentials); if (!NT_STATUS_IS_OK(status)) { printf("could not open connection\n"); |