[Pkg-shadow-commits] r2849 - in upstream/trunk: . lib libmisc src

Nicolas FRANÇOIS nekral-guest at alioth.debian.org
Thu Apr 30 21:08:49 UTC 2009


Author: nekral-guest
Date: 2009-04-30 21:08:49 +0000 (Thu, 30 Apr 2009)
New Revision: 2849

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/lib/encrypt.c
   upstream/trunk/lib/exitcodes.h
   upstream/trunk/libmisc/audit_help.c
   upstream/trunk/libmisc/chowntty.c
   upstream/trunk/libmisc/limits.c
   upstream/trunk/libmisc/rlogin.c
   upstream/trunk/libmisc/sub.c
   upstream/trunk/libmisc/sulog.c
   upstream/trunk/libmisc/system.c
   upstream/trunk/src/groups.c
   upstream/trunk/src/id.c
   upstream/trunk/src/logoutd.c
   upstream/trunk/src/newusers.c
Log:
	* lib/exitcodes.h: Define E_SUCCESS as EXIT_SUCCESS. Added FIXMEs.
	* libmisc/chowntty.c, libmisc/rlogin.c, libmisc/sub.c,
	src/newusers.c, libmisc/sulog.c, libmisc/system.c, src/logoutd.c,
	src/groups.c, src/id.c, lib/encrypt.c, libmisc/audit_help.c,
	libmisc/limits.c: Return EXIT_FAILURE instead of 1, and
	EXIT_SUCCESS instead of 0.
	* libmisc/audit_help.c: Replace an fprintf() by fputs().
	* libmisc/audit_help.c: Remove documentation of the audit_logger
	returned values. The function returns void.
	* libmisc/system.c: Only return status if waitpid succeeded.
	Return -1 otherwise.


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2009-04-28 22:04:41 UTC (rev 2848)
+++ upstream/trunk/ChangeLog	2009-04-30 21:08:49 UTC (rev 2849)
@@ -1,3 +1,17 @@
+2009-04-30  Nicolas François  <nicolas.francois at centraliens.net>
+
+	* lib/exitcodes.h: Define E_SUCCESS as EXIT_SUCCESS. Added FIXMEs.
+	* libmisc/chowntty.c, libmisc/rlogin.c, libmisc/sub.c,
+	src/newusers.c, libmisc/sulog.c, libmisc/system.c, src/logoutd.c,
+	src/groups.c, src/id.c, lib/encrypt.c, libmisc/audit_help.c,
+	libmisc/limits.c: Return EXIT_FAILURE instead of 1, and
+	EXIT_SUCCESS instead of 0.
+	* libmisc/audit_help.c: Replace an fprintf() by fputs().
+	* libmisc/audit_help.c: Remove documentation of the audit_logger
+	returned values. The function returns void.
+	* libmisc/system.c: Only return status if waitpid succeeded.
+	Return -1 otherwise.
+
 2009-04-28  Nicolas François  <nicolas.francois at centraliens.net>
 
 	* NEWS, src/chpasswd.c: Added support for changing the passwords

Modified: upstream/trunk/lib/encrypt.c
===================================================================
--- upstream/trunk/lib/encrypt.c	2009-04-28 22:04:41 UTC (rev 2848)
+++ upstream/trunk/lib/encrypt.c	2009-04-30 21:08:49 UTC (rev 2849)
@@ -53,7 +53,7 @@
 		 * expect us to return NULL, so...
 		 */
 		perror ("crypt");
-		exit (1);
+		exit (EXIT_FAILURE);
 	}
 
 	/* The GNU crypt does not return NULL if the algorithm is not
@@ -82,11 +82,13 @@
 		fprintf (stderr,
 			 _("crypt method not supported by libcrypt? (%s)\n"),
 			  method);
-		exit (1);
+		exit (EXIT_FAILURE);
 	}
 
-	if (strlen (cp) != 13)
+	if (strlen (cp) != 13) {
 		return cp;	/* nonstandard crypt() in libc, better bail out */
