svn commit: samba r26308 - in branches/SAMBA_4_0: .
source/lib/cmdline
jelmer at samba.org
jelmer at samba.org
Thu Dec 6 16:01:17 GMT 2007
Author: jelmer
Date: 2007-12-06 16:01:15 +0000 (Thu, 06 Dec 2007)
New Revision: 26308
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=26308
Log:
Split up big popt common callback function.
Modified:
branches/SAMBA_4_0/
branches/SAMBA_4_0/source/lib/cmdline/popt_common.c
branches/SAMBA_4_0/source/lib/cmdline/popt_credentials.c
Changeset:
Property changes on: branches/SAMBA_4_0
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...
Modified: branches/SAMBA_4_0/source/lib/cmdline/popt_common.c
===================================================================
--- branches/SAMBA_4_0/source/lib/cmdline/popt_common.c 2007-12-06 15:06:36 UTC (rev 26307)
+++ branches/SAMBA_4_0/source/lib/cmdline/popt_common.c 2007-12-06 16:01:15 UTC (rev 26308)
@@ -41,11 +41,23 @@
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)
+{
const char *pname;
struct loadparm_context *lp_ctx = global_loadparm; /* FIXME: allow overriding */
@@ -70,6 +82,7 @@
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 @@
}
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 @@
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 @@
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,21 +176,10 @@
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);
- }
+ case 'S':
+ lp_set_cmdline(lp_ctx, "client signing", arg);
break;
- case OPT_LEAK_REPORT:
- talloc_enable_leak_report();
- break;
-
- case OPT_LEAK_REPORT_FULL:
- talloc_enable_leak_report_full();
- break;
-
}
}
@@ -160,6 +188,7 @@
{ "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_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_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 }
};
Modified: branches/SAMBA_4_0/source/lib/cmdline/popt_credentials.c
===================================================================
--- branches/SAMBA_4_0/source/lib/cmdline/popt_credentials.c 2007-12-06 15:06:36 UTC (rev 26307)
+++ branches/SAMBA_4_0/source/lib/cmdline/popt_credentials.c 2007-12-06 16:01:15 UTC (rev 26308)
@@ -54,6 +54,8 @@
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 @@
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 @@
{ "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" },
More information about the samba-cvs
mailing list