diff options
author | Stefan Metzmacher <metze@samba.org> | 2004-08-25 14:31:59 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:58:23 -0500 |
commit | 8aa051c7b2fa651d284321715f16d94215128abf (patch) | |
tree | 91cd43baacfdd5a08ddd345189fef4eecdf307a7 | |
parent | 7eb820d31b39cda74b56c4c2dc66daa768f5216f (diff) | |
download | samba-8aa051c7b2fa651d284321715f16d94215128abf.tar.gz samba-8aa051c7b2fa651d284321715f16d94215128abf.tar.bz2 samba-8aa051c7b2fa651d284321715f16d94215128abf.zip |
r2071: - change smbtorture to use the popt_common stuff
this means -U DOM\\user is know allowed
- torture:userdomain is a new smb.conf parameter
because lp_workgroup is not the domain of the user
- we use torture:userdomain now in the tests instad of lp_workgroup
- for backward compat the userdomain is lp_workgroup() by default and
not lp_netbios_name(), which my change later to match 'net' and 'smbclient'..
- we now have dublicate options e.g. -N -s ...
tridge: can we change this?
metze
(This used to be commit 4733dcbf5f17422a8a4c9f99664270b3aa66c586)
-rw-r--r-- | source4/torture/ldap/basic.c | 2 | ||||
-rw-r--r-- | source4/torture/raw/context.c | 2 | ||||
-rw-r--r-- | source4/torture/rpc/bind.c | 2 | ||||
-rw-r--r-- | source4/torture/rpc/netlogon.c | 8 | ||||
-rw-r--r-- | source4/torture/torture.c | 261 |
5 files changed, 116 insertions, 159 deletions
diff --git a/source4/torture/ldap/basic.c b/source4/torture/ldap/basic.c index 468cacc032..06b703b4ba 100644 --- a/source4/torture/ldap/basic.c +++ b/source4/torture/ldap/basic.c @@ -79,7 +79,7 @@ BOOL torture_ldap_basic(int dummy) BOOL ret = True; const char *host = lp_parm_string(-1, "torture", "host"); const char *username = lp_parm_string(-1, "torture", "username"); - const char *domain = lp_workgroup(); + const char *domain = lp_parm_string(-1, "torture", "userdomain"); const char *password = lp_parm_string(-1, "torture", "password"); const char *userdn = lp_parm_string(-1, "torture", "ldap_userdn"); /*const char *basedn = lp_parm_string(-1, "torture", "ldap_basedn");*/ diff --git a/source4/torture/raw/context.c b/source4/torture/raw/context.c index 26039191f4..7bc75a6627 100644 --- a/source4/torture/raw/context.c +++ b/source4/torture/raw/context.c @@ -77,7 +77,7 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) username = lp_parm_string(-1, "torture", "username"); password = lp_parm_string(-1, "torture", "password"); - domain = lp_workgroup(); + domain = lp_parm_string(-1, "torture", "userdomain"); printf("create a second security context on the same transport\n"); session = smbcli_session_init(cli->transport); diff --git a/source4/torture/rpc/bind.c b/source4/torture/rpc/bind.c index 3402e3b707..6602a9bcfd 100644 --- a/source4/torture/rpc/bind.c +++ b/source4/torture/rpc/bind.c @@ -36,7 +36,7 @@ BOOL torture_multi_bind(int dummy) { struct dcerpc_pipe *p; - const char *domain = lp_workgroup(); + const char *domain = lp_parm_string(-1, "torture", "userdomain"); const char *username = lp_parm_string(-1, "torture", "username"); const char *password = lp_parm_string(-1, "torture", "password"); const char *pipe_uuid = DCERPC_LSARPC_UUID; diff --git a/source4/torture/rpc/netlogon.c b/source4/torture/rpc/netlogon.c index 205ff1e610..1dec1f5109 100644 --- a/source4/torture/rpc/netlogon.c +++ b/source4/torture/rpc/netlogon.c @@ -272,6 +272,7 @@ enum ntlm_break { struct samlogon_state { TALLOC_CTX *mem_ctx; const char *account_name; + const char *account_domain; const char *password; struct dcerpc_pipe *p; struct netr_LogonSamLogon r; @@ -307,7 +308,7 @@ static NTSTATUS check_samlogon(struct samlogon_state *samlogon_state, samlogon_state->r.in.logon_level = levels[i]; samlogon_state->r.in.logon.network = &ninfo; - ninfo.identity_info.domain_name.string = lp_workgroup(); + ninfo.identity_info.domain_name.string = samlogon_state->account_domain; ninfo.identity_info.parameter_control = 0; ninfo.identity_info.logon_id_low = 0; ninfo.identity_info.logon_id_high = 0; @@ -663,7 +664,7 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, enum ZERO_STRUCT(user_session_key); /* TODO - test with various domain cases, and without domain */ - if (!SMBNTLMv2encrypt(samlogon_state->account_name, lp_workgroup(), + if (!SMBNTLMv2encrypt(samlogon_state->account_name, samlogon_state->account_domain, samlogon_state->password, &samlogon_state->chall, &names_blob, &lmv2_response, &ntlmv2_response, @@ -888,6 +889,7 @@ static BOOL test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) samlogon_state.mem_ctx = mem_ctx; samlogon_state.account_name = lp_parm_string(-1, "torture", "username"); + samlogon_state.account_domain = lp_parm_string(-1, "torture", "userdomain"); samlogon_state.password = lp_parm_string(-1, "torture", "password"); samlogon_state.p = p; @@ -1534,7 +1536,7 @@ static BOOL test_InteractiveLogin(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.validation_level = 6; r.in.flags = 0; - pinfo.identity_info.domain_name.string = lp_workgroup(); + pinfo.identity_info.domain_name.string = lp_parm_string(-1, "torture", "userdomain"); pinfo.identity_info.parameter_control = 0; pinfo.identity_info.logon_id_low = 0; pinfo.identity_info.logon_id_high = 0; diff --git a/source4/torture/torture.c b/source4/torture/torture.c index d59218009c..9488c987ec 100644 --- a/source4/torture/torture.c +++ b/source4/torture/torture.c @@ -87,6 +87,7 @@ BOOL torture_open_connection_share(struct smbcli_state **c, int flags = 0; NTSTATUS status; const char *username = lp_parm_string(-1, "torture", "username"); + const char *userdomain = lp_parm_string(-1, "torture", "userdomain"); const char *password = lp_parm_string(-1, "torture", "password"); if (use_kerberos) @@ -95,7 +96,7 @@ BOOL torture_open_connection_share(struct smbcli_state **c, status = smbcli_full_connection(c, lp_netbios_name(), hostname, NULL, sharename, "?????", - username, username[0]?lp_workgroup():"", + username, username[0]?userdomain:"", password, flags, &retry); if (!NT_STATUS_IS_OK(status)) { printf("Failed to open connection - %s\n", nt_errstr(status)); @@ -150,7 +151,7 @@ NTSTATUS torture_rpc_connection(struct dcerpc_pipe **p, } status = dcerpc_pipe_connect(p, binding, pipe_uuid, pipe_version, - lp_workgroup(), + lp_parm_string(-1, "torture", "userdomain"), lp_parm_string(-1, "torture", "username"), lp_parm_string(-1, "torture", "password")); @@ -822,12 +823,13 @@ static BOOL run_tcon_devtype_test(int dummy) const char *host = lp_parm_string(-1, "torture", "host"); const char *share = lp_parm_string(-1, "torture", "share"); const char *username = lp_parm_string(-1, "torture", "username"); + const char *userdomain = lp_parm_string(-1, "torture", "userdomain"); const char *password = lp_parm_string(-1, "torture", "password"); status = smbcli_full_connection(&cli1, lp_netbios_name(), host, NULL, share, "?????", - username, lp_workgroup(), + username, userdomain, password, flags, &retry); if (!NT_STATUS_IS_OK(status)) { @@ -4271,33 +4273,6 @@ static BOOL run_test(const char *name) } -/* - parse a username%password -*/ -static void parse_user(const char *user) -{ - char *username, *password = NULL, *p; - - username = strdup(user); - p = strchr_m(username,'%'); - if (p) { - *p = 0; - password = strdup(p+1); - } - - lp_set_cmdline("torture:username", username); - - if (password) { - lp_set_cmdline("torture:password", password); - } - - if (!lp_parm_string(-1,"torture","password")) { - password = getpass("password:"); - - lp_set_cmdline("torture:password", password); - } -} - static void parse_dns(const char *dns) { char *userdn, *basedn, *secret; @@ -4338,38 +4313,22 @@ static void parse_dns(const char *dns) } -static void usage(void) +static void usage(poptContext pc) { int i; + int perline = 5; - printf("Usage: smbtorture //server/share <options> TEST1 TEST2 ...\n"); - - printf("\t-d debuglevel\n"); - printf("\t-U user%%pass\n"); - printf("\t-k use kerberos\n"); - printf("\t-N numprocs\n"); - printf("\t-n my_netbios_name\n"); - printf("\t-W workgroup\n"); - printf("\t-o num_operations\n"); - printf("\t-e num files(entries)\n"); - printf("\t-O socket_options\n"); - printf("\t-m maximum protocol\n"); - printf("\t-L use oplocks\n"); - printf("\t-c CLIENT.TXT specify client load file for NBENCH\n"); - printf("\t-t timelimit specify NBENCH time limit (seconds)\n"); - printf("\t-C filename specifies file with list of UNCs for connections\n"); - printf("\t-A showall\n"); - printf("\t-p port\n"); - printf("\t-s seed\n"); - printf("\t-f max failures\n"); - printf("\t-X enable dangerous tests\n"); - printf("\n\n"); + poptPrintUsage(pc, stdout, 0); + printf("\n"); printf("tests are:"); for (i=0;torture_ops[i].name;i++) { - printf(" %s", torture_ops[i].name); + if ((i%perline)==0) { + printf("\n"); + } + printf("%s ", torture_ops[i].name); } - printf("\n"); + printf("\n\n"); printf("default test is ALL\n"); @@ -4384,7 +4343,30 @@ static void usage(void) int opt, i; char *p; BOOL correct = True; - char *host, *share, *username; + int argc_new; + char **argv_new; + poptContext pc; + struct poptOption long_options[] = { + POPT_AUTOHELP + {"smb-ports", 'p', POPT_ARG_STRING, NULL, 0, "SMB ports", NULL}, + {"seed", 's', POPT_ARG_STRING, NULL, 0, "seed", NULL}, + {"num-progs", 'N', POPT_ARG_INT, &torture_nprocs, 4, "num progs", NULL}, + {"num-ops", 'o', POPT_ARG_INT, &torture_numops, 100, "num ops", NULL}, + {"entries", 'e', POPT_ARG_INT, &torture_entries, 1000, "entries", NULL}, + {"use-oplocks", 'L', POPT_ARG_NONE, &use_oplocks, True, "use oplocks", NULL}, + {"show-all", 'A', POPT_ARG_NONE, &torture_showall, True, "show all", NULL}, + {"loadfile", 'c', POPT_ARG_STRING, NULL, 0, "loadfile", NULL}, + {"unclist", 'C', POPT_ARG_STRING, NULL, 0, "unclist", NULL}, + {"timelimit", 't', POPT_ARG_STRING, NULL, 0, "timelimit", NULL}, + {"failures", 'f', POPT_ARG_INT, &torture_failures, 1, "failures", NULL}, + {"parse-dns", 'D', POPT_ARG_STRING, NULL, 0, "parse-dns", NULL}, + {"dangerous", 'X', POPT_ARG_NONE, NULL, 0, "dangerous", NULL}, + POPT_COMMON_SAMBA + POPT_COMMON_CONNECTION + POPT_COMMON_CREDENTIALS + POPT_COMMON_VERSION + POPT_TABLEEND + }; setup_logging("smbtorture", DEBUG_STDOUT); @@ -4392,26 +4374,71 @@ static void usage(void) setbuffer(stdout, NULL, 0); #endif + pc = poptGetContext("smbtorture", argc, (const char **) argv, long_options, + POPT_CONTEXT_KEEP_FIRST); + + poptSetOtherOptionHelp(pc, "<binding>|<unc> TEST1 TEST2 ..."); + + while((opt = poptGetNextOpt(pc)) != -1) { + switch (opt) { + case 'c': + lp_set_cmdline("torture:loadfile", poptGetOptArg(pc)); + break; + case 'C': + lp_set_cmdline("torture:unclist", poptGetOptArg(pc)); + break; + case 't': + lp_set_cmdline("torture:timelimit", poptGetOptArg(pc)); + break; + case 'D': + parse_dns(poptGetOptArg(pc)); + break; + + case 'X': + lp_set_cmdline("torture:dangerous", "1"); + break; + + default: + d_printf("Invalid option %s: %s\n", + poptBadOption(pc, 0), poptStrerror(opt)); + usage(pc); + exit(1); + } + } + lp_load(dyn_CONFIGFILE,True,False,False); load_interfaces(); + srandom(time(NULL)); + + argv_new = (const char **)poptGetArgs(pc); - if (argc < 2) { - usage(); + argc_new = argc; + for (i=0; i<argc; i++) { + if (argv_new[i] == NULL) { + argc_new = i; + break; + } } - for(p = argv[1]; *p; p++) - if(*p == '\\') - *p = '/'; + if (argc_new < 3) { + usage(pc); + exit(1); + } + for(p = argv_new[1]; *p; p++) { + if(*p == '\\') + *p = '/'; + } /* see if its a RPC transport specifier */ - if (strncmp(argv[1], "ncacn_", 6) == 0) { - lp_set_cmdline("torture:binding", argv[1]); + if (strncmp(argv_new[1], "ncacn_", 6) == 0) { + lp_set_cmdline("torture:binding", argv_new[1]); } else { char *binding = NULL; + char *host = NULL, *share = NULL; - if (!parse_unc(argv[1], &host, &share)) { - usage(); + if (!parse_unc(argv_new[1], &host, &share)) { + usage(pc); } lp_set_cmdline("torture:host", host); @@ -4420,102 +4447,30 @@ static void usage(void) lp_set_cmdline("torture:binding", binding); } - if (getenv("LOGNAME")) { - username = strdup(getenv("LOGNAME")); + if (!lp_parm_string(-1,"torture","username")) { + lp_set_cmdline("torture:username", cmdline_get_username()); } - lp_set_cmdline("torture:username", username); - - - argc--; - argv++; - - srandom(time(NULL)); - - while ((opt = getopt(argc, argv, "p:hW:D:U:n:N:O:o:e:m:Ld:Ac:ks:f:s:t:C:X")) != EOF) { - switch (opt) { - case 'p': - lp_set_cmdline("smb ports", optarg); - break; - case 'W': - lp_set_cmdline("workgroup", optarg); - break; - case 'm': - lp_set_cmdline("protocol", optarg); - break; - case 'n': - lp_set_cmdline("netbios name", optarg); - break; - case 'd': - lp_set_cmdline("debug level", optarg); - setup_logging(NULL, DEBUG_STDOUT); - break; - case 'O': - lp_set_cmdline("socket options", optarg); - break; - case 's': - srandom(atoi(optarg)); - break; - case 'N': - torture_nprocs = atoi(optarg); - break; - case 'o': - torture_numops = atoi(optarg); - break; - case 'e': - torture_entries = atoi(optarg); - break; - case 'L': - use_oplocks = True; - break; - case 'A': - torture_showall = True; - break; - case 'c': - lp_set_cmdline("torture:loadfile", optarg); - break; - case 'C': - lp_set_cmdline("torture:unclist", optarg); - break; - case 't': - lp_set_cmdline("torture:timelimit", optarg); - break; - case 'k': -#ifdef HAVE_KRB5 - use_kerberos = True; -#else - d_printf("No kerberos support compiled in\n"); - exit(1); -#endif - break; - case 'U': - parse_user(optarg); - break; - case 'D': - parse_dns(optarg); - break; - case 'f': - torture_failures = atoi(optarg); - break; - - case 'X': - lp_set_cmdline("torture:dangerous", "1"); - break; - - default: - printf("Unknown option %c (%d)\n", (char)opt, opt); - usage(); + if (!lp_parm_string(-1,"torture","userdomain")) { + /* + * backward compatibility + * maybe we should remove this to make this consistent + * for all cmdline tools + * --metze + */ + if (strequal(lp_netbios_name(),cmdline_get_userdomain())) { + cmdline_set_userdomain(lp_workgroup()); } + lp_set_cmdline("torture:userdomain", cmdline_get_userdomain()); } - if (!lp_parm_string(-1,"torture","password")) { - lp_set_cmdline("torture:password", ""); + lp_set_cmdline("torture:password", cmdline_get_userpassword()); } - if (argc == optind) { + if (argc_new == 0) { printf("You must specify a test to run, or 'ALL'\n"); } else { - for (i=optind;i<argc;i++) { - if (!run_test(argv[i])) { + for (i=2;i<argc_new;i++) { + if (!run_test(argv_new[i])) { correct = False; } } |