diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/Makefile.in | 6 | ||||
-rw-r--r-- | source3/lib/popt_common.c | 272 | ||||
-rw-r--r-- | source3/nmbd/nmbd.c | 15 | ||||
-rw-r--r-- | source3/smbd/server.c | 8 | ||||
-rw-r--r-- | source3/utils/pdbedit.c | 9 | ||||
-rw-r--r-- | source3/utils/smbtree.c | 191 | ||||
-rw-r--r-- | source3/utils/status.c | 6 | ||||
-rw-r--r-- | source3/web/swat.c | 5 |
8 files changed, 286 insertions, 226 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index ac27232590..ce37ccff91 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -397,7 +397,7 @@ SMBCONTROL_OBJ = utils/smbcontrol.o $(LOCKING_OBJ) $(PARAM_OBJ) \ SMBTREE_OBJ = utils/smbtree.o $(LOCKING_OBJ) $(PARAM_OBJ) \ $(UBIQX_OBJ) $(PROFILE_OBJ) $(LIB_OBJ) $(LIBSMB_OBJ) \ - $(KRBCLIENT_OBJ) + $(KRBCLIENT_OBJ) $(POPT_LIB_OBJ) TESTPARM_OBJ = utils/testparm.o \ $(PARAM_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) $(POPT_LIB_OBJ) @@ -779,9 +779,9 @@ bin/smbcontrol@EXEEXT@: $(SMBCONTROL_OBJ) bin/.dummy @echo Linking $@ @$(CC) -DUSING_SMBCONTROL $(FLAGS) -o $@ $(SMBCONTROL_OBJ) $(LDFLAGS) $(LIBS) -bin/smbtree@EXEEXT@: $(SMBTREE_OBJ) bin/.dummy +bin/smbtree@EXEEXT@: $(SMBTREE_OBJ) @BUILD_POPT@ bin/.dummy @echo Linking $@ - @$(CC) $(FLAGS) -o $@ $(SMBTREE_OBJ) $(LDFLAGS) $(LIBS) + @$(CC) $(FLAGS) -o $@ $(SMBTREE_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@ bin/smbpasswd@EXEEXT@: $(SMBPASSWD_OBJ) bin/.dummy @echo Linking $@ diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c index 77c44f127a..6920ef4d5f 100644 --- a/source3/lib/popt_common.c +++ b/source3/lib/popt_common.c @@ -3,7 +3,7 @@ Common popt routines Copyright (C) Tim Potter 2001,2002 - Copyright (C) Jelmer Vernooij 2002 + Copyright (C) Jelmer Vernooij 2002,2003 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 @@ -23,17 +23,21 @@ #include "includes.h" /* Handle command line options: - * d,--debuglevel - * s,--configfile - * O,--socket-options - * V,--version - * l,--log-base - * n,--netbios-name + * -d,--debuglevel + * -s,--configfile + * -O,--socket-options + * -V,--version + * -l,--log-base + * -n,--netbios-name + * -W,--workgroup + * -i,--scope */ extern pstring user_socket_options; extern BOOL AllowDebugChange; +struct user_auth_info cmdline_auth_info; + static void popt_common_callback(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, @@ -93,42 +97,246 @@ static void popt_common_callback(poptContext con, lp_set_logfile(logfile); } break; + + case 'i': + if (arg) { + set_global_scope(arg); + } + break; + + case 'W': + if (arg) { + set_global_myworkgroup(arg); + } + break; } } -struct poptOption popt_common_debug[] = { +struct poptOption popt_common_connection[] = { { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, - { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", - "DEBUGLEVEL" }, - { 0 } + { "socket-options", 'O', POPT_ARG_STRING, NULL, 'O', "socket options to use", + "SOCKETOPTIONS" }, + { "netbiosname", 'n', POPT_ARG_STRING, NULL, 'n', "Primary netbios name", "NETBIOSNAME" }, + { "workgroup", 'W', POPT_ARG_STRING, NULL, 'W', "Set the workgroup name", "WORKGROUP" }, + { "scope", 'i', POPT_ARG_STRING, NULL, 'i', "Use this Netbios scope", "SCOPE" }, + POPT_TABLEEND }; -struct poptOption popt_common_configfile[] = { - { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, - { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file" }, - { 0 } -}; - -struct poptOption popt_common_socket_options[] = { - { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, - {"socket-options", 'O', POPT_ARG_STRING, NULL, 'O', "socket options to use" }, - { 0 } +struct poptOption popt_common_samba[] = { + { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_callback }, + { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" }, + { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file", "CONFIGFILE" }, + { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files", "LOGFILEBASE" }, + { "version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" }, + POPT_TABLEEND }; struct poptOption popt_common_version[] = { { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, - {"version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" }, - { 0 } + { "version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" }, + POPT_TABLEEND }; -struct poptOption popt_common_netbios_name[] = { - { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, - {"netbiosname", 'n', POPT_ARG_STRING, NULL, 'n', "Primary netbios name"}, - { 0 } -}; -struct poptOption popt_common_log_base[] = { - { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_callback }, - { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files"}, - { 0 } + +/**************************************************************************** + * get a password from a a file or file descriptor + * exit on failure + * ****************************************************************************/ +static void get_password_file(struct user_auth_info *a) +{ + int fd = -1; + char *p; + BOOL close_it = False; + pstring spec; + char pass[128]; + + if ((p = getenv("PASSWD_FD")) != NULL) { + pstrcpy(spec, "descriptor "); + pstrcat(spec, p); + sscanf(p, "%d", &fd); + close_it = False; + } else if ((p = getenv("PASSWD_FILE")) != NULL) { + fd = sys_open(p, O_RDONLY, 0); + pstrcpy(spec, p); + if (fd < 0) { + fprintf(stderr, "Error opening PASSWD_FILE %s: %s\n", + spec, strerror(errno)); + exit(1); + } + close_it = True; + } + + for(p = pass, *p = '\0'; /* ensure that pass is null-terminated */ + p && p - pass < sizeof(pass);) { + switch (read(fd, p, 1)) { + case 1: + if (*p != '\n' && *p != '\0') { + *++p = '\0'; /* advance p, and null-terminate pass */ + break; + } + case 0: + if (p - pass) { + *p = '\0'; /* null-terminate it, just in case... */ + p = NULL; /* then force the loop condition to become false */ + break; + } else { + fprintf(stderr, "Error reading password from file %s: %s\n", + spec, "empty password\n"); + exit(1); + } + + default: + fprintf(stderr, "Error reading password from file %s: %s\n", + spec, strerror(errno)); + exit(1); + } + } + pstrcpy(a->password, pass); + if (close_it) + close(fd); +} + +static void get_credentials_file(const char *file, struct user_auth_info *info) +{ + XFILE *auth; + fstring buf; + uint16 len = 0; + char *ptr, *val, *param; + + if ((auth=x_fopen(file, O_RDONLY, 0)) == NULL) + { + /* fail if we can't open the credentials file */ + d_printf("ERROR: Unable to open credentials file!\n"); + exit(-1); + } + + while (!x_feof(auth)) + { + /* get a line from the file */ + if (!x_fgets(buf, sizeof(buf), auth)) + continue; + len = strlen(buf); + + if ((len) && (buf[len-1]=='\n')) + { + buf[len-1] = '\0'; + len--; + } + if (len == 0) + continue; + + /* break up the line into parameter & value. + * will need to eat a little whitespace possibly */ + param = buf; + if (!(ptr = strchr_m (buf, '='))) + continue; + + val = ptr+1; + *ptr = '\0'; + + /* eat leading white space */ + while ((*val!='\0') && ((*val==' ') || (*val=='\t'))) + val++; + + if (strwicmp("password", param) == 0) + { + pstrcpy(info->password, val); + info->got_pass = True; + } + else if (strwicmp("username", param) == 0) + pstrcpy(info->username, val); + else if (strwicmp("domain", param) == 0) + set_global_myworkgroup(val); + memset(buf, 0, sizeof(buf)); + } + x_fclose(auth); +} + +/* Handle command line options: + * -U,--user + * -A,--authentication-file + * -k,--use-kerberos + * -N,--no-pass + */ + + +static void popt_common_credentials_callback(poptContext con, + enum poptCallbackReason reason, + const struct poptOption *opt, + const char *arg, const void *data) +{ + char *p; + + if (reason == POPT_CALLBACK_REASON_PRE) { + cmdline_auth_info.use_kerberos = False; + cmdline_auth_info.got_pass = False; + pstrcpy(cmdline_auth_info.username, "GUEST"); + + if (getenv("LOGNAME"))pstrcpy(cmdline_auth_info.username,getenv("LOGNAME")); + + if (getenv("USER")) { + pstrcpy(cmdline_auth_info.username,getenv("USER")); + + if ((p = strchr_m(cmdline_auth_info.username,'%'))) { + *p = 0; + pstrcpy(cmdline_auth_info.password,p+1); + cmdline_auth_info.got_pass = True; + memset(strchr_m(getenv("USER"),'%')+1,'X',strlen(cmdline_auth_info.password)); + } + } + + if (getenv("PASSWD")) { + pstrcpy(cmdline_auth_info.password,getenv("PASSWD")); + cmdline_auth_info.got_pass = True; + } + + if (getenv("PASSWD_FD") || getenv("PASSWD_FILE")) { + get_password_file(&cmdline_auth_info); + cmdline_auth_info.got_pass = True; + } + + return; + } + + switch(opt->val) { + case 'U': + { + char *lp; + + pstrcpy(cmdline_auth_info.username,arg); + if ((lp=strchr_m(cmdline_auth_info.username,'%'))) { + *lp = 0; + pstrcpy(cmdline_auth_info.password,lp+1); + cmdline_auth_info.got_pass = True; + memset(strchr_m(arg,'%')+1,'X',strlen(cmdline_auth_info.password)); + } + } + break; + + case 'A': + get_credentials_file(arg, &cmdline_auth_info); + break; + + case 'k': +#ifndef HAVE_KRB5 + d_printf("No kerberos support compiled in\n"); + exit(1); +#else + cmdline_auth_info.use_kerberos = True; + cmdline_auth_info.got_pass = True; +#endif + break; + } +} + + + +struct poptOption popt_common_credentials[] = { + { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE, popt_common_credentials_callback }, + { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "USERNAME" }, + { "no-pass", 'N', POPT_ARG_NONE, &cmdline_auth_info.got_pass, True, "Don't ask for a password" }, + { "kerberos", 'k', POPT_ARG_NONE, &cmdline_auth_info.use_kerberos, True, "Use kerberos (active directory) authentication" }, + { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" }, + POPT_TABLEEND }; diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 5685db7452..013ef9ddb7 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -3,7 +3,7 @@ NBT netbios routines and daemon - version 2 Copyright (C) Andrew Tridgell 1994-1998 Copyright (C) Jeremy Allison 1997-2002 - Copyright (C) Jelmer Vernooij 2002 (Conversion to popt) + Copyright (C) Jelmer Vernooij 2002,2003 (Conversion to popt) 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 @@ -600,15 +600,9 @@ static BOOL open_sockets(BOOL isdaemon, int port) {"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" }, {"hosts", 'H', POPT_ARG_STRING, dyn_LMHOSTSFILE, 'H', "Load a netbios hosts file"}, {"port", 'p', POPT_ARG_INT, &global_nmb_port, NMB_PORT, "Listen on the specified port" }, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_socket_options }, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version }, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_netbios_name }, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_log_base }, + POPT_COMMON_SAMBA { NULL } }; - int opt; pstring logfile; global_nmb_port = NMB_PORT; @@ -624,7 +618,7 @@ static BOOL open_sockets(BOOL isdaemon, int port) fault_setup((void (*)(void *))fault_continue ); /* POSIX demands that signals are inherited. If the invoking process has - * these signals masked, we will have problems, as we won't recieve them. */ + * these signals masked, we will have problems, as we won't receive them. */ BlockSignals(False, SIGHUP); BlockSignals(False, SIGUSR1); BlockSignals(False, SIGTERM); @@ -643,9 +637,6 @@ static BOOL open_sockets(BOOL isdaemon, int port) #endif pc = poptGetContext("nmbd", argc, argv, long_options, 0); - while((opt = poptGetNextOpt(pc)) != -1) - { } - poptFreeContext(pc); if ( opt_interactive ) { diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 056231c344..70925254e4 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -3,7 +3,7 @@ Main SMB server routines Copyright (C) Andrew Tridgell 1992-1998 Copyright (C) Martin Pool 2002 - Copyright (C) Jelmer Vernooij 2002 + Copyright (C) Jelmer Vernooij 2002-2003 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 @@ -669,11 +669,7 @@ static BOOL init_structs(void ) {"log-stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" }, {"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" }, {"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"}, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug}, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile}, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_socket_options}, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_log_base}, - {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, + POPT_COMMON_SAMBA { NULL } }; diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index 99d3e01fd2..bf42fb805f 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -516,7 +516,7 @@ int main (int argc, char **argv) poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP - {"list", 'l', POPT_ARG_NONE, &list_users, 0, "list all users", NULL}, + {"list", 'L', POPT_ARG_NONE, &list_users, 0, "list all users", NULL}, {"verbose", 'v', POPT_ARG_NONE, &verbose, 0, "be verbose", NULL }, {"smbpasswd-style", 'w',POPT_ARG_NONE, &spstyle, 0, "give output in smbpasswd style", NULL}, {"user", 'u', POPT_ARG_STRING, &user_name, 0, "use username", "USER" }, @@ -534,11 +534,10 @@ int main (int argc, char **argv) {"export", 'e', POPT_ARG_STRING, &backend_out, 0, "export user accounts to this backend", NULL}, {"group", 'g', POPT_ARG_NONE, &transfer_groups, 0, "use -i and -e for groups", NULL}, {"account-policy", 'P', POPT_ARG_STRING, &account_policy, 0,"value of an account policy (like maximum password age)",NULL}, - {"value", 'V', POPT_ARG_LONG, &account_policy_value, 'V',"set the account policy to this value", NULL}, + {"value", 'C', POPT_ARG_LONG, &account_policy_value, 'C',"set the account policy to this value", NULL}, {"account-control", 'c', POPT_ARG_STRING, &account_control, 0, "Values of account control", NULL}, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, - {0,0,0,0} + POPT_COMMON_SAMBA + POPT_TABLEEND }; setup_logging("pdbedit", True); diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c index 940120d644..cbe1bd448f 100644 --- a/source3/utils/smbtree.c +++ b/source3/utils/smbtree.c @@ -3,6 +3,7 @@ Network neighbourhood browser. Copyright (C) Tim Potter 2000 + Copyright (C) Jelmer Vernooij 2003 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 @@ -23,34 +24,11 @@ static BOOL use_bcast; -struct user_auth_info { - pstring username; - pstring password; - pstring workgroup; -}; - /* How low can we go? */ enum tree_level {LEV_WORKGROUP, LEV_SERVER, LEV_SHARE}; static enum tree_level level = LEV_SHARE; -static void usage(void) -{ - printf( -"Usage: smbtree [options]\n\ -\n\ -\t-d debuglevel set debug output level\n\ -\t-U username user to autheticate as\n\ -\t-W workgroup workgroup of user to authenticate as\n\ -\t-D list only domains (workgroups) of tree\n\ -\t-S list domains and servers of tree\n\ -\t-b use bcast instead of using the master browser\n\ -\n\ -The username can be of the form username%%password or\n\ -workgroup\\username%%password.\n\n\ -"); -} - /* Holds a list of workgroups or servers */ struct name_list { @@ -87,62 +65,6 @@ static void add_name(const char *machine_name, uint32 server_type, DLIST_ADD(*name_list, new_name); } -/* Return a cli_state pointing at the IPC$ share for the given server */ - -static struct cli_state *get_ipc_connect(char *server, struct in_addr *server_ip, - struct user_auth_info *user_info) -{ - struct cli_state *cli; - pstring myname; - NTSTATUS nt_status; - - get_myname(myname); - - nt_status = cli_full_connection(&cli, myname, server, server_ip, 0, "IPC$", "IPC", - user_info->username, lp_workgroup(), user_info->password, - CLI_FULL_CONNECTION_ANNONYMOUS_FALLBACK, NULL); - - if (NT_STATUS_IS_OK(nt_status)) { - return cli; - } else { - return NULL; - } -} - -/* Return the IP address and workgroup of a master browser on the - network. */ - -static BOOL find_master_ip_bcast(pstring workgroup, struct in_addr *server_ip) -{ - struct in_addr *ip_list; - int i, count; - - /* Go looking for workgroups by broadcasting on the local network */ - - if (!name_resolve_bcast(MSBROWSE, 1, &ip_list, &count)) { - return False; - } - - for (i = 0; i < count; i++) { - static fstring name; - - if (!name_status_find("*", 0, 0x1d, ip_list[i], name)) - continue; - - if (!find_master_ip(name, server_ip)) - continue; - - pstrcpy(workgroup, name); - - DEBUG(4, ("found master browser %s, %s\n", - name, inet_ntoa(ip_list[i]))); - - return True; - } - - return False; -} - /**************************************************************************** display tree of smb workgroups, servers and shares ****************************************************************************/ @@ -158,19 +80,21 @@ static BOOL get_workgroups(struct user_auth_info *user_info) pstrcpy(master_workgroup, lp_workgroup()); - if (use_bcast || !find_master_ip(lp_workgroup(), &server_ip)) { - DEBUG(4, ("Unable to find master browser for workgroup %s\n", + if (!use_bcast && !find_master_ip(lp_workgroup(), &server_ip)) { + DEBUG(4, ("Unable to find master browser for workgroup %s, falling back to broadcast\n", master_workgroup)); - if (!find_master_ip_bcast(master_workgroup, &server_ip)) { + use_bcast = True; + } else if(!use_bcast) { + if (!(cli = get_ipc_connect(inet_ntoa(server_ip), &server_ip, user_info))) + return False; + } + + if (!(cli = get_ipc_connect_master_ip_bcast(master_workgroup, user_info))) { DEBUG(4, ("Unable to find master browser by " "broadcast\n")); return False; - } } - if (!(cli = get_ipc_connect(inet_ntoa(server_ip), &server_ip, user_info))) - return False; - if (!cli_NetServerEnum(cli, master_workgroup, SV_TYPE_DOMAIN_ENUM, add_name, &workgroups)) return False; @@ -267,13 +191,17 @@ static BOOL print_tree(struct user_auth_info *user_info) ****************************************************************************/ int main(int argc,char *argv[]) { - extern char *optarg; - extern int optind; - int opt; - char *p; - struct user_auth_info user_info; - BOOL got_pass = False; - + struct poptOption long_options[] = { + POPT_AUTOHELP + { "broadcast", 'b', POPT_ARG_VAL, &use_bcast, True, "Use broadcast instead of using the master browser" }, + { "domains", 'D', POPT_ARG_VAL, &level, LEV_WORKGROUP, "List only domains (workgroups) of tree" }, + { "servers", 'S', POPT_ARG_VAL, &level, LEV_SERVER, "List domains(workgroups) and servers of tree" }, + POPT_COMMON_SAMBA + POPT_COMMON_CREDENTIALS + POPT_TABLEEND + }; + poptContext pc; + /* Initialise samba stuff */ setlinebuf(stdout); @@ -282,86 +210,27 @@ static BOOL print_tree(struct user_auth_info *user_info) setup_logging(argv[0],True); + pc = poptGetContext("smbtree", argc, (const char **)argv, long_options, + POPT_CONTEXT_KEEP_FIRST); + while(poptGetNextOpt(pc) != -1); + poptFreeContext(pc); + lp_load(dyn_CONFIGFILE,True,False,False); load_interfaces(); - if (getenv("USER")) { - pstrcpy(user_info.username, getenv("USER")); - - if ((p=strchr(user_info.username, '%'))) { - *p = 0; - pstrcpy(user_info.password, p+1); - got_pass = True; - memset(strchr(getenv("USER"), '%') + 1, 'X', - strlen(user_info.password)); - } - } - - pstrcpy(user_info.workgroup, lp_workgroup()); - /* Parse command line args */ - while ((opt = getopt(argc, argv, "U:hd:W:DSb")) != EOF) { - switch (opt) { - case 'U': - pstrcpy(user_info.username,optarg); - p = strchr(user_info.username,'%'); - if (p) { - *p = 0; - pstrcpy(user_info.password, p+1); - got_pass = 1; - } - break; - - case 'b': - use_bcast = True; - break; - - case 'h': - usage(); - exit(1); - - case 'd': - DEBUGLEVEL = atoi(optarg); - break; - - case 'W': - pstrcpy(user_info.workgroup, optarg); - break; - - case 'D': - level = LEV_WORKGROUP; - break; - - case 'S': - level = LEV_SERVER; - break; - - default: - printf("Unknown option %c (%d)\n", (char)opt, opt); - exit(1); - } - } - - argc -= optind; - argv += optind; - - if (argc > 0) { - usage(); - exit(1); - } - - if (!got_pass) { + if (!cmdline_auth_info.got_pass) { char *pass = getpass("Password: "); if (pass) { - pstrcpy(user_info.password, pass); + pstrcpy(cmdline_auth_info.password, pass); } - got_pass = True; + cmdline_auth_info.got_pass = True; } /* Now do our stuff */ - if (!print_tree(&user_info)) + if (!print_tree(&cmdline_auth_info)) return 1; return 0; diff --git a/source3/utils/status.c b/source3/utils/status.c index 8014b133d9..7e87701752 100644 --- a/source3/utils/status.c +++ b/source3/utils/status.c @@ -559,10 +559,8 @@ static int traverse_sessionid(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, vo {"profile", 'P', POPT_ARG_NONE, &profile_only, 'P', "Do profiling" }, #endif /* WITH_PROFILE */ {"byterange", 'B', POPT_ARG_NONE, &show_brl, 'B', "Include byte range locks"}, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, - { 0, 0, 0, 0} + POPT_COMMON_SAMBA + POPT_TABLEEND }; setup_logging(argv[0],True); diff --git a/source3/web/swat.c b/source3/web/swat.c index 6d14e9db98..fa319bb3ae 100644 --- a/source3/web/swat.c +++ b/source3/web/swat.c @@ -1267,9 +1267,8 @@ static void printers_page(void) struct poptOption long_options[] = { POPT_AUTOHELP { "disable-authentication", 'a', POPT_ARG_VAL, &demo_mode, True, "Disable authentication (demo mode)" }, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version}, - { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile}, - { 0, 0, 0, 0 } + POPT_COMMON_SAMBA + POPT_TABLEEND }; fault_setup(NULL); |