From ffb63e4f8ec2b7390cbb00bca74a9bedb8399a91 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 19 Jun 2001 02:02:19 +0000 Subject: moved all our torture code to a separate directory (This used to be commit dd12c47645e2d0e832bc555492a6a8725a4495ee) --- source3/utils/locktest.c | 567 ---------------------------------------- source3/utils/locktest2.c | 626 --------------------------------------------- source3/utils/masktest.c | 521 ------------------------------------- source3/utils/msgtest.c | 96 ------- source3/utils/nbio.c | 240 ----------------- source3/utils/rpctorture.c | 559 ---------------------------------------- 6 files changed, 2609 deletions(-) delete mode 100644 source3/utils/locktest.c delete mode 100644 source3/utils/locktest2.c delete mode 100644 source3/utils/masktest.c delete mode 100644 source3/utils/msgtest.c delete mode 100644 source3/utils/nbio.c delete mode 100644 source3/utils/rpctorture.c (limited to 'source3/utils') diff --git a/source3/utils/locktest.c b/source3/utils/locktest.c deleted file mode 100644 index 80dbba1e37..0000000000 --- a/source3/utils/locktest.c +++ /dev/null @@ -1,567 +0,0 @@ -/* - Unix SMB/Netbios implementation. - Version 2.0 - randomised byte range lock tester - Copyright (C) Andrew Tridgell 1999 - - 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. -*/ - -#define NO_SYSLOG - -#include "includes.h" - -static fstring password; -static fstring username; -static int got_pass; -static int numops = 1000; -static BOOL showall; -static BOOL analyze; -static BOOL hide_unlock_fails; -static BOOL use_oplocks; - -#define FILENAME "\\locktest.dat" -#define LOCKRANGE 1000 -#define LOCKBASE 0; - -/* -#define LOCKBASE (0x40000000 - 50) -*/ - -#define READ_PCT 50 -#define LOCK_PCT 35 -#define UNLOCK_PCT 55 -#define RANGE_MULTIPLE 1 -#define NSERVERS 2 -#define NCONNECTIONS 2 -#define NFILES 2 -#define LOCK_TIMEOUT 0 - -#define NASTY_POSIX_LOCK_HACK 0 - - -struct record { - char r1, r2; - char conn, f; - SMB_BIG_UINT start, len; - char needed; -}; - -static struct record preset[] = { -#if 0 -{36, 5, 0, 0, 0, 8, 1}, -{ 2, 6, 0, 1, 0, 1, 1}, -{53, 92, 0, 0, 0, 0, 1}, -{99, 11, 0, 0, 7, 1, 1}, -#endif -}; - -static struct record *recorded; - -static void print_brl(SMB_DEV_T dev, SMB_INO_T ino, int pid, - enum brl_type lock_type, - br_off start, br_off size) -{ -#if NASTY_POSIX_LOCK_HACK - { - pstring cmd; - static SMB_INO_T lastino; - - if (lastino != ino) { - slprintf(cmd, sizeof(cmd), - "egrep POSIX.*%u /proc/locks", (int)ino); - system(cmd); - } - lastino = ino; - } -#endif - - printf("%6d %05x:%05x %s %.0f:%.0f(%.0f)\n", - (int)pid, (int)dev, (int)ino, - lock_type==READ_LOCK?"R":"W", - (double)start, (double)start+size-1,(double)size); - -} - - -static void show_locks(void) -{ - brl_forall(print_brl); - /* system("cat /proc/locks"); */ -} - - -/***************************************************** -return a connection to a server -*******************************************************/ -struct cli_state *connect_one(char *share) -{ - struct cli_state *c; - struct nmb_name called, calling; - char *server_n; - fstring server; - struct in_addr ip; - extern struct in_addr ipzero; - fstring myname; - static int count; - - fstrcpy(server,share+2); - share = strchr(server,'\\'); - if (!share) return NULL; - *share = 0; - share++; - - server_n = server; - - ip = ipzero; - - slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), count++); - - make_nmb_name(&calling, myname, 0x0); - make_nmb_name(&called , server, 0x20); - - again: - ip = ipzero; - - /* have to open a new connection */ - if (!(c=cli_initialise(NULL)) || (cli_set_port(c, 139) == 0) || - !cli_connect(c, server_n, &ip)) { - DEBUG(0,("Connection to %s failed\n", server_n)); - return NULL; - } - - if (!cli_session_request(c, &calling, &called)) { - DEBUG(0,("session request to %s failed\n", called.name)); - cli_shutdown(c); - if (strcmp(called.name, "*SMBSERVER")) { - make_nmb_name(&called , "*SMBSERVER", 0x20); - goto again; - } - return NULL; - } - - DEBUG(4,(" session request ok\n")); - - if (!cli_negprot(c)) { - DEBUG(0,("protocol negotiation failed\n")); - cli_shutdown(c); - return NULL; - } - - if (!got_pass) { - char *pass = getpass("Password: "); - if (pass) { - pstrcpy(password, pass); - } - } - - if (!cli_session_setup(c, username, - password, strlen(password), - password, strlen(password), - lp_workgroup())) { - DEBUG(0,("session setup failed: %s\n", cli_errstr(c))); - return NULL; - } - - /* - * These next two lines are needed to emulate - * old client behaviour for people who have - * scripts based on client output. - * QUESTION ? Do we want to have a 'client compatibility - * mode to turn these on/off ? JRA. - */ - - if (*c->server_domain || *c->server_os || *c->server_type) - DEBUG(1,("Domain=[%s] OS=[%s] Server=[%s]\n", - c->server_domain,c->server_os,c->server_type)); - - DEBUG(4,(" session setup ok\n")); - - if (!cli_send_tconX(c, share, "?????", - password, strlen(password)+1)) { - DEBUG(0,("tree connect failed: %s\n", cli_errstr(c))); - cli_shutdown(c); - return NULL; - } - - DEBUG(4,(" tconx ok\n")); - - c->use_oplocks = use_oplocks; - - return c; -} - - -static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NSERVERS][NCONNECTIONS][NFILES], - char *share[NSERVERS]) -{ - int server, conn, f; - - for (server=0;serverconn; - unsigned f = rec->f; - SMB_BIG_UINT start = rec->start; - SMB_BIG_UINT len = rec->len; - unsigned r1 = rec->r1; - unsigned r2 = rec->r2; - unsigned op; - int server; - BOOL ret[NSERVERS]; - - if (r1 < READ_PCT) { - op = READ_LOCK; - } else { - op = WRITE_LOCK; - } - - if (r2 < LOCK_PCT) { - /* set a lock */ - for (server=0;server %u:%u\n", - conn, f, - (double)start, (double)start+len-1, (double)len, - op==READ_LOCK?"READ_LOCK":"WRITE_LOCK", - ret[0], ret[1]); - } - if (showall || ret[0] != ret[1]) show_locks(); - if (ret[0] != ret[1]) return False; - } else if (r2 < LOCK_PCT+UNLOCK_PCT) { - /* unset a lock */ - for (server=0;server %u:%u\n", - conn, f, - (double)start, (double)start+len-1, (double)len, - ret[0], ret[1]); - } - if (showall || ret[0] != ret[1]) show_locks(); - if (!hide_unlock_fails && ret[0] != ret[1]) return False; - } else { - /* reopen the file */ - for (server=0;serverserver_domain || *c->server_os || *c->server_type) - DEBUG(1,("Domain=[%s] OS=[%s] Server=[%s]\n", - c->server_domain,c->server_os,c->server_type)); - - DEBUG(4,(" session setup ok\n")); - - if (!cli_send_tconX(c, share, "?????", - password, strlen(password)+1)) { - DEBUG(0,("tree connect failed: %s\n", cli_errstr(c))); - cli_shutdown(c); - return NULL; - } - - DEBUG(4,(" tconx ok\n")); - - c->use_oplocks = use_oplocks; - - return c; -} - - -static void reconnect(struct cli_state *cli[NSERVERS][NCONNECTIONS], - char *nfs[NSERVERS], - int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES], - char *share1, char *share2) -{ - int server, conn, f, fstype; - char *share[2]; - share[0] = share1; - share[1] = share2; - - fstype = FSTYPE_SMB; - - for (server=0;serverconn; - unsigned f = rec->f; - unsigned fstype = rec->fstype; - unsigned start = rec->start; - unsigned len = rec->len; - unsigned r1 = rec->r1; - unsigned r2 = rec->r2; - unsigned op; - int server; - BOOL ret[NSERVERS]; - - if (r1 < READ_PCT) { - op = READ_LOCK; - } else { - op = WRITE_LOCK; - } - - if (r2 < LOCK_PCT) { - /* set a lock */ - for (server=0;server %u:%u\n", - conn, fstype, f, - start, start+len-1, len, - op==READ_LOCK?"READ_LOCK":"WRITE_LOCK", - ret[0], ret[1]); - } - if (showall) brl_forall(print_brl); - if (ret[0] != ret[1]) return False; - } else if (r2 < LOCK_PCT+UNLOCK_PCT) { - /* unset a lock */ - for (server=0;server %u:%u\n", - conn, fstype, f, - start, start+len-1, len, - ret[0], ret[1]); - } - if (showall) brl_forall(print_brl); - if (!hide_unlock_fails && ret[0] != ret[1]) return False; - } else { - /* reopen the file */ - for (server=0;server': - if (n[0] == '.') { - if (! n[1] && ms_fnmatch_lanman_core(p, n+1) == 0) goto match; - if (ms_fnmatch_lanman_core(p, n) == 0) goto match; - goto nomatch; - } - if (! *n) goto next; - n++; - break; - - case '*': - if (! *p) goto match; - for (; *n; n++) { - if (ms_fnmatch_lanman_core(p, n) == 0) goto match; - } - break; - - case '<': - for (; *n; n++) { - if (ms_fnmatch_lanman_core(p, n) == 0) goto match; - if (*n == '.' && !strchr(n+1,'.')) { - n++; - break; - } - } - break; - - case '"': - if (*n == 0 && ms_fnmatch_lanman_core(p, n) == 0) goto match; - if (*n != '.') goto nomatch; - n++; - break; - - default: - if (c != *n) goto nomatch; - n++; - } - } - - if (! *n) goto match; - - nomatch: - if (verbose) printf("NOMATCH pattern=[%s] string=[%s]\n", pattern, string); - return -1; - -next: - if (ms_fnmatch_lanman_core(p, n) == 0) goto match; - goto nomatch; - - match: - if (verbose) printf("MATCH pattern=[%s] string=[%s]\n", pattern, string); - return 0; -} - -int ms_fnmatch_lanman(char *pattern, char *string) -{ - if (!strpbrk(pattern, "?*<>\"")) { - if (strcmp(string,"..") == 0) string = "."; - return strcmp(pattern, string); - } - - if (strcmp(string,"..") == 0 || strcmp(string,".") == 0) { - return ms_fnmatch_lanman_core(pattern, "..") && - ms_fnmatch_lanman_core(pattern, "."); - } - - return ms_fnmatch_lanman_core(pattern, string); -} - -static BOOL reg_match_one(char *pattern, char *file) -{ - /* oh what a weird world this is */ - if (old_list && strcmp(pattern, "*.*") == 0) return True; - - if (strcmp(pattern,".") == 0) return False; - - if (max_protocol <= PROTOCOL_LANMAN2) { - return ms_fnmatch_lanman(pattern, file)==0; - } - - if (strcmp(file,"..") == 0) file = "."; - - return ms_fnmatch(pattern, file)==0; -} - -static char *reg_test(char *pattern, char *long_name, char *short_name) -{ - static fstring ret; - fstrcpy(ret, "---"); - - pattern = 1+strrchr(pattern,'\\'); - - if (reg_match_one(pattern, ".")) ret[0] = '+'; - if (reg_match_one(pattern, "..")) ret[1] = '+'; - if (reg_match_one(pattern, long_name) || - (*short_name && reg_match_one(pattern, short_name))) ret[2] = '+'; - return ret; -} - - -/***************************************************** -return a connection to a server -*******************************************************/ -struct cli_state *connect_one(char *share) -{ - struct cli_state *c; - struct nmb_name called, calling; - char *server_n; - char *server; - struct in_addr ip; - extern struct in_addr ipzero; - - server = share+2; - share = strchr(server,'\\'); - if (!share) return NULL; - *share = 0; - share++; - - server_n = server; - - ip = ipzero; - - make_nmb_name(&calling, "masktest", 0x0); - make_nmb_name(&called , server, 0x20); - - again: - ip = ipzero; - - /* have to open a new connection */ - if (!(c=cli_initialise(NULL)) || (cli_set_port(c, 139) == 0) || - !cli_connect(c, server_n, &ip)) { - DEBUG(0,("Connection to %s failed\n", server_n)); - return NULL; - } - - c->protocol = max_protocol; - - if (!cli_session_request(c, &calling, &called)) { - DEBUG(0,("session request to %s failed\n", called.name)); - cli_shutdown(c); - if (strcmp(called.name, "*SMBSERVER")) { - make_nmb_name(&called , "*SMBSERVER", 0x20); - goto again; - } - return NULL; - } - - DEBUG(4,(" session request ok\n")); - - if (!cli_negprot(c)) { - DEBUG(0,("protocol negotiation failed\n")); - cli_shutdown(c); - return NULL; - } - - if (!got_pass) { - char *pass = getpass("Password: "); - if (pass) { - pstrcpy(password, pass); - } - } - - if (!cli_session_setup(c, username, - password, strlen(password), - password, strlen(password), - lp_workgroup())) { - DEBUG(0,("session setup failed: %s\n", cli_errstr(c))); - return NULL; - } - - /* - * These next two lines are needed to emulate - * old client behaviour for people who have - * scripts based on client output. - * QUESTION ? Do we want to have a 'client compatibility - * mode to turn these on/off ? JRA. - */ - - if (*c->server_domain || *c->server_os || *c->server_type) - DEBUG(1,("Domain=[%s] OS=[%s] Server=[%s]\n", - c->server_domain,c->server_os,c->server_type)); - - DEBUG(4,(" session setup ok\n")); - - if (!cli_send_tconX(c, share, "?????", - password, strlen(password)+1)) { - DEBUG(0,("tree connect failed: %s\n", cli_errstr(c))); - cli_shutdown(c); - return NULL; - } - - DEBUG(4,(" tconx ok\n")); - - return c; -} - -static char *resultp; -static file_info *finfo; - -void listfn(file_info *f, const char *s, void *state) -{ - if (strcmp(f->name,".") == 0) { - resultp[0] = '+'; - } else if (strcmp(f->name,"..") == 0) { - resultp[1] = '+'; - } else { - resultp[2] = '+'; - } - finfo = f; -} - -static void get_real_name(struct cli_state *cli, - pstring long_name, fstring short_name) -{ - /* nasty hack to force level 260 listings - tridge */ - cli->capabilities |= CAP_NT_SMBS; - if (max_protocol <= PROTOCOL_LANMAN1) { - cli_list_new(cli, "\\masktest\\*.*", aHIDDEN | aDIR, listfn, NULL); - } else { - cli_list_new(cli, "\\masktest\\*", aHIDDEN | aDIR, listfn, NULL); - } - if (finfo) { - fstrcpy(short_name, finfo->short_name); - strlower(short_name); - pstrcpy(long_name, finfo->name); - strlower(long_name); - } - - if (*short_name == 0) { - fstrcpy(short_name, long_name); - } - -#if 0 - if (!strchr(short_name,'.')) { - fstrcat(short_name,"."); - } -#endif -} - -static void testpair(struct cli_state *cli, char *mask, char *file) -{ - int fnum; - fstring res1; - char *res2; - static int count; - fstring short_name; - pstring long_name; - - count++; - - fstrcpy(res1, "---"); - - fnum = cli_open(cli, file, O_CREAT|O_TRUNC|O_RDWR, 0); - if (fnum == -1) { - DEBUG(0,("Can't create %s\n", file)); - return; - } - cli_close(cli, fnum); - - resultp = res1; - fstrcpy(short_name, ""); - finfo = NULL; - get_real_name(cli, long_name, short_name); - finfo = NULL; - fstrcpy(res1, "---"); - cli_list(cli, mask, aHIDDEN | aDIR, listfn, NULL); - - res2 = reg_test(mask, long_name, short_name); - - if (showall || strcmp(res1, res2)) { - DEBUG(0,("%s %s %d mask=[%s] file=[%s] rfile=[%s/%s]\n", - res1, res2, count, mask, file, long_name, short_name)); - if (die_on_error) exit(1); - } - - cli_unlink(cli, file); - - if (count % 100 == 0) DEBUG(0,("%d\n", count)); -} - -static void test_mask(int argc, char *argv[], - struct cli_state *cli) -{ - pstring mask, file; - int l1, l2, i, l; - int mc_len = strlen(maskchars); - int fc_len = strlen(filechars); - - cli_mkdir(cli, "\\masktest"); - - cli_unlink(cli, "\\masktest\\*"); - - if (argc >= 2) { - while (argc >= 2) { - pstrcpy(mask,"\\masktest\\"); - pstrcpy(file,"\\masktest\\"); - pstrcat(mask, argv[0]); - pstrcat(file, argv[1]); - testpair(cli, mask, file); - argv += 2; - argc -= 2; - } - goto finished; - } - - while (1) { - l1 = 1 + random() % 20; - l2 = 1 + random() % 20; - pstrcpy(mask,"\\masktest\\"); - pstrcpy(file,"\\masktest\\"); - l = strlen(mask); - for (i=0;i st_size) { -#if NBDEBUG - printf("(%d) needs expanding %s to %d from %d\n", - line_count, fname, size, (int)st_size); -#endif - } else if (size < st_size) { -#if NBDEBUG - printf("(%d) needs truncating %s to %d from %d\n", - line_count, fname, size, (int)st_size); -#endif - } - for (i=0;icapabilities |= CAP_NT_SMBS; -} - -/**************************************************************************** -make smb client connection -****************************************************************************/ -static BOOL rpcclient_connect(struct client_info *info) -{ - struct nmb_name calling; - struct nmb_name called; - - make_nmb_name(&called , dns_to_netbios_name(info->dest_host ), info->name_type); - make_nmb_name(&calling, dns_to_netbios_name(info->myhostname), 0x0); - - if (!cli_establish_connection(smb_cli, - info->dest_host, &info->dest_ip, - &calling, &called, - info->share, info->svc_type, - False, True)) - { - DEBUG(0,("rpcclient_connect: connection failed\n")); - cli_shutdown(smb_cli); - return False; - } - - return True; -} - -/**************************************************************************** -stop the smb connection(s?) -****************************************************************************/ -static void rpcclient_stop(void) -{ - cli_shutdown(smb_cli); -} - -/**************************************************************************** - log in as an nt user, log out again. -****************************************************************************/ -void run_enums_test(int num_ops, struct client_info *cli_info, struct cli_state *cli) -{ - pstring cmd; - int i; - - /* establish connections. nothing to stop these being re-established. */ - rpcclient_connect(cli_info); - - DEBUG(5,("rpcclient_connect: cli->fd:%d\n", cli->fd)); - if (cli->fd <= 0) - { - fprintf(out_hnd, "warning: connection could not be established to %s<%02x>\n", - cli_info->dest_host, cli_info->name_type); - return; - } - - for (i = 0; i < num_ops; i++) - { - set_first_token(""); - cmd_srv_enum_sess(cli_info); - set_first_token(""); - cmd_srv_enum_shares(cli_info); - set_first_token(""); - cmd_srv_enum_files(cli_info); - - if (password[0] != 0) - { - slprintf(cmd, sizeof(cmd)-1, "1"); - set_first_token(cmd); - } - else - { - set_first_token(""); - } - cmd_srv_enum_conn(cli_info); - } - - rpcclient_stop(); - -} - -/**************************************************************************** - log in as an nt user, log out again. -****************************************************************************/ -void run_ntlogin_test(int num_ops, struct client_info *cli_info, struct cli_state *cli) -{ - pstring cmd; - int i; - - /* establish connections. nothing to stop these being re-established. */ - rpcclient_connect(cli_info); - - DEBUG(5,("rpcclient_connect: cli->fd:%d\n", cli->fd)); - if (cli->fd <= 0) - { - fprintf(out_hnd, "warning: connection could not be established to %s<%02x>\n", - cli_info->dest_host, cli_info->name_type); - return; - } - - for (i = 0; i < num_ops; i++) - { - slprintf(cmd, sizeof(cmd)-1, "%s %s", cli->user_name, password); - set_first_token(cmd); - - cmd_netlogon_login_test(cli_info); - } - - rpcclient_stop(); - -} - -/**************************************************************************** - runs n simultaneous functions. -****************************************************************************/ -static void create_procs(int nprocs, int numops, - struct client_info *cli_info, struct cli_state *cli, - void (*fn)(int, struct client_info *, struct cli_state *)) -{ - int i, status; - - for (i=0;i [-d debuglevel] [-l log] ", - pname); - - fprintf(out_hnd, "\nVersion %s\n",VERSION); - fprintf(out_hnd, "\t-d debuglevel set the debuglevel\n"); - fprintf(out_hnd, "\t-l log basename. Basename for log/debug files\n"); - fprintf(out_hnd, "\t-n netbios name. Use this name as my netbios name\n"); - fprintf(out_hnd, "\t-m max protocol set the max protocol level\n"); - fprintf(out_hnd, "\t-I dest IP use this IP to connect to\n"); - fprintf(out_hnd, "\t-E write messages to stderr instead of stdout\n"); - fprintf(out_hnd, "\t-U username set the network username\n"); - fprintf(out_hnd, "\t-W workgroup set the workgroup name\n"); - fprintf(out_hnd, "\t-t terminal code terminal i/o code {sjis|euc|jis7|jis8|junet|hex}\n"); - fprintf(out_hnd, "\n"); -} - -enum client_action -{ - CLIENT_NONE, - CLIENT_IPC, - CLIENT_SVC -}; - -/**************************************************************************** - main program -****************************************************************************/ - int main(int argc,char *argv[]) -{ - char *pname = argv[0]; - int opt; - extern FILE *dbf; - extern char *optarg; - extern int optind; - static pstring servicesf = CONFIGFILE; - pstring term_code; - BOOL got_pass = False; - char *cmd_str=""; - mode_t myumask = 0755; - enum client_action cli_action = CLIENT_NONE; - int nprocs = 1; - int numops = 100; - - struct client_info cli_info; - - out_hnd = stdout; - - rpcclient_init(); - -#ifdef KANJI - pstrcpy(term_code, KANJI); -#else /* KANJI */ - *term_code = 0; -#endif /* KANJI */ - - if (!lp_load(servicesf,True, False, False)) - { - fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf); - } - - codepage_initialise(lp_client_code_page()); - - DEBUGLEVEL = 0; - - cli_info.put_total_size = 0; - cli_info.put_total_time_ms = 0; - cli_info.get_total_size = 0; - cli_info.get_total_time_ms = 0; - - cli_info.dir_total = 0; - cli_info.newer_than = 0; - cli_info.archive_level = 0; - cli_info.print_mode = 1; - - cli_info.translation = False; - cli_info.recurse_dir = False; - cli_info.lowercase = False; - cli_info.prompt = True; - cli_info.abort_mget = True; - - cli_info.dest_ip.s_addr = 0; - cli_info.name_type = 0x20; - - pstrcpy(cli_info.cur_dir , "\\"); - pstrcpy(cli_info.file_sel, ""); - pstrcpy(cli_info.base_dir, ""); - pstrcpy(smb_cli->domain, ""); - pstrcpy(smb_cli->user_name, ""); - pstrcpy(cli_info.myhostname, ""); - pstrcpy(cli_info.dest_host, ""); - - pstrcpy(cli_info.svc_type, "A:"); - pstrcpy(cli_info.share, ""); - pstrcpy(cli_info.service, ""); - - ZERO_STRUCT(cli_info.dom.level3_sid); - pstrcpy(cli_info.dom.level3_dom, ""); - ZERO_STRUCT(cli_info.dom.level5_sid); - pstrcpy(cli_info.dom.level5_dom, ""); - - smb_cli->nt_pipe_fnum = 0xffff; - - setup_logging(pname, True); - - TimeInit(); - charset_initialise(); - - myumask = umask(0); - umask(myumask); - - if (!get_myname(global_myname)) - { - fprintf(stderr, "Failed to get my hostname.\n"); - } - - password[0] = 0; - - if (argc < 2) - { - usage(pname); - exit(1); - } - - if (*argv[1] != '-') - { - pstrcpy(cli_info.service, argv[1]); - /* Convert any '/' characters in the service name to '\' characters */ - string_replace( cli_info.service, '/','\\'); - argc--; - argv++; - - DEBUG(1,("service: %s\n", cli_info.service)); - - if (count_chars(cli_info.service,'\\') < 3) - { - usage(pname); - printf("\n%s: Not enough '\\' characters in service\n", cli_info.service); - exit(1); - } - - /* - if (count_chars(cli_info.service,'\\') > 3) - { - usage(pname); - printf("\n%s: Too many '\\' characters in service\n", cli_info.service); - exit(1); - } - */ - - if (argc > 1 && (*argv[1] != '-')) - { - got_pass = True; - pstrcpy(password,argv[1]); - memset(argv[1],'X',strlen(argv[1])); - argc--; - argv++; - } - - cli_action = CLIENT_SVC; - } - - while ((opt = getopt(argc, argv,"s:O:M:S:i:N:o:n:d:l:hI:EB:U:L:t:m:W:T:D:c:")) != EOF) - { - switch (opt) - { - case 'm': - { - /* FIXME ... max_protocol seems to be funny here */ - - int max_protocol = 0; - max_protocol = interpret_protocol(optarg,max_protocol); - fprintf(stderr, "max protocol not currently supported\n"); - break; - } - - case 'O': - { - pstrcpy(user_socket_options,optarg); - break; - } - - case 'S': - { - pstrcpy(cli_info.dest_host,optarg); - strupper(cli_info.dest_host); - cli_action = CLIENT_IPC; - break; - } - - case 'i': - { - pstrcpy(scope, optarg); - break; - } - - case 'U': - { - char *lp; - pstrcpy(smb_cli->user_name,optarg); - if ((lp=strchr(smb_cli->user_name,'%'))) - { - *lp = 0; - pstrcpy(password,lp+1); - got_pass = True; - memset(strchr(optarg,'%')+1,'X',strlen(password)); - } - break; - } - - case 'W': - { - pstrcpy(smb_cli->domain,optarg); - break; - } - - case 'E': - { - dbf = stderr; - break; - } - - case 'I': - { - cli_info.dest_ip = *interpret_addr2(optarg); - if (zero_ip(cli_info.dest_ip)) - { - exit(1); - } - break; - } - - case 'N': - { - nprocs = atoi(optarg); - break; - } - - case 'o': - { - numops = atoi(optarg); - break; - } - - case 'n': - { - fstrcpy(global_myname, optarg); - break; - } - - case 'd': - { - if (*optarg == 'A') - DEBUGLEVEL = 10000; - else - DEBUGLEVEL = atoi(optarg); - break; - } - - case 'l': - { - slprintf(debugf, sizeof(debugf)-1, - "%s.client",optarg); - break; - } - - case 'c': - { - cmd_str = optarg; - got_pass = True; - break; - } - - case 'h': - { - usage(pname); - exit(0); - break; - } - - case 's': - { - pstrcpy(servicesf, optarg); - break; - } - - case 't': - { - pstrcpy(term_code, optarg); - break; - } - - default: - { - usage(pname); - exit(1); - break; - } - } - } - - if (cli_action == CLIENT_NONE) - { - usage(pname); - exit(1); - } - - strupper(global_myname); - fstrcpy(cli_info.myhostname, global_myname); - - DEBUG(3,("%s client started (version %s)\n",timestring(False),VERSION)); - - if (*smb_cli->domain == 0) - { - pstrcpy(smb_cli->domain,lp_workgroup()); - } - strupper(smb_cli->domain); - - load_interfaces(); - - if (cli_action == CLIENT_IPC) - { - pstrcpy(cli_info.share, "IPC$"); - pstrcpy(cli_info.svc_type, "IPC"); - } - - fstrcpy(cli_info.mach_acct, cli_info.myhostname); - strupper(cli_info.mach_acct); - fstrcat(cli_info.mach_acct, "$"); - - /* set the password cache info */ - if (got_pass) - { - if (password[0] == 0) - { - pwd_set_nullpwd(&(smb_cli->pwd)); - } - else - { - pwd_make_lm_nt_16(&(smb_cli->pwd), password); /* generate 16 byte hashes */ - } - } - else - { - char *pwd = getpass("Enter Password:"); - safe_strcpy(password, pwd, sizeof(password)); - pwd_make_lm_nt_16(&(smb_cli->pwd), password); /* generate 16 byte hashes */ - } - - create_procs(nprocs, numops, &cli_info, smb_cli, run_enums_test); - - if (password[0] != 0) - { - create_procs(nprocs, numops, &cli_info, smb_cli, run_ntlogin_test); - } - - fflush(out_hnd); - - return(0); -} -- cgit