diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/smb.h | 1 | ||||
-rw-r--r-- | source3/lib/popt_common.c | 60 | ||||
-rw-r--r-- | source3/utils/pdbedit.c | 26 |
3 files changed, 62 insertions, 25 deletions
diff --git a/source3/include/smb.h b/source3/include/smb.h index b5ab504415..7ce7599239 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -1664,5 +1664,6 @@ typedef struct { /* Common popt structures */ extern struct poptOption popt_common_debug[]; +extern struct poptOption popt_common_configfile[]; #endif /* _SMB_H */ diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c index bbc17cb704..1a63405b72 100644 --- a/source3/lib/popt_common.c +++ b/source3/lib/popt_common.c @@ -3,6 +3,7 @@ Common popt routines Copyright (C) Tim Potter 2001,2002 + Copyright (C) Jelmer Vernooij 2002 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 @@ -21,29 +22,76 @@ #include "includes.h" -/* Handle -d,--debuglevel command line option */ +/* Handle command line options: + * -d,--debuglevel + * -s,--configfile + * -O,--socket-options + */ -static void debug_callback(poptContext con, +extern pstring user_socket_options; +extern BOOL AllowDebugChange; +extern pstring global_myname; + +static void popt_common_callback(poptContext con, enum poptCallbackReason reason, const struct poptOption *opt, const char *arg, const void *data) { - extern BOOL AllowDebugChange; - switch(opt->val) { case 'd': if (arg) { debug_parse_levels(arg); AllowDebugChange = False; } + break; + case 'V': + printf( "Version %s\n", VERSION ); + exit(0); + break; + + case 'O': + pstrcpy(user_socket_options,arg); + break; + + case 's': + pstrcpy(dyn_CONFIGFILE, arg); + break; + + case 'n': + pstrcpy(global_myname,arg); + strupper(global_myname); break; } } struct poptOption popt_common_debug[] = { - { NULL, 0, POPT_ARG_CALLBACK, debug_callback }, - { "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", + { NULL, 0, POPT_ARG_CALLBACK, popt_common_callback }, + { "debuglevel", 'd', POPT_ARG_STRING, dyn_CONFIGFILE, 'd', "Set debug level", "DEBUGLEVEL" }, { 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 } +}; diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c index 6942779556..9508e6db7c 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -23,8 +23,6 @@ #include "includes.h" -#define BIT_CONFIGFILE 0x00000001 -#define BIT_DEBUGLEVEL 0x00000002 #define BIT_BACKEND 0x00000004 #define BIT_VERBOSE 0x00000008 #define BIT_SPSTYLE 0x00000010 @@ -53,7 +51,6 @@ #define MASK_ALWAYS_GOOD 0x0000001F #define MASK_USER_GOOD 0x00001F00 extern pstring global_myname; -extern BOOL AllowDebugChange; /********************************************************* Add all currently available users to another db @@ -450,8 +447,6 @@ int main (int argc, char **argv) static char *backend_out = NULL; static char *logon_script = NULL; static char *profile_path = NULL; - static char *config_file = dyn_CONFIGFILE; - static char *new_debuglevel = NULL; static char *account_policy = NULL; static long int account_policy_value = 0; BOOL account_policy_value_set = False; @@ -468,8 +463,8 @@ int main (int argc, char **argv) {"user", 'u', POPT_ARG_STRING, &user_name, 0, "use username", "USER" }, {"fullname", 'f', POPT_ARG_STRING, &full_name, 0, "set full name", NULL}, {"homedir", 'h', POPT_ARG_STRING, &home_dir, 0, "set home directory", NULL}, - {"drive", 'd', POPT_ARG_STRING, &home_drive, 0, "set home drive", NULL}, - {"script", 's', POPT_ARG_STRING, &logon_script, 0, "set logon script", NULL}, + {"drive", 'D', POPT_ARG_STRING, &home_drive, 0, "set home drive", NULL}, + {"script", 'S', POPT_ARG_STRING, &logon_script, 0, "set logon script", NULL}, {"profile", 'p', POPT_ARG_STRING, &profile_path, 0, "set profile path", NULL}, {"create", 'a', POPT_ARG_NONE, &add_user, 0, "create user", NULL}, {"modify", 'r', POPT_ARG_NONE, &modify_user, 0, "modify user", NULL}, @@ -478,10 +473,10 @@ int main (int argc, char **argv) {"backend", 'b', POPT_ARG_STRING, &backend, 0, "use different passdb backend as default backend", NULL}, {"import", 'i', POPT_ARG_STRING, &backend_in, 0, "import user accounts from this backend", NULL}, {"export", 'e', POPT_ARG_STRING, &backend_out, 0, "export user accounts to this backend", NULL}, - {"debuglevel", 'D', POPT_ARG_STRING, &new_debuglevel, 0,"set debuglevel",NULL}, - {"configfile", 'c', POPT_ARG_STRING, &config_file, 0,"use different configuration file",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}, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, + { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile }, {0,0,0,0} }; @@ -498,13 +493,8 @@ int main (int argc, char **argv) } } - if (new_debuglevel) { - debug_parse_levels(new_debuglevel); - AllowDebugChange = False; - } - - if (!lp_load(config_file,True,False,False)) { - fprintf(stderr, "Can't load %s - run testparm to debug it\n", config_file); + if (!lp_load(dyn_CONFIGFILE,True,False,False)) { + fprintf(stderr, "Can't load %s - run testparm to debug it\n", dyn_CONFIGFILE); exit(1); } @@ -519,9 +509,7 @@ int main (int argc, char **argv) strupper(global_myname); - setparms = (config_file ? BIT_CONFIGFILE : 0) + - (new_debuglevel ? BIT_DEBUGLEVEL : 0) + - (backend ? BIT_BACKEND : 0) + + setparms = (backend ? BIT_BACKEND : 0) + (verbose ? BIT_VERBOSE : 0) + (spstyle ? BIT_SPSTYLE : 0) + (full_name ? BIT_FULLNAME : 0) + |