summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2003-03-24 11:25:34 +0000
committerJelmer Vernooij <jelmer@samba.org>2003-03-24 11:25:34 +0000
commit2ddfed298d7f0b6e690275725a39c3ef107077ae (patch)
tree0132d5c894c36e4182caa067baa828b2f5abee81
parent55a341a367a7d1b18ae7ef04678479eb74b68ea3 (diff)
downloadsamba-2ddfed298d7f0b6e690275725a39c3ef107077ae.tar.gz
Patch from metze to generalise POPT_COMMON_SAMBA, with some minor changes
-rw-r--r--source/client/client.c16
-rw-r--r--source/include/popt_common.h11
-rw-r--r--source/lib/popt_common.c95
-rw-r--r--source/nmbd/nmbd.c5
-rw-r--r--source/nsswitch/wbinfo.c4
-rw-r--r--source/nsswitch/winbindd.c7
-rw-r--r--source/rpcclient/rpcclient.c156
-rw-r--r--source/smbd/server.c4
-rw-r--r--source/torture/samtest.c14
-rw-r--r--source/torture/vfstest.c44
-rw-r--r--source/utils/net.c3
-rw-r--r--source/utils/nmblookup.c3
-rw-r--r--source/utils/ntlm_auth.c10
-rw-r--r--source/utils/pdbedit.c4
-rw-r--r--source/utils/smbcacls.c45
-rw-r--r--source/utils/smbtree.c8
-rw-r--r--source/utils/status.c6
-rw-r--r--source/utils/testparm.c4
-rw-r--r--source/web/swat.c5
-rw-r--r--source/wrepld/server.c8
20 files changed, 95 insertions, 357 deletions
diff --git a/source/client/client.c b/source/client/client.c
index 9fb843cfbae..8d6730cdc66 100644
--- a/source/client/client.c
+++ b/source/client/client.c
@@ -2589,15 +2589,7 @@ static void remember_query_host(const char *arg,
int rc = 0;
struct poptOption long_options[] = {
POPT_AUTOHELP
- POPT_COMMON_SAMBA
- { 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_version },
- { 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_netbios_name },
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_scope },
- POPT_CREDENTIALS
+
{ "name-resolve", 'R', POPT_ARG_STRING, &new_name_resolve_order, 'R', "Use these name resolution services only", "NAME-RESOLVE-ORDER" },
{ "message", 'M', POPT_ARG_STRING, NULL, 'M', "Send message", "HOST" },
{ "ip-address", 'I', POPT_ARG_STRING, NULL, 'I', "Use this IP to connect to", "IP" },
@@ -2610,7 +2602,9 @@ static void remember_query_host(const char *arg,
{ "command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated commands" },
{ "send-buffer", 'b', POPT_ARG_INT, NULL, 'b', "Changes the transmit/send buffer", "BYTES" },
{ "port", 'p', POPT_ARG_INT, &port, 'p', "Port to connect to", "PORT" },
- { 0, 0, 0, 0 }
+ POPT_COMMON_SAMBA
+ POPT_CREDENTIALS
+ POPT_TABLEEND
};
@@ -2720,7 +2714,7 @@ static void remember_query_host(const char *arg,
pstrcpy(username, cmdline_auth_info.username);
pstrcpy(password, cmdline_auth_info.password);
- pstrcpy(workgroup, cmdline_auth_info.workgroup);
+ pstrcpy(workgroup, lp_workgroup());
use_kerberos = cmdline_auth_info.use_kerberos;
got_pass = cmdline_auth_info.got_pass;
diff --git a/source/include/popt_common.h b/source/include/popt_common.h
index 9354e8734d7..7cdbc988623 100644
--- a/source/include/popt_common.h
+++ b/source/include/popt_common.h
@@ -22,22 +22,15 @@
#define _POPT_COMMON_H
/* Common popt structures */
-extern struct poptOption popt_common_debug[];
-extern struct poptOption popt_common_configfile[];
-extern struct poptOption popt_common_socket_options[];
-extern struct poptOption popt_common_version[];
-extern struct poptOption popt_common_netbios_name[];
-extern struct poptOption popt_common_log_base[];
+extern struct poptOption popt_common_samba[];
extern struct poptOption popt_common_credentials[];
-extern struct poptOption popt_common_scope[];
-#define POPT_COMMON_SAMBA { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version, 0, "Common samba options:", NULL },
+#define POPT_COMMON_SAMBA { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_samba, 0, "Common samba options:", NULL },
#define POPT_CREDENTIALS { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_credentials, 0, "Authentication options:", NULL },
struct user_auth_info {
pstring username;
pstring password;
- pstring workgroup;
BOOL got_pass;
BOOL use_kerberos;
};
diff --git a/source/lib/popt_common.c b/source/lib/popt_common.c
index 3c9a87b361c..06ba4fc898e 100644
--- a/source/lib/popt_common.c
+++ b/source/lib/popt_common.c
@@ -29,6 +29,7 @@
* -V,--version
* -l,--log-base
* -n,--netbios-name
+ * -W,--workgroup
* -i,--scope
*/
@@ -102,49 +103,29 @@ static void popt_common_callback(poptContext con,
set_global_scope(arg);
}
break;
+
+ case 'W':
+ if (arg) {
+ set_global_myworkgroup(arg);
+ }
+ break;
}
}
-struct poptOption popt_common_debug[] = {
+struct poptOption popt_common_samba[] = {
{ NULL, 0, POPT_ARG_CALLBACK, popt_common_callback },
{ "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" },
- { 0 }
-};
-
-struct poptOption popt_common_scope[] = {
- { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback },
- { "scope", 'i', POPT_ARG_STRING, NULL, 'i', "Use this Netbios scope", "SCOPE" },
- { 0 }
-};
-
-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_version[] = {
- { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback },
- {"version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" },
- { 0 }
-};
-
-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 }
+ { "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file",
+ "CONFIGFILE" },
+ { "socket-options", 'O', POPT_ARG_STRING, NULL, 'O', "socket options to use",
+ "SOCKETOPTIONS" },
+ { "version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" },
+ { "log-basename", 'l', POPT_ARG_STRING, NULL, 'l', "Basename for log/debug files",
+ "LOGFILEBASE" },
+ { "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
};
/****************************************************************************
@@ -255,7 +236,7 @@ static void get_credentials_file(const char *file, struct user_auth_info *info)
else if (strwicmp("username", param) == 0)
pstrcpy(info->username, val);
else if (strwicmp("domain", param) == 0)
- pstrcpy(info->workgroup,val);
+ set_global_myworkgroup(val);
memset(buf, 0, sizeof(buf));
}
x_fclose(auth);
@@ -263,7 +244,6 @@ static void get_credentials_file(const char *file, struct user_auth_info *info)
/* Handle command line options:
* -U,--user
- * -W,--workgroup
* -A,--authentication-file
* -k,--use-kerberos
* -N,--no-pass
@@ -327,30 +307,25 @@ static void popt_common_credentials_callback(poptContext con,
get_credentials_file(arg, &cmdline_auth_info);
break;
- case 'W':
- pstrcpy(cmdline_auth_info.workgroup,arg);
- break;
-
- case 'k':
+ case 'k':
#ifndef HAVE_KRB5
- d_printf("No kerberos support compiled in\n");
- exit(1);
+ d_printf("No kerberos support compiled in\n");
+ exit(1);
#else
- cmdline_auth_info.got_pass = True;
+ cmdline_auth_info.use_kerberos = True;
+ cmdline_auth_info.got_pass = True;
#endif
-
- break;
- }
+ 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_VAL, &cmdline_auth_info.got_pass, True, "Don't ask for a password" },
- { "kerberos", 'k', POPT_ARG_VAL, &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" },
- { "workgroup", 'W', POPT_ARG_STRING, NULL, 'W', "Set the workgroup name", "WORKGROUP" },
- { 0 }
- };
+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/source/nmbd/nmbd.c b/source/nmbd/nmbd.c
index a34593557e5..d013b79d3e6 100644
--- a/source/nmbd/nmbd.c
+++ b/source/nmbd/nmbd.c
@@ -601,11 +601,6 @@ static BOOL open_sockets(BOOL isdaemon, int port)
{"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" },
POPT_COMMON_SAMBA
- {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_netbios_name },
- {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_log_base },
{ NULL }
};
pstring logfile;
diff --git a/source/nsswitch/wbinfo.c b/source/nsswitch/wbinfo.c
index 4f621e7008a..fe11cd65285 100644
--- a/source/nsswitch/wbinfo.c
+++ b/source/nsswitch/wbinfo.c
@@ -711,8 +711,8 @@ int main(int argc, char **argv)
{ "set-auth-user", 'A', POPT_ARG_STRING, &string_arg, OPT_SET_AUTH_USER, "Store user and password used by winbindd (root only)", "user%password" },
{ "get-auth-user", 0, POPT_ARG_NONE, NULL, OPT_GET_AUTH_USER, "Retrieve user and password used by winbindd (root only)", NULL },
{ "ping", 'p', POPT_ARG_NONE, 0, 'p', "Ping winbindd to see if it is alive" },
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version},
- { 0, 0, 0, 0 }
+ POPT_COMMON_SAMBA
+ POPT_TABLEEND
};
/* Samba client initialisation */
diff --git a/source/nsswitch/winbindd.c b/source/nsswitch/winbindd.c
index c9d68083168..cd72a4f5721 100644
--- a/source/nsswitch/winbindd.c
+++ b/source/nsswitch/winbindd.c
@@ -814,16 +814,13 @@ int main(int argc, char **argv)
static BOOL log_stdout = False;
struct poptOption long_options[] = {
POPT_AUTOHELP
- POPT_COMMON_SAMBA
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug },
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile },
{ "stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
{ "foreground", 'F', POPT_ARG_VAL, &Fork, False, "Daemon in foreground mode" },
{ "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Interactive mode" },
{ "dual-daemon", 'B', POPT_ARG_VAL, &opt_dual_daemon, True, "Dual daemon mode" },
{ "no-caching", 'n', POPT_ARG_VAL, &opt_nocache, False, "Disable caching" },
-
- { 0, 0, 0, 0 }
+ POPT_COMMON_SAMBA
+ POPT_TABLEEND
};
poptContext pc;
int opt;
diff --git a/source/rpcclient/rpcclient.c b/source/rpcclient/rpcclient.c
index 2338d72f192..97a944dbf9d 100644
--- a/source/rpcclient/rpcclient.c
+++ b/source/rpcclient/rpcclient.c
@@ -97,70 +97,6 @@ static char **completion_fn(char *text, int start, int end)
return matches;
}
-/***********************************************************************
- * read in username/password credentials from a file
- */
-static void read_authfile (
- char *filename,
- char* username,
- char* password,
- char* domain
-)
-{
- FILE *auth;
- fstring buf;
- uint16 len = 0;
- char *ptr, *val, *param;
-
- if ((auth=sys_fopen(filename, "r")) == NULL)
- {
- printf ("ERROR: Unable to open credentials file!\n");
- return;
- }
-
- while (!feof(auth))
- {
- /* get a line from the file */
- if (!fgets (buf, sizeof(buf), auth))
- continue;
-
- len = strlen(buf);
-
- /* skip empty lines */
- 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)
- fstrcpy (password, val);
- else if (strwicmp("username", param) == 0)
- fstrcpy (username, val);
- else if (strwicmp("domain", param) == 0)
- fstrcpy (domain, val);
-
- memset(buf, 0, sizeof(buf));
- }
- fclose(auth);
-
- return;
-}
-
static char* next_command (char** cmdstr)
{
static pstring command;
@@ -181,28 +117,6 @@ static char* next_command (char** cmdstr)
return command;
}
-
-/**
- * Find default username from environment variables.
- *
- * @param username fstring to receive username; not touched if none is
- * known.
- **/
-static void get_username (char *username)
-{
- if (getenv("USER"))
- fstrcpy(username,getenv("USER"));
-
- if (*username == 0 && getenv("LOGNAME"))
- fstrcpy(username,getenv("LOGNAME"));
-
- if (*username == 0) {
- fstrcpy(username,"GUEST");
- }
-
- return;
-}
-
/* Fetch the SID for this computer */
static void fetch_machine_sid(struct cli_state *cli)
@@ -575,21 +489,12 @@ out_free:
int main(int argc, char *argv[])
{
- static int got_pass = 0;
BOOL interactive = True;
int opt;
- static char *cmdstr = "";
+ static char *cmdstr = NULL;
const char *server;
struct cli_state *cli;
- fstring password="",
- username="",
- domain="";
- static char *opt_authfile=NULL,
- *opt_username=NULL,
- *opt_domain=NULL,
- *opt_logfile=NULL,
- *opt_ipaddr=NULL;
- pstring logfile;
+ static char *opt_ipaddr=NULL;
struct cmd_set **cmd_set;
struct in_addr server_ip;
NTSTATUS nt_status;
@@ -599,17 +504,11 @@ out_free:
poptContext pc;
struct poptOption long_options[] = {
POPT_AUTOHELP
- {"authfile", 'A', POPT_ARG_STRING, &opt_authfile, 'A', "File containing user credentials", "AUTHFILE"},
- {"nopass", 'N', POPT_ARG_NONE, &got_pass, 'N', "Don't ask for a password"},
- {"user", 'U', POPT_ARG_STRING, &opt_username, 'U', "Set the network username", "USER"},
- {"workgroup", 'W', POPT_ARG_STRING, &opt_domain, 'W', "Set the domain name for user account", "DOMAIN"},
{"command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated cmds", "COMMANDS"},
- {"logfile", 'l', POPT_ARG_STRING, &opt_logfile, 'l', "Logfile to use instead of stdout", "LOGFILE" },
{"dest-ip", 'I', POPT_ARG_STRING, &opt_ipaddr, 'I', "Specify destination IP address", "IP"},
- { 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_version},
- { NULL }
+ POPT_COMMON_SAMBA
+ POPT_CREDENTIALS
+ POPT_TABLEEND
};
ZERO_STRUCT(server_ip);
@@ -628,43 +527,13 @@ out_free:
while((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
- case 'A':
- /* only get the username, password, and domain from the file */
- read_authfile (opt_authfile, username, password, domain);
- if (strlen (password))
- got_pass = 1;
- break;
-
- case 'l':
- slprintf(logfile, sizeof(logfile) - 1, "%s.client",
- opt_logfile);
- lp_set_logfile(logfile);
- interactive = False;
- break;
-
- case 'U': {
- char *lp;
- fstrcpy(username,opt_username);
-
- if ((lp=strchr_m(username,'%'))) {
- *lp = 0;
- fstrcpy(password,lp+1);
- got_pass = 1;
- memset(strchr_m(opt_username,'%') + 1, 'X',
- strlen(password));
- }
- break;
- }
case 'I':
if ( (server_ip.s_addr=inet_addr(opt_ipaddr)) == INADDR_NONE ) {
fprintf(stderr, "%s not a valid IP address\n",
opt_ipaddr);
return 1;
}
- case 'W':
- fstrcpy(domain, opt_domain);
- break;
}
}
@@ -701,28 +570,25 @@ out_free:
* from stdin if necessary
*/
- if (!got_pass) {
+ if (!cmdline_auth_info.got_pass) {
char *pass = getpass("Password:");
if (pass) {
- fstrcpy(password, pass);
+ pstrcpy(cmdline_auth_info.password, pass);
}
}
- if (!strlen(username) && !got_pass)
- get_username(username);
-
nt_status = cli_full_connection(&cli, global_myname(), server,
opt_ipaddr ? &server_ip : NULL, 0,
"IPC$", "IPC",
- username, domain,
- password, 0, NULL);
+ cmdline_auth_info.username, lp_workgroup(),
+ cmdline_auth_info.password, 0, NULL);
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("Cannot connect to server. Error was %s\n", nt_errstr(nt_status)));
return 1;
}
- memset(password,'X',sizeof(password));
+ memset(cmdline_auth_info.password,'X',sizeof(cmdline_auth_info.password));
/* Load command lists */
@@ -737,7 +603,7 @@ out_free:
fetch_machine_sid(cli);
/* Do anything specified with -c */
- if (cmdstr[0]) {
+ if (cmdstr && cmdstr[0]) {
char *cmd;
char *p = cmdstr;
diff --git a/source/smbd/server.c b/source/smbd/server.c
index 627fad15726..715e9162631 100644
--- a/source/smbd/server.c
+++ b/source/smbd/server.c
@@ -670,10 +670,6 @@ static BOOL init_structs(void )
{"build-options", 'b', POPT_ARG_NONE, NULL, 'b', "Print build options" },
{"port", 'p', POPT_ARG_STRING, &ports, 0, "Listen on the specified ports"},
POPT_COMMON_SAMBA
- {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 }
};
diff --git a/source/torture/samtest.c b/source/torture/samtest.c
index 0de2e5d2889..fd5f75a664b 100644
--- a/source/torture/samtest.c
+++ b/source/torture/samtest.c
@@ -353,10 +353,7 @@ int main(int argc, char *argv[])
{
BOOL interactive = True;
int opt;
- static char *cmdstr = "";
- static char *opt_logfile=NULL;
- static char *config_file = dyn_CONFIGFILE;
- pstring logfile;
+ static char *cmdstr = NULL;
struct cmd_set **cmd_set;
struct samtest_state st;
@@ -365,12 +362,9 @@ int main(int argc, char *argv[])
poptContext pc;
struct poptOption long_options[] = {
POPT_AUTOHELP
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug },
{"command", 'e', POPT_ARG_STRING, &cmdstr, 'e', "Execute semicolon seperated cmds"},
- {"logfile", 'l', POPT_ARG_STRING, &opt_logfile, 'l', "Logfile to use instead of stdout"},
- {"configfile", 'c', POPT_ARG_STRING, &config_file, 0,"use different configuration file",NULL},
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version},
- { 0, 0, 0, 0}
+ POPT_COMMON_SAMBA
+ POPT_TABLEEND
};
ZERO_STRUCT(st);
@@ -419,7 +413,7 @@ int main(int argc, char *argv[])
}
/* Do anything specified with -c */
- if (cmdstr[0]) {
+ if (cmdstr && cmdstr[0]) {
char *cmd;
char *p = cmdstr;
diff --git a/source/torture/vfstest.c b/source/torture/vfstest.c
index 04f31656d3d..3b28a3c496b 100644
--- a/source/torture/vfstest.c
+++ b/source/torture/vfstest.c
@@ -4,7 +4,7 @@
Copyright (C) Simo Sorce 2002
Copyright (C) Eric Lorimer 2002
- Copyright (C) Jelmer Vernooij 2002
+ Copyright (C) Jelmer Vernooij 2002,2003
Most of this code was ripped off of rpcclient.
Copyright (C) Tim Potter 2000-2001
@@ -474,17 +474,11 @@ BOOL reload_services(BOOL test)
int main(int argc, char *argv[])
{
- BOOL interactive = True;
- int opt;
- static char *cmdstr = "";
- static char *opt_logfile=NULL;
- static int opt_debuglevel;
- pstring logfile;
+ static char *cmdstr = NULL;
struct cmd_set **cmd_set;
- extern BOOL AllowDebugChange;
static struct vfs_state vfs;
int i;
- static const char *filename = "";
+ static const char *filename = NULL;
/* make sure the vars that get altered (4th field) are in
a fixed location or certain compilers complain */
@@ -493,35 +487,17 @@ int main(int argc, char *argv[])
POPT_AUTOHELP
{"file", 'f', POPT_ARG_STRING, &filename, 0, },
{"command", 'c', POPT_ARG_STRING, &cmdstr, 0, "Execute specified list of commands" },
- {"logfile", 'l', POPT_ARG_STRING, &opt_logfile, 'l', "Write output to specified logfile" },
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug },
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version},
- { 0, 0, 0, 0}
+ POPT_COMMON_SAMBA
+ POPT_TABLEEND
};
setlinebuf(stdout);
- DEBUGLEVEL = 1;
- AllowDebugChange = False;
-
pc = poptGetContext("vfstest", argc, (const char **) argv,
long_options, 0);
- while((opt = poptGetNextOpt(pc)) != -1) {
- switch (opt) {
- case 'l':
- slprintf(logfile, sizeof(logfile) - 1, "%s.client",
- opt_logfile);
- lp_set_logfile(logfile);
- interactive = False;
- break;
-
- case 'd':
- DEBUGLEVEL = opt_debuglevel;
- break;
- }
- }
+ while(poptGetNextOpt(pc) != -1);
poptFreeContext(pc);
@@ -531,9 +507,7 @@ int main(int argc, char *argv[])
/* the following functions are part of the Samba debugging
facilities. See lib/debug.c */
- setup_logging("vfstest", interactive);
- if (!interactive)
- reopen_logs();
+ setup_logging("vfstest", True);
/* Load command lists */
@@ -556,13 +530,13 @@ int main(int argc, char *argv[])
smbd_vfs_init(vfs.conn);
/* Do we have a file input? */
- if (filename[0]) {
+ if (filename && filename[0]) {
process_file(&vfs, filename);
return 0;
}
/* Do anything specified with -c */
- if (cmdstr[0]) {
+ if (cmdstr && cmdstr[0]) {
char *cmd;
char *p = cmdstr;
diff --git a/source/utils/net.c b/source/utils/net.c
index 33c125901b9..d6945ceefbd 100644
--- a/source/utils/net.c
+++ b/source/utils/net.c
@@ -515,7 +515,6 @@ static struct functable net_func[] = {
struct poptOption long_options[] = {
{"help", 'h', POPT_ARG_NONE, 0, 'h'},
{"workgroup", 'w', POPT_ARG_STRING, &opt_target_workgroup},
- {"myworkgroup", 'W', POPT_ARG_STRING, &opt_workgroup},
{"user", 'U', POPT_ARG_STRING, &opt_user_name, 'U'},
{"ipaddress", 'I', POPT_ARG_STRING, 0,'I'},
{"port", 'p', POPT_ARG_INT, &opt_port},
@@ -532,8 +531,6 @@ static struct functable net_func[] = {
{"timeout", 't', POPT_ARG_INT, &opt_timeout},
{"machine-pass",'P', POPT_ARG_NONE, &opt_machine_pass},
POPT_COMMON_SAMBA
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug },
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile },
{ 0, 0, 0, 0}
};
diff --git a/source/utils/nmblookup.c b/source/utils/nmblookup.c
index 97cea3a7bbf..88038fb566a 100644
--- a/source/utils/nmblookup.c
+++ b/source/utils/nmblookup.c
@@ -203,9 +203,6 @@ int main(int argc,char *argv[])
{ "root-port", 'r', POPT_ARG_VAL, &RootPort, True, "Use root port 137 (Win95 only replies to this)" },
{ "lookup-by-ip", 'A', POPT_ARG_VAL, &lookup_by_ip, True, "Do a node status on <name> as an IP Address" },
POPT_COMMON_SAMBA
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_scope },
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile },
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug },
{ 0, 0, 0, 0 }
};
diff --git a/source/utils/ntlm_auth.c b/source/utils/ntlm_auth.c
index ac456769f22..a28bbf93648 100644
--- a/source/utils/ntlm_auth.c
+++ b/source/utils/ntlm_auth.c
@@ -439,14 +439,13 @@ enum {
OPT_NT_KEY
};
-int main(int argc, const char **argv)
+ int main(int argc, const char **argv)
{
int opt;
poptContext pc;
struct poptOption long_options[] = {
POPT_AUTOHELP
-
{ "helper-protocol", 0, POPT_ARG_STRING, &helper_protocol, OPT_DOMAIN, "operate as a stdio-based helper", "helper protocol to use"},
{ "username", 0, POPT_ARG_STRING, &username, OPT_USERNAME, "username"},
{ "domain", 0, POPT_ARG_STRING, &domain, OPT_DOMAIN, "domain name"},
@@ -457,10 +456,9 @@ int main(int argc, const char **argv)
{ "password", 0, POPT_ARG_STRING, &password, OPT_PASSWORD, "User's plaintext password"},
{ "request-lm-key", 0, POPT_ARG_NONE, &request_lm_key, OPT_LM_KEY, "Retreive LM session key"},
{ "request-nt-key", 0, POPT_ARG_NONE, &request_nt_key, OPT_NT_KEY, "Retreive NT session key"},
- { 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_version},
- { 0, 0, 0, 0 }
+ POPT_COMMON_SAMBA
+ POPT_CREDENTIALS
+ POPT_TABLEEND
};
/* Samba client initialisation */
diff --git a/source/utils/pdbedit.c b/source/utils/pdbedit.c
index f373adcb0a9..03be2571e54 100644
--- a/source/utils/pdbedit.c
+++ b/source/utils/pdbedit.c
@@ -537,9 +537,7 @@ int main (int argc, char **argv)
{"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},
POPT_COMMON_SAMBA
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug },
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile },
- {0,0,0,0}
+ POPT_TABLEEND
};
setup_logging("pdbedit", True);
diff --git a/source/utils/smbcacls.c b/source/utils/smbcacls.c
index af5bf09e48c..ac15cf1aa03 100644
--- a/source/utils/smbcacls.c
+++ b/source/utils/smbcacls.c
@@ -24,11 +24,8 @@
#include "includes.h"
-static fstring password;
-static pstring username;
static pstring owner_username;
static fstring server;
-static int got_pass;
static int test_args = False;
static TALLOC_CTX *ctx;
@@ -716,19 +713,19 @@ static struct cli_state *connect_one(const char *share)
NTSTATUS nt_status;
zero_ip(&ip);
- if (!got_pass) {
+ if (!cmdline_auth_info.got_pass) {
char *pass = getpass("Password: ");
if (pass) {
- fstrcpy(password, pass);
- got_pass = True;
+ pstrcpy(cmdline_auth_info.password, pass);
+ cmdline_auth_info.got_pass = True;
}
}
if (NT_STATUS_IS_OK(nt_status = cli_full_connection(&c, global_myname(), server,
&ip, 0,
share, "?????",
- username, lp_workgroup(),
- password, 0, NULL))) {
+ cmdline_auth_info.username, lp_workgroup(),
+ cmdline_auth_info.password, 0, NULL))) {
return c;
} else {
DEBUG(0,("cli_full_connection failed! (%s)\n", nt_errstr(nt_status)));
@@ -743,7 +740,6 @@ static struct cli_state *connect_one(const char *share)
{
char *share;
int opt;
- char *p;
enum acl_mode mode = SMB_ACL_SET;
static char *the_acl = NULL;
enum chown_mode change_mode = REQUEST_NONE;
@@ -759,12 +755,10 @@ static struct cli_state *connect_one(const char *share)
{ "set", 'S', POPT_ARG_STRING, NULL, 'S', "Set acls", "ACLS" },
{ "chown", 'C', POPT_ARG_STRING, NULL, 'C', "Change ownership of a file", "USERNAME" },
{ "chgrp", 'G', POPT_ARG_STRING, NULL, 'G', "Change group ownership of a file", "GROUPNAME" },
- { "numeric", 'n', POPT_ARG_VAL, &numeric, True, "Don't resolve sids or masks to names" },
- { "test-args", 't', POPT_ARG_VAL, &test_args, True, "Test arguments"},
- { 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 },
- {"username", 'U', POPT_ARG_STRING, NULL, 'U', "User to authenticate as", "user%password" },
+ { "numeric", 0, POPT_ARG_NONE, &numeric, True, "Don't resolve sids or masks to names" },
+ { "test-args", 't', POPT_ARG_NONE, &test_args, True, "Test arguments"},
+ POPT_COMMON_SAMBA
+ POPT_CREDENTIALS
{ NULL }
};
@@ -781,33 +775,12 @@ static struct cli_state *connect_one(const char *share)
lp_load(dyn_CONFIGFILE,True,False,False);
load_interfaces();
- if (getenv("USER")) {
- pstrcpy(username,getenv("USER"));
-
- if ((p=strchr_m(username,'%'))) {
- *p = 0;
- fstrcpy(password,p+1);
- got_pass = True;
- memset(strchr_m(getenv("USER"), '%') + 1, 'X',
- strlen(password));
- }
- }
pc = poptGetContext("smbcacls", argc, argv, long_options, 0);
poptSetOtherOptionHelp(pc, "//server1/share1 filename");
while ((opt = poptGetNextOpt(pc)) != -1) {
switch (opt) {
- case 'U':
- pstrcpy(username,poptGetOptArg(pc));
- p = strchr_m(username,'%');
- if (p) {
- *p = 0;
- fstrcpy(password, p+1);
- got_pass = 1;
- }
- break;
-
case 'S':
the_acl = smb_xstrdup(poptGetOptArg(pc));
mode = SMB_ACL_SET;
diff --git a/source/utils/smbtree.c b/source/utils/smbtree.c
index a55dd4dd009..32506c41019 100644
--- a/source/utils/smbtree.c
+++ b/source/utils/smbtree.c
@@ -247,14 +247,12 @@ static BOOL print_tree(struct user_auth_info *user_info)
{
struct poptOption long_options[] = {
POPT_AUTOHELP
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_credentials },
- { 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 },
{ "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" },
- { 0 }
+ POPT_COMMON_SAMBA
+ POPT_CREDENTIALS
+ POPT_TABLEEND
};
poptContext pc;
diff --git a/source/utils/status.c b/source/utils/status.c
index 8014b133d9e..7e87701752a 100644
--- a/source/utils/status.c
+++ b/source/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/source/utils/testparm.c b/source/utils/testparm.c
index 22964214be4..c0e4f7606e0 100644
--- a/source/utils/testparm.c
+++ b/source/utils/testparm.c
@@ -186,7 +186,7 @@ via the %%o substitution. With encrypted passwords this is not possible.\n", lp_
return ret;
}
-int main(int argc, const char *argv[])
+ int main(int argc, const char *argv[])
{
const char *config_file = dyn_CONFIGFILE;
int s;
@@ -206,7 +206,7 @@ int main(int argc, const char *argv[])
{"verbose", 'v', POPT_ARG_NONE, &show_defaults, 1, "Show default options too"},
{"server", 'L',POPT_ARG_STRING, &new_local_machine, 0, "Set %%L macro to servername\n"},
{"encoding", 't', POPT_ARG_STRING, &term_code, 0, "Print parameters with encoding"},
- {NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version},
+ POPT_COMMON_SAMBA
{0,0,0,0}
};
diff --git a/source/web/swat.c b/source/web/swat.c
index 92dece6ecd9..9a133e1330d 100644
--- a/source/web/swat.c
+++ b/source/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);
diff --git a/source/wrepld/server.c b/source/wrepld/server.c
index 5203d337457..be9d86952d2 100644
--- a/source/wrepld/server.c
+++ b/source/wrepld/server.c
@@ -510,17 +510,13 @@ static void process(void)
static BOOL log_stdout = False;
struct poptOption long_options[] = {
POPT_AUTOHELP
- POPT_COMMON_SAMBA
- { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_socket_options },
- { 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_log_base },
{ "daemon", 'D', POPT_ARG_VAL, &is_daemon, True, "Become a daemon (default)" },
{ "foreground", 'F', POPT_ARG_VAL, &Fork, False, "Run daemon in foreground (for daemontools, etc)" },
{ "stdout", 'S', POPT_ARG_VAL, &log_stdout, True, "Log to stdout" },
{ "interactive", 'i', POPT_ARG_NONE, NULL, 'i', "Run interactive (not a daemon)" },
{ "port", 'p', POPT_ARG_INT, &wins_port, 'p', "Listen on the specified port" },
- { 0, 0, 0, 0 }
+ POPT_COMMON_SAMBA
+ POPT_TABLEEND
};
int opt;
poptContext pc;