summaryrefslogtreecommitdiffstats
path: root/login-utils/su.c
diff options
context:
space:
mode:
authorJim Meyering2004-01-22 22:00:25 +0100
committerJim Meyering2004-01-22 22:00:25 +0100
commit12f1e56dd3f486b3cac757012c5edfd8dfedd843 (patch)
treefb6ec93bb76f41d6885aada98964bde759c08015 /login-utils/su.c
parentMost .c files (AUTHORS): Revert the WRITTEN_BY/AUTHORS change (diff)
downloadkernel-qcow2-util-linux-12f1e56dd3f486b3cac757012c5edfd8dfedd843.tar.gz
kernel-qcow2-util-linux-12f1e56dd3f486b3cac757012c5edfd8dfedd843.tar.xz
kernel-qcow2-util-linux-12f1e56dd3f486b3cac757012c5edfd8dfedd843.zip
(usage): Use EXIT_SUCCESS, not 0, for clarity.
(main): Initialize exit_failure to EXIT_FAIL. (main): Use EXIT_ENOENT and EXIT_CANNOT_INVOKE rather than roll-your-own symbols or integers.
Diffstat (limited to 'login-utils/su.c')
-rw-r--r--login-utils/su.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/login-utils/su.c b/login-utils/su.c
index 3bcc87abd..d15d96a93 100644
--- a/login-utils/su.c
+++ b/login-utils/su.c
@@ -1,5 +1,5 @@
/* su for GNU. Run a shell with substitute user and group IDs.
- Copyright (C) 1992-2003 Free Software Foundation, Inc.
+ Copyright (C) 1992-2004 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -346,13 +346,13 @@ change_identity (const struct passwd *pw)
#ifdef HAVE_INITGROUPS
errno = 0;
if (initgroups (pw->pw_name, pw->pw_gid) == -1)
- error (EXIT_FAILURE, errno, _("cannot set groups"));
+ error (EXIT_FAIL, errno, _("cannot set groups"));
endgrent ();
#endif
if (setgid (pw->pw_gid))
- error (EXIT_FAILURE, errno, _("cannot set group id"));
+ error (EXIT_FAIL, errno, _("cannot set group id"));
if (setuid (pw->pw_uid))
- error (EXIT_FAILURE, errno, _("cannot set user id"));
+ error (EXIT_FAIL, errno, _("cannot set user id"));
}
/* Run SHELL, or DEFAULT_SHELL if SHELL is empty.
@@ -398,7 +398,7 @@ run_shell (const char *shell, const char *command, char **additional_args)
execv (shell, (char **) args);
{
- int exit_status = (errno == ENOENT ? 127 : 126);
+ int exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
error (0, errno, "%s", shell);
exit (exit_status);
}
@@ -428,7 +428,7 @@ restricted_shell (const char *shell)
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -472,6 +472,7 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ initialize_exit_failure (EXIT_FAIL);
atexit (close_stdout);
fast_startup = 0;
@@ -511,7 +512,7 @@ main (int argc, char **argv)
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
- usage (EXIT_FAILURE);
+ usage (EXIT_FAIL);
}
}
@@ -527,7 +528,7 @@ main (int argc, char **argv)
pw = getpwnam (new_user);
if (pw == 0)
- error (EXIT_FAILURE, 0, _("user %s does not exist"), new_user);
+ error (EXIT_FAIL, 0, _("user %s does not exist"), new_user);
endpwent ();
/* Make sure pw->pw_shell is non-NULL. It may be NULL when NEW_USER
@@ -550,7 +551,7 @@ main (int argc, char **argv)
#ifdef SYSLOG_FAILURE
log_su (pw, 0);
#endif
- error (EXIT_FAILURE, 0, _("incorrect password"));
+ error (EXIT_FAIL, 0, _("incorrect password"));
}
#ifdef SYSLOG_SUCCESS
else