svn commit: samba r24600 - in branches/SAMBA_3_2_0/source: nmbd nsswitch smbd

metze at samba.org metze at samba.org
Tue Aug 21 14:42:14 GMT 2007


Author: metze
Date: 2007-08-21 14:42:13 +0000 (Tue, 21 Aug 2007)
New Revision: 24600

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24600

Log:
patch from Karolin Seeger <ks at sernet.de>:

smbd, nmbd and winbindd can be started with invalid options currently.
The first patch attached would be a possible solution.
It contains an exit if an invalid option has been used. The main problem
is, that existing setups with wrong options or missing arguments in start
scripts will break (which is the right behaviour from my point of view).

metze
Modified:
   branches/SAMBA_3_2_0/source/nmbd/nmbd.c
   branches/SAMBA_3_2_0/source/nsswitch/winbindd.c
   branches/SAMBA_3_2_0/source/smbd/server.c


Changeset:
Modified: branches/SAMBA_3_2_0/source/nmbd/nmbd.c
===================================================================
--- branches/SAMBA_3_2_0/source/nmbd/nmbd.c	2007-08-21 14:22:16 UTC (rev 24599)
+++ branches/SAMBA_3_2_0/source/nmbd/nmbd.c	2007-08-21 14:42:13 UTC (rev 24600)
@@ -659,6 +659,7 @@
 	poptContext pc;
 	static char *p_lmhosts = dyn_LMHOSTSFILE;
 	static BOOL no_process_group = False;
+	int opt;
 	struct poptOption long_options[] = {
 	POPT_AUTOHELP
 	{"daemon", 'D', POPT_ARG_VAL, &is_daemon, True, "Become a daemon(default)" },
@@ -677,7 +678,14 @@
 	global_nmb_port = NMB_PORT;
 
 	pc = poptGetContext("nmbd", argc, argv, long_options, 0);
-	while (poptGetNextOpt(pc) != -1) {};
+	while ((opt = poptGetNextOpt(pc)) != -1) {
+		switch (opt) {
+		default:
+			d_fprintf(stderr, "\nInvalid option %s: %s\n",
+				  poptBadOption(pc, 0), poptStrerror(opt));
+			exit(1);
+		}
+	};
 	poptFreeContext(pc);
 
 	global_in_nmbd = True;

Modified: branches/SAMBA_3_2_0/source/nsswitch/winbindd.c
===================================================================
--- branches/SAMBA_3_2_0/source/nsswitch/winbindd.c	2007-08-21 14:22:16 UTC (rev 24599)
+++ branches/SAMBA_3_2_0/source/nsswitch/winbindd.c	2007-08-21 14:42:13 UTC (rev 24600)
@@ -975,8 +975,7 @@
 
 	/* Initialise samba/rpc client stuff */
 
-	pc = poptGetContext("winbindd", argc, (const char **)argv, long_options,
-						POPT_CONTEXT_KEEP_FIRST);
+	pc = poptGetContext("winbindd", argc, (const char **)argv, long_options, 0);
 
 	while ((opt = poptGetNextOpt(pc)) != -1) {
 		switch (opt) {
@@ -986,10 +985,13 @@
 			log_stdout = True;
 			Fork = False;
 			break;
+		default:
+			d_fprintf(stderr, "\nInvalid option %s: %s\n",
+				  poptBadOption(pc, 0), poptStrerror(opt));
+			exit(1);
 		}
 	}
 
-
 	if (log_stdout && Fork) {
 		printf("Can't log to stdout (-S) unless daemon is in foreground +(-F) or interactive (-i)\n");
 		poptPrintUsage(pc, stderr, 0);

Modified: branches/SAMBA_3_2_0/source/smbd/server.c
===================================================================
--- branches/SAMBA_3_2_0/source/smbd/server.c	2007-08-21 14:22:16 UTC (rev 24599)
+++ branches/SAMBA_3_2_0/source/smbd/server.c	2007-08-21 14:42:13 UTC (rev 24600)
@@ -892,7 +892,10 @@
 		case 'b':
 			build_options(True); /* Display output to screen as well as debug */ 
 			exit(0);
-			break;
+		default:
+			d_fprintf(stderr, "\nInvalid option %s: %s\n",
+				  poptBadOption(pc, 0), poptStrerror(opt));
+			exit(1);
 		}
 	}
 



More information about the samba-cvs mailing list