svn commit: samba r24599 - in branches/SAMBA_3_2/source: nmbd nsswitch smbd

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


Author: metze
Date: 2007-08-21 14:22:16 +0000 (Tue, 21 Aug 2007)
New Revision: 24599

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

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/source/nmbd/nmbd.c
   branches/SAMBA_3_2/source/nsswitch/winbindd.c
   branches/SAMBA_3_2/source/smbd/server.c


Changeset:
Modified: branches/SAMBA_3_2/source/nmbd/nmbd.c
===================================================================
--- branches/SAMBA_3_2/source/nmbd/nmbd.c	2007-08-21 14:10:22 UTC (rev 24598)
+++ branches/SAMBA_3_2/source/nmbd/nmbd.c	2007-08-21 14:22:16 UTC (rev 24599)
@@ -652,6 +652,7 @@
 	BOOL no_process_group = False;
 	BOOL log_stdout = False;
 	enum smb_server_mode server_mode = SERVER_MODE_DAEMON;
+	int opt;
 
 	struct poptOption long_options[] = {
 	POPT_AUTOHELP
@@ -674,7 +675,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/source/nsswitch/winbindd.c
===================================================================
--- branches/SAMBA_3_2/source/nsswitch/winbindd.c	2007-08-21 14:10:22 UTC (rev 24598)
+++ branches/SAMBA_3_2/source/nsswitch/winbindd.c	2007-08-21 14:22:16 UTC (rev 24599)
@@ -1012,10 +1012,16 @@
 
 	/* 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) {}
+	while ((opt = poptGetNextOpt(pc)) != -1) {
+		switch (opt) {
+		default:
+			d_fprintf(stderr, "\nInvalid option %s: %s\n",
+				  poptBadOption(pc, 0), poptStrerror(opt));
+			exit(1);
+		}
+	}
 
 	if (server_mode == SERVER_MODE_INTERACTIVE) {
 		log_stdout = True;

Modified: branches/SAMBA_3_2/source/smbd/server.c
===================================================================
--- branches/SAMBA_3_2/source/smbd/server.c	2007-08-21 14:10:22 UTC (rev 24598)
+++ branches/SAMBA_3_2/source/smbd/server.c	2007-08-21 14:22:16 UTC (rev 24599)
@@ -855,7 +855,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