+	}
+
 	strcpy (cipher, cp);
 
 	return cipher;

Modified: upstream/trunk/lib/exitcodes.h
===================================================================
--- upstream/trunk/lib/exitcodes.h	2009-04-28 22:04:41 UTC (rev 2848)
+++ upstream/trunk/lib/exitcodes.h	2009-04-30 21:08:49 UTC (rev 2849)
@@ -32,7 +32,12 @@
 /*
  * Exit codes used by shadow programs
  */
-#define E_SUCCESS       	0	/* success */
+#define E_SUCCESS       	EXIT_SUCCESS	/* success */
+/*
+ * FIXME: other values should differ from EXIT_FAILURE (and EXIT_SUCCESS).
+ *
+ * FIXME: reserve EXIT_FAILURE for internal failures.
+ */
 #define E_NOPERM        	1	/* permission denied */
 #define E_USAGE         	2	/* invalid command syntax */
 #define E_BAD_ARG       	3	/* invalid argument to option */

Modified: upstream/trunk/libmisc/audit_help.c
===================================================================
--- upstream/trunk/libmisc/audit_help.c	2009-04-28 22:04:41 UTC (rev 2848)
+++ upstream/trunk/libmisc/audit_help.c	2009-04-30 21:08:49 UTC (rev 2849)
@@ -53,12 +53,14 @@
 	if (audit_fd < 0) {
 		/* You get these only when the kernel doesn't have
 		 * audit compiled in. */
-		if (errno == EINVAL || errno == EPROTONOSUPPORT ||
-		    errno == EAFNOSUPPORT)
+		if (   (errno == EINVAL)
+		    || (errno == EPROTONOSUPPORT)
+		    || (errno == EAFNOSUPPORT)) {
 			return;
-		fprintf (stderr,
-		         _("Cannot open audit interface - aborting.\n"));
-		exit (1);
+		}
+		(void) fputs (_("Cannot open audit interface - aborting.\n"),
+		              stderr);
+		exit (EXIT_FAILURE);
 	}
 }
 
@@ -73,7 +75,6 @@
  * name - user's account or group name. If not available use NULL.
  * id  -  uid or gid that the operation is being performed on. This is used
  *	  only when user is NULL.
- * result - 1 is "success" and 0 is "failed"
  */
 void audit_logger (int type, const char *pgname, const char *op,
                    const char *name, unsigned int id,

Modified: upstream/trunk/libmisc/chowntty.c
===================================================================
--- upstream/trunk/libmisc/chowntty.c	2009-04-28 22:04:41 UTC (rev 2848)
+++ upstream/trunk/libmisc/chowntty.c	2009-04-30 21:08:49 UTC (rev 2849)
@@ -83,7 +83,7 @@
 		         info->pw_name, strerror (err)));
 		if (EROFS != err) {
 			closelog ();
-			exit (1);
+			exit (EXIT_FAILURE);
 		}
 	}
 #ifdef __linux__

Modified: upstream/trunk/libmisc/limits.c
===================================================================
--- upstream/trunk/libmisc/limits.c	2009-04-28 22:04:41 UTC (rev 2848)
+++ upstream/trunk/libmisc/limits.c	2009-04-30 21:08:49 UTC (rev 2849)
@@ -436,7 +436,7 @@
 			    LOGIN_ERROR_LOGIN) {
 				(void) fputs (_("Too many logins.\n"), stderr);
 				(void) sleep (2); /* XXX: Should be FAIL_DELAY */
-				exit (1);
+				exit (EXIT_FAILURE);
 			}
 		}
 #endif

