[Pkg-shadow-devel] patch for su (needed by the switch to getopt in 4.0.14)

Nicolas François nicolas.francois at centraliens.net
Fri Dec 9 22:46:40 UTC 2005


Hello Thomasz,

While looking at the 437_ patches, I found this, which applies to your
CVS.

argc used to get decremented. It is not anymore (since your switch to
getopt). Now, optind must be compared to argc.

Maybe this bloc of code should be moved earclier in order to put all the
options parsing in the same place.

Best Regards,
-- 
Nekral
-------------- next part --------------
Index: src/su.c
===================================================================
RCS file: /cvsroot/shadow/src/su.c,v
retrieving revision 1.51
diff -u -r1.51 su.c
--- src/su.c	5 Dec 2005 18:19:47 -0000	1.51
+++ src/su.c	9 Dec 2005 22:35:39 -0000
@@ -396,15 +396,13 @@
 	 * doesn't start with a "-" unless you specify the new user name.
 	 * Any remaining arguments will be passed to the user's login shell.
 	 */
-	if (argc > 0 && argv[0][0] != '-') {
-		STRFCPY (name, argv[0]);	/* use this login id */
-		argc--;
-		argv++;		/* shift ... */
+	if (optind < argc && argv[optind][0] != '-') {
+		STRFCPY (name, argv[optind++]);	/* use this login id */
 	}
 	if (!name[0])		/* use default user ID */
 		(void) strcpy (name, "root");
 
-	doshell = argc == 0;	/* any arguments remaining? */
+	doshell = optind == argc;	/* any arguments remaining? */
 
 	/*
 	 * Get the user's real name. The current UID is used to determine


More information about the Pkg-shadow-devel mailing list