1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

Patch from metze to generalise POPT_COMMON_SAMBA, with some minor changes

(This used to be commit 2ddfed298d)
This commit is contained in:
Jelmer Vernooij 2003-03-24 11:25:34 +00:00
parent 2238286425
commit 11e9de855c
20 changed files with 95 additions and 357 deletions

View File

@ -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;

View File

@ -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;
};

View File

@ -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
};

View File

@ -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;

View File

@ -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 */

View File

@ -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;

View File

@ -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;

View File

@ -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 }
};

View File

@ -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;

View File

@ -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;

View File

@ -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}
};

View File

@ -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 }
};

View File

@ -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 */

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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}
};

View File

@ -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);

View File

@ -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;