Modified: upstream/trunk/libmisc/rlogin.c
===================================================================
--- upstream/trunk/libmisc/rlogin.c	2009-04-28 22:04:41 UTC (rev 2848)
+++ upstream/trunk/libmisc/rlogin.c	2009-04-30 21:08:49 UTC (rev 2849)
@@ -114,7 +114,7 @@
 {
 	for (;;) {
 		if (read (0, buf, 1) != 1) {
-			exit (1);
+			exit (EXIT_FAILURE);
 		}
 		if ('\0' == *buf) {
 			return;

Modified: upstream/trunk/libmisc/sub.c
===================================================================
--- upstream/trunk/libmisc/sub.c	2009-04-28 22:04:41 UTC (rev 2848)
+++ upstream/trunk/libmisc/sub.c	2009-04-30 21:08:49 UTC (rev 2849)
@@ -58,7 +58,7 @@
 		printf (_("Invalid root directory '%s'\n"), pw->pw_dir);
 		SYSLOG ((LOG_WARN, BAD_SUBROOT2, pw->pw_dir, pw->pw_name));
 		closelog ();
-		exit (1);
+		exit (EXIT_FAILURE);
 	}
 
 	/*
@@ -71,6 +71,6 @@
 			pw->pw_dir);
 		SYSLOG ((LOG_WARN, NO_SUBROOT2, pw->pw_dir, pw->pw_name));
 		closelog ();
-		exit (1);
+		exit (EXIT_FAILURE);
 	}
 }

Modified: upstream/trunk/libmisc/sulog.c
===================================================================
--- upstream/trunk/libmisc/sulog.c	2009-04-28 22:04:41 UTC (rev 2848)
+++ upstream/trunk/libmisc/sulog.c	2009-04-30 21:08:49 UTC (rev 2849)
@@ -83,7 +83,7 @@
 		         "can't switch back to group `%d' in sulog",
 		         oldgid));
 		/* Do not return if the group permission were raised. */
-		exit (1);
+		exit (EXIT_FAILURE);
 	}
 	if (fp == (FILE *) 0) {
 		return;		/* can't open or create logfile */

Modified: upstream/trunk/libmisc/system.c
===================================================================
--- upstream/trunk/libmisc/system.c	2009-04-28 22:04:41 UTC (rev 2848)
+++ upstream/trunk/libmisc/system.c	2009-04-30 21:08:49 UTC (rev 2849)
@@ -51,8 +51,11 @@
 	}
 
 	if (pid) {       /* Parent */
-		waitpid (pid, &status, 0);
-		return status;
+		if (waitpid (pid, &status, 0) > 0) {
+			return status;
+		} else {
+			return -1;
+		}
 	}
 
 	fd = open ("/dev/null", O_RDWR);
@@ -64,6 +67,6 @@
 
 	execve (command, (char *const *) argv, (char *const *) env);
 	fprintf (stderr, _("Failed to exec '%s'\n"), argv[0]);
-	exit (-1);
+	exit (EXIT_FAILURE);
 }
 

Modified: upstream/trunk/src/groups.c
===================================================================
--- upstream/trunk/src/groups.c	2009-04-28 22:04:41 UTC (rev 2848)
+++ upstream/trunk/src/groups.c	2009-04-30 21:08:49 UTC (rev 2849)
@@ -64,7 +64,7 @@
 	if (NULL == pwd) {
 		(void) fprintf (stderr, _("%s: unknown user %s\n"),
 		                Prog, member);
-		exit (1);
+		exit (EXIT_FAILURE);
 	}
 
 	setgrent ();
@@ -146,7 +146,7 @@
 		ngroups = getgroups (sys_ngroups, groups);
 		if (ngroups < 0) {
 			perror ("getgroups");
-			exit (1);
+			exit (EXIT_FAILURE);
 		}
 
 		/*
@@ -203,7 +203,7 @@
 		if (NULL != logname) {
 			print_groups (logname);
 		} else {
-			exit (1);
+			exit (EXIT_FAILURE);
 		}
 #endif
 	} else {
@@ -214,6 +214,6 @@
 		 */
 		print_groups (argv[1]);
 	}
-	exit (0);
+	return EXIT_SUCCESS;
 }
 

