summaryrefslogtreecommitdiff
path: root/source4/lib/cmdline
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-12-06 16:01:15 +0100
committerStefan Metzmacher <metze@samba.org>2007-12-21 05:48:20 +0100
commitfd1870e4f7370a184850e35a3d83157c664a79de (patch)
treeb69c0fa6d3005dc3572eb5a7b63bac514eff4ef7 /source4/lib/cmdline
parent1fbe268ec9a4d7367befd21e88f53781cd82cf1a (diff)
downloadsamba-fd1870e4f7370a184850e35a3d83157c664a79de.tar.gz
samba-fd1870e4f7370a184850e35a3d83157c664a79de.tar.bz2
samba-fd1870e4f7370a184850e35a3d83157c664a79de.zip
r26308: Split up big popt common callback function.
(This used to be commit bd2d6e0595c7ef897bbc6fdea50b96a7c1b94031)
Diffstat (limited to 'source4/lib/cmdline')
-rw-r--r--source4/lib/cmdline/popt_common.c83
-rw-r--r--source4/lib/cmdline/popt_credentials.c7
2 files changed, 58 insertions, 32 deletions
diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c
index 1eeb611256..b95dfdebc4 100644
--- a/source4/lib/cmdline/popt_common.c
+++ b/source4/lib/cmdline/popt_common.c
@@ -41,7 +41,19 @@ enum {OPT_OPTION=1,OPT_LEAK_REPORT,OPT_LEAK_REPORT_FULL,OPT_DEBUG_STDERR};
struct cli_credentials *cmdline_credentials = NULL;
-static void popt_common_callback(poptContext con,
+static void popt_version_callback(poptContext con,
+ enum poptCallbackReason reason,
+ const struct poptOption *opt,
+ const char *arg, const void *data)
+{
+ switch(opt->val) {
+ case 'V':
+ printf("Version %s\n", SAMBA_VERSION_STRING );
+ exit(0);
+ }
+}
+
+static void popt_samba_callback(poptContext con,
enum poptCallbackReason reason,
const struct poptOption *opt,
const char *arg, const void *data)
@@ -70,6 +82,7 @@ static void popt_common_callback(poptContext con,
pname++;
if (reason == POPT_CALLBACK_REASON_PRE) {
+
/* Hook for 'almost the first thing to do in a samba program' here */
/* setup for panics */
fault_setup(poptGetInvocationName(con));
@@ -81,6 +94,22 @@ static void popt_common_callback(poptContext con,
}
switch(opt->val) {
+
+ case OPT_LEAK_REPORT:
+ talloc_enable_leak_report();
+ break;
+
+ case OPT_LEAK_REPORT_FULL:
+ talloc_enable_leak_report_full();
+ break;
+
+ case OPT_OPTION:
+ if (!lp_set_option(lp_ctx, arg)) {
+ fprintf(stderr, "Error setting option '%s'\n", arg);
+ exit(1);
+ }
+ break;
+
case 'd':
lp_set_cmdline(lp_ctx, "log level", arg);
break;
@@ -89,16 +118,6 @@ static void popt_common_callback(poptContext con,
setup_logging(pname, DEBUG_STDERR);
break;
- case 'V':
- printf("Version %s\n", SAMBA_VERSION_STRING );
- exit(0);
-
- case 'O':
- if (arg) {
- lp_set_cmdline(lp_ctx, "socket options", arg);
- }
- break;
-
case 's':
if (arg) {
lp_load(arg, NULL);
@@ -112,7 +131,27 @@ static void popt_common_callback(poptContext con,
talloc_free(new_logfile);
}
break;
-
+
+
+ }
+
+}
+
+
+static void popt_common_callback(poptContext con,
+ enum poptCallbackReason reason,
+ const struct poptOption *opt,
+ const char *arg, const void *data)
+{
+ struct loadparm_context *lp_ctx = global_loadparm; /* FIXME: allow overriding */
+
+ switch(opt->val) {
+ case 'O':
+ if (arg) {
+ lp_set_cmdline(lp_ctx, "socket options", arg);
+ }
+ break;
+
case 'W':
lp_set_cmdline(lp_ctx, "workgroup", arg);
break;
@@ -137,19 +176,8 @@ static void popt_common_callback(poptContext con,
lp_set_cmdline(lp_ctx, "name resolve order", arg);
break;
- case OPT_OPTION:
- if (!lp_set_option(lp_ctx, arg)) {
- fprintf(stderr, "Error setting option '%s'\n", arg);
- exit(1);
- }
- break;
-
- case OPT_LEAK_REPORT:
- talloc_enable_leak_report();
- break;
-
- case OPT_LEAK_REPORT_FULL:
- talloc_enable_leak_report_full();
+ case 'S':
+ lp_set_cmdline(lp_ctx, "client signing", arg);
break;
}
@@ -160,6 +188,7 @@ struct poptOption popt_common_connection[] = {
{ "name-resolve", 'R', POPT_ARG_STRING, NULL, 'R', "Use these name resolution services only", "NAME-RESOLVE-ORDER" },
{ "socket-options", 'O', POPT_ARG_STRING, NULL, 'O', "socket options to use", "SOCKETOPTIONS" },
{ "netbiosname", 'n', POPT_ARG_STRING, NULL, 'n', "Primary netbios name", "NETBIOSNAME" },
+ { "signing", 'S', POPT_ARG_STRING, NULL, 'S', "Set the client signing state", "on|off|required" },
{ "workgroup", 'W', POPT_ARG_STRING, NULL, 'W', "Set the workgroup name", "WORKGROUP" },
{ "realm", 0, POPT_ARG_STRING, NULL, 'r', "Set the realm name", "REALM" },
{ "scope", 'i', POPT_ARG_STRING, NULL, 'i', "Use this Netbios scope", "SCOPE" },
@@ -168,7 +197,7 @@ struct poptOption popt_common_connection[] = {
};
struct poptOption popt_common_samba[] = {
- { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, (void *)popt_common_callback },
+ { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, (void *)popt_samba_callback },
{ "debuglevel", 'd', POPT_ARG_STRING, NULL, 'd', "Set debug level", "DEBUGLEVEL" },
{ "debug-stderr", 0, POPT_ARG_NONE, NULL, OPT_DEBUG_STDERR, "Send debug output to STDERR", NULL },
{ "configfile", 's', POPT_ARG_STRING, NULL, 's', "Use alternative configuration file", "CONFIGFILE" },
@@ -180,7 +209,7 @@ struct poptOption popt_common_samba[] = {
};
struct poptOption popt_common_version[] = {
- { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_POST, (void *)popt_common_callback },
+ { NULL, 0, POPT_ARG_CALLBACK, (void *)popt_version_callback },
{ "version", 'V', POPT_ARG_NONE, NULL, 'V', "Print version" },
{ NULL }
};
diff --git a/source4/lib/cmdline/popt_credentials.c b/source4/lib/cmdline/popt_credentials.c
index 03142a7602..25c9a2e5ff 100644
--- a/source4/lib/cmdline/popt_credentials.c
+++ b/source4/lib/cmdline/popt_credentials.c
@@ -54,6 +54,8 @@ static void popt_common_credentials_callback(poptContext con,
const struct poptOption *opt,
const char *arg, const void *data)
{
+ struct cli_credentials *creds = data;
+
if (reason == POPT_CALLBACK_REASON_PRE) {
cmdline_credentials = cli_credentials_init(talloc_autofree_context());
return;
@@ -94,10 +96,6 @@ static void popt_common_credentials_callback(poptContext con,
cli_credentials_parse_file(cmdline_credentials, arg, CRED_SPECIFIED);
break;
- case 'S':
- lp_set_cmdline(global_loadparm, "client signing", arg);
- break;
-
case 'P':
/* Later, after this is all over, get the machine account details from the secrets.ldb */
cli_credentials_set_machine_account_pending(cmdline_credentials);
@@ -136,7 +134,6 @@ struct poptOption popt_common_credentials[] = {
{ "no-pass", 'N', POPT_ARG_NONE, &dont_ask, 'N', "Don't ask for a password" },
{ "password", 0, POPT_ARG_STRING, NULL, OPT_PASSWORD, "Password" },
{ "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" },
- { "signing", 'S', POPT_ARG_STRING, NULL, 'S', "Set the client signing state", "on|off|required" },
{ "machine-pass", 'P', POPT_ARG_NONE, NULL, 'P', "Use stored machine account password (implies -k)" },
{ "simple-bind-dn", 0, POPT_ARG_STRING, NULL, OPT_SIMPLE_BIND_DN, "DN to use for a simple bind" },
{ "kerberos", 'k', POPT_ARG_STRING, NULL, OPT_KERBEROS, "Use Kerberos" },