[Pkg-shadow-commits] r2217 - in upstream/trunk: . src

nekral-guest at alioth.debian.org nekral-guest at alioth.debian.org
Sun Jul 27 01:16:14 UTC 2008


Author: nekral-guest
Date: 2008-07-27 01:16:13 +0000 (Sun, 27 Jul 2008)
New Revision: 2217

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/src/groupmems.c
Log:
	* src/groupmems.c: Reduce the number of checks. Isolate the
	parameters setting and permissions checking.


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2008-07-27 00:59:42 UTC (rev 2216)
+++ upstream/trunk/ChangeLog	2008-07-27 01:16:13 UTC (rev 2217)
@@ -1,5 +1,10 @@
 2008-07-27  Nicolas François  <nicolas.francois at centraliens.net>
 
+	* src/groupmems.c: Reduce the number of checks. Isolate the
+	parameters setting and permissions checking.
+
+2008-07-27  Nicolas François  <nicolas.francois at centraliens.net>
+
 	* src/groupmems.c: Add functions process_flags() and check_perms()
 	from code of main().
 	* src/groupmems.c: Harmonize the failure message in case of PAM

Modified: upstream/trunk/src/groupmems.c
===================================================================
--- upstream/trunk/src/groupmems.c	2008-07-27 00:59:42 UTC (rev 2216)
+++ upstream/trunk/src/groupmems.c	2008-07-27 01:16:13 UTC (rev 2217)
@@ -228,15 +228,18 @@
 
 	process_flags (argc, argv);
 
-	if (!isroot () && NULL != thisgroup) {
-		fputs (_("Only root can add members to different groups\n"),
-		       stderr);
-		exit (EXIT_NOT_ROOT);
-	} else if (isroot () && NULL != thisgroup) {
+	if (NULL == thisgroup) {
+		name = whoami ();
+		if (NULL == name) {
+			fprintf (stderr, _("%s: your groupname does not match your username\n"), Prog);
+			exit (EXIT_NOT_PRIMARY);
+		}
+	} else {
 		name = thisgroup;
-	} else if (NULL == (name = whoami ())) {
-		fputs (_("Not primary owner of current group\n"), stderr);
-		exit (EXIT_NOT_PRIMARY);
+		if (!isroot ()) {
+			fprintf (stderr, _("%s: only root can use the -g/--group option\n"), Prog);
+			exit (EXIT_NOT_ROOT);
+		}
 	}
 
 	check_perms ();




More information about the Pkg-shadow-commits mailing list