Modified: upstream/trunk/src/id.c
===================================================================
--- upstream/trunk/src/id.c	2009-04-28 22:04:41 UTC (rev 2848)
+++ upstream/trunk/src/id.c	2009-04-30 21:08:49 UTC (rev 2849)
@@ -57,7 +57,7 @@
 #else
 	(void) fputs (_("Usage: id\n"), stderr);
 #endif
-	exit (1);
+	exit (EXIT_FAILURE);
 }
 
  /*ARGSUSED*/ int main (int argc, char **argv)
@@ -201,7 +201,7 @@
 	 * Finish off the line.
 	 */
 	(void) putchar ('\n');
-	exit (0);
-	/* NOT REACHED */
+
+	return EXIT_SUCCESS;
 }
 

Modified: upstream/trunk/src/logoutd.c
===================================================================
--- upstream/trunk/src/logoutd.c	2009-04-28 22:04:41 UTC (rev 2848)
+++ upstream/trunk/src/logoutd.c	2009-04-30 21:08:49 UTC (rev 2849)
@@ -175,11 +175,11 @@
 	pid = fork ();
 	if (pid > 0) {
 		/* parent */
-		exit (0);
+		exit (EXIT_SUCCESS);
 	} else if (pid < 0) {
 		/* error */
 		perror ("fork");
-		exit (1);
+		exit (EXIT_FAILURE);
 	}
 #endif				/* !DEBUG */
 
@@ -276,7 +276,7 @@
 			/*
 			 * This child has done all it can, drop dead.
 			 */
-			exit (0);
+			exit (EXIT_SUCCESS);
 		}
 
 #ifdef USE_UTMPX
@@ -293,7 +293,7 @@
 		 */
 		while (wait (&status) != -1);
 	}
-	return 1;
-	/* NOT REACHED */
+
+	return EXIT_FAILURE;
 }
 

Modified: upstream/trunk/src/newusers.c
===================================================================
--- upstream/trunk/src/newusers.c	2009-04-28 22:04:41 UTC (rev 2848)
+++ upstream/trunk/src/newusers.c	2009-04-30 21:08:49 UTC (rev 2849)
@@ -126,7 +126,7 @@
 	                   "                                crypt algorithms\n")
 #endif
 	                 );
-	exit (1);
+	exit (EXIT_FAILURE);
 }
 
 /*
@@ -529,7 +529,7 @@
 			char buf[BUFSIZ];
 			snprintf (buf, sizeof buf, "%s: %s", Prog, argv[1]);
 			perror (buf);
-			fail_exit (1);
+			fail_exit (EXIT_FAILURE);
 		}
 	}
 
@@ -593,7 +593,7 @@
 		fprintf (stderr,
 		         _("%s: Cannot determine your user name.\n"),
 		         Prog);
-		fail_exit (1);
+		fail_exit (EXIT_FAILURE);
 	}
 
 	retval = pam_start ("newusers", pampw->pw_name, &conv, &pamh);
@@ -611,7 +611,7 @@
 	}
 	if (PAM_SUCCESS != retval) {
 		fprintf (stderr, _("%s: PAM authentication failed\n"), Prog);
-		fail_exit (1);
+		fail_exit (EXIT_FAILURE);
 	}
 #endif				/* USE_PAM */
 #endif				/* ACCT_TOOLS_SETUID */
@@ -632,7 +632,7 @@
 		fprintf (stderr,
 		         _("%s: cannot lock %s; try again later.\n"),
 		         Prog, pw_dbname ());
-		fail_exit (1);
+		fail_exit (EXIT_FAILURE);
 	}
 	pw_locked = true;
 	if (is_shadow) {
@@ -640,7 +640,7 @@
 			fprintf (stderr,
 			         _("%s: cannot lock %s; try again later.\n"),
 			         Prog, spw_dbname ());
-			fail_exit (1);
+			fail_exit (EXIT_FAILURE);
 		}
 		spw_locked = true;
 	}
