* 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.
This commit is contained in:
nekral-guest
2009-04-30 21:08:49 +00:00
parent 0f448edf19
commit a326ffa435
14 changed files with 74 additions and 49 deletions

View File

@@ -53,12 +53,14 @@ void audit_help_open (void)
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 @@ void audit_help_open (void)
* 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,

View File

@@ -83,7 +83,7 @@ void chown_tty (const struct passwd *info)
info->pw_name, strerror (err)));
if (EROFS != err) {
closelog ();
exit (1);
exit (EXIT_FAILURE);
}
}
#ifdef __linux__

View File

@@ -436,7 +436,7 @@ void setup_limits (const struct passwd *info)
LOGIN_ERROR_LOGIN) {
(void) fputs (_("Too many logins.\n"), stderr);
(void) sleep (2); /* XXX: Should be FAIL_DELAY */
exit (1);
exit (EXIT_FAILURE);
}
}
#endif

View File

@@ -114,7 +114,7 @@ static void get_remote_string (char *buf, size_t size)
{
for (;;) {
if (read (0, buf, 1) != 1) {
exit (1);
exit (EXIT_FAILURE);
}
if ('\0' == *buf) {
return;

View File

@@ -58,7 +58,7 @@ void subsystem (const struct passwd *pw)
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 @@ void subsystem (const struct passwd *pw)
pw->pw_dir);
SYSLOG ((LOG_WARN, NO_SUBROOT2, pw->pw_dir, pw->pw_name));
closelog ();
exit (1);
exit (EXIT_FAILURE);
}
}

View File

@@ -83,7 +83,7 @@ void sulog (const char *tty, bool success, const char *oldname, const char *name
"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 */

View File

@@ -51,8 +51,11 @@ int safe_system (const char *command,
}
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 @@ int safe_system (const char *command,
execve (command, (char *const *) argv, (char *const *) env);
fprintf (stderr, _("Failed to exec '%s'\n"), argv[0]);
exit (-1);
exit (EXIT_FAILURE);
}