@@ -648,7 +648,7 @@
 		fprintf (stderr,
 		         _("%s: cannot lock %s; try again later.\n"),
 		         Prog, gr_dbname ());
-		fail_exit (1);
+		fail_exit (EXIT_FAILURE);
 	}
 	gr_locked = true;
 #ifdef SHADOWGRP
@@ -657,7 +657,7 @@
 			fprintf (stderr,
 			         _("%s: cannot lock %s; try again later.\n"),
 			         Prog, sgr_dbname ());
-			fail_exit (1);
+			fail_exit (EXIT_FAILURE);
 		}
 		sgr_locked = true;
 	}
@@ -665,20 +665,20 @@
 
 	if (pw_open (O_RDWR) == 0) {
 		fprintf (stderr, _("%s: cannot open %s\n"), Prog, pw_dbname ());
-		fail_exit (1);
+		fail_exit (EXIT_FAILURE);
 	}
 	if (is_shadow && (spw_open (O_RDWR) == 0)) {
 		fprintf (stderr, _("%s: cannot open %s\n"), Prog, spw_dbname ());
-		fail_exit (1);
+		fail_exit (EXIT_FAILURE);
 	}
 	if (gr_open (O_RDWR) == 0) {
 		fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
-		fail_exit (1);
+		fail_exit (EXIT_FAILURE);
 	}
 #ifdef SHADOWGRP
 	if (is_shadow_grp && (sgr_open (O_RDWR) == 0)) {
 		fprintf (stderr, _("%s: cannot open %s\n"), Prog, sgr_dbname ());
-		fail_exit (1);
+		fail_exit (EXIT_FAILURE);
 	}
 #endif
 }
@@ -691,7 +691,7 @@
 	if (pw_close () == 0) {
 		fprintf (stderr, _("%s: failure while writing changes to %s\n"), Prog, pw_dbname ());
 		SYSLOG ((LOG_ERR, "failure while writing changes to %s", pw_dbname ()));
-		fail_exit (1);
+		fail_exit (EXIT_FAILURE);
 	}
 	if (pw_unlock () == 0) {
 		fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
@@ -706,7 +706,7 @@
 			         _("%s: failure while writing changes to %s\n"),
 			         Prog, spw_dbname ());
 			SYSLOG ((LOG_ERR, "failure while writing changes to %s", spw_dbname ()));
-			fail_exit (1);
+			fail_exit (EXIT_FAILURE);
 		}
 		if (spw_unlock () == 0) {
 			fprintf (stderr,
@@ -723,7 +723,7 @@
 		         _("%s: failure while writing changes to %s\n"),
 		         Prog, gr_dbname ());
 		SYSLOG ((LOG_ERR, "failure while writing changes to %s", gr_dbname ()));
-		fail_exit (1);
+		fail_exit (EXIT_FAILURE);
 	}
 	if (gr_unlock () == 0) {
 		fprintf (stderr,
@@ -741,7 +741,7 @@
 			         _("%s: failure while writing changes to %s\n"),
 			         Prog, sgr_dbname ());
 			SYSLOG ((LOG_ERR, "failure while writing changes to %s", sgr_dbname ()));
-			fail_exit (1);
+			fail_exit (EXIT_FAILURE);
 		}
 		if (sgr_unlock () == 0) {
 			fprintf (stderr,
@@ -963,7 +963,7 @@
 	if (0 != errors) {
 		fprintf (stderr,
 		         _("%s: error detected, changes ignored\n"), Prog);
-		fail_exit (1);
+		fail_exit (EXIT_FAILURE);
 	}
 
 	close_files ();
@@ -971,6 +971,6 @@
 	nscd_flush_cache ("passwd");
 	nscd_flush_cache ("group");
 
-	return 0;
+	return EXIT_SUCCESS;
 }
 




More information about the Pkg-shadow-commits mailing list