* src/newgrp.c, src/chfn.c, src/groupmems.c, src/usermod.c,

src/userdel.c, src/chpasswd.c, src/grpck.c, src/gpasswd.c,
	src/groupdel.c, src/chgpasswd.c, src/vipw.c, src/useradd.c,
	src/su.c, src/groupmod.c, src/passwd.c, src/pwck.c,
	src/groupadd.c, src/chage.c, src/login.c, src/faillog.c,
	src/sulogin.c, src/chsh.c, src/pwconv.c: Added splint annotations.
	* src/userdel.c, src/pwconv.c, src/lastlog.c, src/grpck.c,
	src/vipw.c, src/groupmod.c, src/passwd.c, src/pwck.c, src/login.c,
	src/sulogin.c, src/usermod.c: Use return instead of exit at the
	end of main().
	* src/gpasswd.c, src/passwd.c, src/faillog.c: Use the exitcodes.h
	exit codes.
	* src/chpasswd.c: Added missing ||.
	* src/nologin.c: Do not include exitcodes.h.
	* src/nologin.c: Added brackets.
	* src/nologin.c: Avoid assignments in comparisons.
This commit is contained in:
nekral-guest 2009-04-30 21:39:38 +00:00
parent c527c0196b
commit 4e75bb57bb
26 changed files with 130 additions and 76 deletions

View File

@ -1,3 +1,22 @@
2009-04-30 Nicolas François <nicolas.francois@centraliens.net>
* src/newgrp.c, src/chfn.c, src/groupmems.c, src/usermod.c,
src/userdel.c, src/chpasswd.c, src/grpck.c, src/gpasswd.c,
src/groupdel.c, src/chgpasswd.c, src/vipw.c, src/useradd.c,
src/su.c, src/groupmod.c, src/passwd.c, src/pwck.c,
src/groupadd.c, src/chage.c, src/login.c, src/faillog.c,
src/sulogin.c, src/chsh.c, src/pwconv.c: Added splint annotations.
* src/userdel.c, src/pwconv.c, src/lastlog.c, src/grpck.c,
src/vipw.c, src/groupmod.c, src/passwd.c, src/pwck.c, src/login.c,
src/sulogin.c, src/usermod.c: Use return instead of exit at the
end of main().
* src/gpasswd.c, src/passwd.c, src/faillog.c: Use the exitcodes.h
exit codes.
* src/chpasswd.c: Added missing ||.
* src/nologin.c: Do not include exitcodes.h.
* src/nologin.c: Added brackets.
* src/nologin.c: Avoid assignments in comparisons.
2009-04-30 Nicolas François <nicolas.francois@centraliens.net> 2009-04-30 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/getgr_nam_gid.c, lib/get_gid.c, lib/get_pid.c, * libmisc/getgr_nam_gid.c, lib/get_gid.c, lib/get_pid.c,

View File

@ -52,11 +52,13 @@
#include <selinux/selinux.h> #include <selinux/selinux.h>
#include <selinux/av_permissions.h> #include <selinux/av_permissions.h>
#endif #endif
#include "exitcodes.h"
#include "prototypes.h" #include "prototypes.h"
#include "defines.h" #include "defines.h"
#include "pwio.h" #include "pwio.h"
#include "shadowio.h" #include "shadowio.h"
/*@-exitarg@*/
#include "exitcodes.h"
/* /*
* Global variables * Global variables
*/ */

View File

@ -44,7 +44,6 @@
#include <selinux/av_permissions.h> #include <selinux/av_permissions.h>
#endif #endif
#include "defines.h" #include "defines.h"
#include "exitcodes.h"
#include "getdef.h" #include "getdef.h"
#include "nscd.h" #include "nscd.h"
#ifdef USE_PAM #ifdef USE_PAM
@ -53,6 +52,9 @@
#include "prototypes.h" #include "prototypes.h"
#include "pwauth.h" #include "pwauth.h"
#include "pwio.h" #include "pwio.h"
/*@-exitarg@*/
#include "exitcodes.h"
/* /*
* Global variables. * Global variables.
*/ */

View File

@ -45,13 +45,15 @@
#endif /* USE_PAM */ #endif /* USE_PAM */
#endif /* ACCT_TOOLS_SETUID */ #endif /* ACCT_TOOLS_SETUID */
#include "defines.h" #include "defines.h"
#include "exitcodes.h"
#include "nscd.h" #include "nscd.h"
#include "prototypes.h" #include "prototypes.h"
#include "groupio.h" #include "groupio.h"
#ifdef SHADOWGRP #ifdef SHADOWGRP
#include "sgroupio.h" #include "sgroupio.h"
#endif #endif
/*@-exitarg@*/
#include "exitcodes.h"
/* /*
* Global variables * Global variables
*/ */

View File

@ -43,11 +43,13 @@
#include "pam_defs.h" #include "pam_defs.h"
#endif /* USE_PAM */ #endif /* USE_PAM */
#include "defines.h" #include "defines.h"
#include "exitcodes.h"
#include "nscd.h" #include "nscd.h"
#include "prototypes.h" #include "prototypes.h"
#include "pwio.h" #include "pwio.h"
#include "shadowio.h" #include "shadowio.h"
/*@-exitarg@*/
#include "exitcodes.h"
/* /*
* Global variables * Global variables
*/ */
@ -495,7 +497,7 @@ int main (int argc, char **argv)
#else /* !USE_PAM */ #else /* !USE_PAM */
if ( !eflg if ( !eflg
&& ( (NULL == crypt_method) && ( (NULL == crypt_method)
(0 != strcmp (crypt_method, "NONE")))) { || (0 != strcmp (crypt_method, "NONE")))) {
void *arg = NULL; void *arg = NULL;
if (md5flg) { if (md5flg) {
crypt_method = "MD5"; crypt_method = "MD5";

View File

@ -44,7 +44,6 @@
#include <selinux/av_permissions.h> #include <selinux/av_permissions.h>
#endif #endif
#include "defines.h" #include "defines.h"
#include "exitcodes.h"
#include "getdef.h" #include "getdef.h"
#include "nscd.h" #include "nscd.h"
#include "prototypes.h" #include "prototypes.h"
@ -53,6 +52,9 @@
#ifdef USE_PAM #ifdef USE_PAM
#include "pam_defs.h" #include "pam_defs.h"
#endif #endif
/*@-exitarg@*/
#include "exitcodes.h"
#ifndef SHELLS_FILE #ifndef SHELLS_FILE
#define SHELLS_FILE "/etc/shells" #define SHELLS_FILE "/etc/shells"
#endif #endif

View File

@ -42,9 +42,11 @@
#include <time.h> #include <time.h>
#include <assert.h> #include <assert.h>
#include "defines.h" #include "defines.h"
#include "exitcodes.h"
#include "faillog.h" #include "faillog.h"
#include "prototypes.h" #include "prototypes.h"
/*@-exitarg@*/
#include "exitcodes.h"
/* /*
* Global variables * Global variables
*/ */
@ -498,7 +500,7 @@ int main (int argc, char **argv)
fprintf (stderr, fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"), _("%s: invalid numeric argument '%s'\n"),
"faillog", optarg); "faillog", optarg);
usage (); exit (E_BAD_ARG);
} }
lflg = true; lflg = true;
break; break;
@ -507,7 +509,7 @@ int main (int argc, char **argv)
fprintf (stderr, fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"), _("%s: invalid numeric argument '%s'\n"),
"faillog", optarg); "faillog", optarg);
usage (); exit (E_BAD_ARG);
} }
mflg = true; mflg = true;
break; break;
@ -519,7 +521,7 @@ int main (int argc, char **argv)
fprintf (stderr, fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"), _("%s: invalid numeric argument '%s'\n"),
"faillog", optarg); "faillog", optarg);
usage (); exit (E_BAD_ARG);
} }
seconds = (time_t) days * DAY; seconds = (time_t) days * DAY;
tflg = true; tflg = true;
@ -550,7 +552,7 @@ int main (int argc, char **argv)
fprintf (stderr, fprintf (stderr,
_("lastlog: Unknown user or range: %s\n"), _("lastlog: Unknown user or range: %s\n"),
optarg); optarg);
exit (EXIT_FAILURE); exit (E_BAD_ARG);
} }
} }
@ -579,7 +581,7 @@ int main (int argc, char **argv)
fprintf (stderr, fprintf (stderr,
_("faillog: Cannot open %s: %s\n"), _("faillog: Cannot open %s: %s\n"),
FAILLOG_FILE, strerror (errno)); FAILLOG_FILE, strerror (errno));
exit (EXIT_FAILURE); exit (E_NOPERM);
} }
/* Get the size of the faillog */ /* Get the size of the faillog */
@ -587,7 +589,7 @@ int main (int argc, char **argv)
fprintf (stderr, fprintf (stderr,
_("faillog: Cannot get the size of %s: %s\n"), _("faillog: Cannot get the size of %s: %s\n"),
FAILLOG_FILE, strerror (errno)); FAILLOG_FILE, strerror (errno));
exit (EXIT_FAILURE); exit (E_NOPERM);
} }
if (lflg) { if (lflg) {
@ -608,6 +610,6 @@ int main (int argc, char **argv)
fclose (fail); fclose (fail);
exit (errors ? EXIT_FAILURE : EXIT_SUCCESS); exit (errors ? E_NOPERM : E_SUCCESS);
} }

View File

@ -43,13 +43,15 @@
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>
#include "defines.h" #include "defines.h"
#include "exitcodes.h"
#include "groupio.h" #include "groupio.h"
#include "nscd.h" #include "nscd.h"
#include "prototypes.h" #include "prototypes.h"
#ifdef SHADOWGRP #ifdef SHADOWGRP
#include "sgroupio.h" #include "sgroupio.h"
#endif #endif
/*@-exitarg@*/
#include "exitcodes.h"
/* /*
* Global variables * Global variables
*/ */
@ -220,7 +222,7 @@ static void failure (void)
{ {
fprintf (stderr, _("%s: Permission denied.\n"), Prog); fprintf (stderr, _("%s: Permission denied.\n"), Prog);
log_gpasswd_failure (": Permission denied"); log_gpasswd_failure (": Permission denied");
exit (1); exit (E_NOPERM);
} }
/* /*
@ -248,9 +250,9 @@ static void process_flags (int argc, char **argv)
/* local, no need for xgetpwnam */ /* local, no need for xgetpwnam */
if (getpwnam (user) == NULL) { if (getpwnam (user) == NULL) {
fprintf (stderr, fprintf (stderr,
_("%s: user '%s' does not exist\n"), Prog, _("%s: user '%s' does not exist\n"),
user); Prog, user);
exit (1); exit (E_BAD_ARG);
} }
break; break;
#ifdef SHADOWGRP #ifdef SHADOWGRP
@ -259,11 +261,11 @@ static void process_flags (int argc, char **argv)
fprintf (stderr, fprintf (stderr,
_("%s: shadow group passwords required for -A\n"), _("%s: shadow group passwords required for -A\n"),
Prog); Prog);
exit (2); exit (E_GSHADOW_NOTFOUND);
} }
admins = optarg; admins = optarg;
if (!is_valid_user_list (admins)) { if (!is_valid_user_list (admins)) {
exit (1); exit (E_BAD_ARG);
} }
Aflg = true; Aflg = true;
break; break;
@ -277,7 +279,7 @@ static void process_flags (int argc, char **argv)
case 'M': /* set the list of members */ case 'M': /* set the list of members */
members = optarg; members = optarg;
if (!is_valid_user_list (members)) { if (!is_valid_user_list (members)) {
exit (1); exit (E_BAD_ARG);
} }
Mflg = true; Mflg = true;
break; break;
@ -345,7 +347,7 @@ static void open_files (void)
fprintf (stderr, fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"), _("%s: cannot lock %s; try again later.\n"),
Prog, gr_dbname ()); Prog, gr_dbname ());
exit (1); exit (E_NOPERM);
} }
add_cleanup (cleanup_unlock_group, NULL); add_cleanup (cleanup_unlock_group, NULL);
@ -355,7 +357,7 @@ static void open_files (void)
fprintf (stderr, fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"), _("%s: cannot lock %s; try again later.\n"),
Prog, sgr_dbname ()); Prog, sgr_dbname ());
exit (1); exit (E_NOPERM);
} }
add_cleanup (cleanup_unlock_gshadow, NULL); add_cleanup (cleanup_unlock_gshadow, NULL);
} }
@ -368,7 +370,7 @@ static void open_files (void)
_("%s: cannot open %s\n"), _("%s: cannot open %s\n"),
Prog, gr_dbname ()); Prog, gr_dbname ());
SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ())); SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
exit (1); exit (E_NOPERM);
} }
#ifdef SHADOWGRP #ifdef SHADOWGRP
@ -378,7 +380,7 @@ static void open_files (void)
_("%s: cannot open %s\n"), _("%s: cannot open %s\n"),
Prog, sgr_dbname ()); Prog, sgr_dbname ());
SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ())); SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
exit (1); exit (E_NOPERM);
} }
add_cleanup (log_gpasswd_failure_gshadow, NULL); add_cleanup (log_gpasswd_failure_gshadow, NULL);
} }
@ -669,7 +671,7 @@ static void close_files (void)
fprintf (stderr, fprintf (stderr,
_("%s: failure while writing changes to %s\n"), _("%s: failure while writing changes to %s\n"),
Prog, gr_dbname ()); Prog, gr_dbname ());
exit (1); exit (E_NOPERM);
} }
add_cleanup (log_gpasswd_success_group, NULL); add_cleanup (log_gpasswd_success_group, NULL);
del_cleanup (log_gpasswd_failure_group); del_cleanup (log_gpasswd_failure_group);
@ -683,7 +685,7 @@ static void close_files (void)
fprintf (stderr, fprintf (stderr,
_("%s: failure while writing changes to %s\n"), _("%s: failure while writing changes to %s\n"),
Prog, sgr_dbname ()); Prog, sgr_dbname ());
exit (1); exit (E_NOPERM);
} }
add_cleanup (log_gpasswd_success_gshadow, NULL); add_cleanup (log_gpasswd_success_gshadow, NULL);
del_cleanup (log_gpasswd_failure_gshadow); del_cleanup (log_gpasswd_failure_gshadow);
@ -815,7 +817,7 @@ static void get_group (struct group *gr)
if (gr_open (O_RDONLY) == 0) { if (gr_open (O_RDONLY) == 0) {
fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ()); fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());
SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ())); SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
exit (1); exit (E_NOPERM);
} }
tmpgr = gr_locate (group); tmpgr = gr_locate (group);
@ -823,7 +825,7 @@ static void get_group (struct group *gr)
fprintf (stderr, fprintf (stderr,
_("%s: group '%s' does not exist in %s\n"), _("%s: group '%s' does not exist in %s\n"),
Prog, group, gr_dbname ()); Prog, group, gr_dbname ());
exit (1); exit (E_BAD_ARG);
} }
*gr = *tmpgr; *gr = *tmpgr;
@ -838,7 +840,7 @@ static void get_group (struct group *gr)
SYSLOG ((LOG_ERR, SYSLOG ((LOG_ERR,
"failure while closing read-only %s", "failure while closing read-only %s",
gr_dbname ())); gr_dbname ()));
exit (1); exit (E_NOPERM);
} }
#ifdef SHADOWGRP #ifdef SHADOWGRP
@ -848,7 +850,7 @@ static void get_group (struct group *gr)
_("%s: cannot open %s\n"), _("%s: cannot open %s\n"),
Prog, sgr_dbname ()); Prog, sgr_dbname ());
SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ())); SYSLOG ((LOG_WARN, "cannot open %s", sgr_dbname ()));
exit (1); exit (E_NOPERM);
} }
tmpsg = sgr_locate (group); tmpsg = sgr_locate (group);
if (NULL != tmpsg) { if (NULL != tmpsg) {
@ -884,7 +886,7 @@ static void get_group (struct group *gr)
SYSLOG ((LOG_ERR, SYSLOG ((LOG_ERR,
"failure while closing read-only %s", "failure while closing read-only %s",
sgr_dbname ())); sgr_dbname ()));
exit (1); exit (E_NOPERM);
} }
} }
#endif /* SHADOWGRP */ #endif /* SHADOWGRP */
@ -1010,7 +1012,7 @@ int main (int argc, char **argv)
SYSLOG ((LOG_WARN, SYSLOG ((LOG_WARN,
"Cannot determine the user name of the caller (UID %lu)", "Cannot determine the user name of the caller (UID %lu)",
(unsigned long) getuid ())); (unsigned long) getuid ()));
exit (1); exit (E_NOPERM);
} }
myname = xstrdup (pw->pw_name); myname = xstrdup (pw->pw_name);
@ -1020,7 +1022,7 @@ int main (int argc, char **argv)
*/ */
if (atexit (do_cleanups) != 0) { if (atexit (do_cleanups) != 0) {
fprintf(stderr, "%s: cannot set exit function\n", Prog); fprintf(stderr, "%s: cannot set exit function\n", Prog);
exit(EXIT_FAILURE); exit (1);
} }
/* Parse the options */ /* Parse the options */
@ -1106,7 +1108,7 @@ int main (int argc, char **argv)
fprintf (stderr, fprintf (stderr,
_("%s: user '%s' is not a member of '%s'\n"), _("%s: user '%s' is not a member of '%s'\n"),
Prog, user, group); Prog, user, group);
exit (1); exit (E_BAD_ARG);
} }
goto output; goto output;
} }
@ -1144,7 +1146,7 @@ int main (int argc, char **argv)
*/ */
if ((isatty (0) == 0) || (isatty (1) == 0)) { if ((isatty (0) == 0) || (isatty (1) == 0)) {
fprintf (stderr, _("%s: Not a tty\n"), Prog); fprintf (stderr, _("%s: Not a tty\n"), Prog);
exit (1); exit (E_NOPERM);
} }
catch_signals (0); /* save tty modes */ catch_signals (0); /* save tty modes */
@ -1175,7 +1177,7 @@ int main (int argc, char **argv)
fputs (_("Cannot change ID to root.\n"), stderr); fputs (_("Cannot change ID to root.\n"), stderr);
SYSLOG ((LOG_ERR, "can't setuid(0)")); SYSLOG ((LOG_ERR, "can't setuid(0)"));
closelog (); closelog ();
exit (1); exit (E_NOPERM);
} }
pwd_init (); pwd_init ();

View File

@ -59,6 +59,7 @@
/* /*
* exit status values * exit status values
*/ */
/*@-exitarg@*/
#define E_SUCCESS 0 /* success */ #define E_SUCCESS 0 /* success */
#define E_USAGE 2 /* invalid command syntax */ #define E_USAGE 2 /* invalid command syntax */
#define E_BAD_ARG 3 /* invalid argument to option */ #define E_BAD_ARG 3 /* invalid argument to option */

View File

@ -67,6 +67,7 @@ static bool is_shadow_grp;
/* /*
* exit status values * exit status values
*/ */
/*@-exitarg@*/
#define E_SUCCESS 0 /* success */ #define E_SUCCESS 0 /* success */
#define E_USAGE 2 /* invalid command syntax */ #define E_USAGE 2 /* invalid command syntax */
#define E_NOTFOUND 6 /* specified group doesn't exist */ #define E_NOTFOUND 6 /* specified group doesn't exist */

View File

@ -49,7 +49,7 @@
#endif #endif
/* Exit Status Values */ /* Exit Status Values */
/*@-exitarg@*/
#define EXIT_SUCCESS 0 /* success */ #define EXIT_SUCCESS 0 /* success */
#define EXIT_USAGE 1 /* invalid command syntax */ #define EXIT_USAGE 1 /* invalid command syntax */
#define EXIT_GROUP_FILE 2 /* group file access problems */ #define EXIT_GROUP_FILE 2 /* group file access problems */

View File

@ -58,6 +58,7 @@
/* /*
* exit status values * exit status values
*/ */
/*@-exitarg@*/
#define E_SUCCESS 0 /* success */ #define E_SUCCESS 0 /* success */
#define E_USAGE 2 /* invalid command syntax */ #define E_USAGE 2 /* invalid command syntax */
#define E_BAD_ARG 3 /* invalid argument to option */ #define E_BAD_ARG 3 /* invalid argument to option */
@ -813,7 +814,6 @@ int main (int argc, char **argv)
nscd_flush_cache ("group"); nscd_flush_cache ("group");
exit (E_SUCCESS); return E_SUCCESS;
/* NOT REACHED */
} }

View File

@ -53,7 +53,7 @@
/* /*
* Exit codes * Exit codes
*/ */
/*@-exitarg@*/
#define E_OKAY 0 #define E_OKAY 0
#define E_USAGE 1 #define E_USAGE 1
#define E_BAD_ENTRY 2 #define E_BAD_ENTRY 2
@ -840,6 +840,6 @@ int main (int argc, char **argv)
} }
} }
exit ((0 != errors) ? E_BAD_ENTRY : E_OKAY); return ((0 != errors) ? E_BAD_ENTRY : E_OKAY);
} }

View File

@ -296,6 +296,7 @@ int main (int argc, char **argv)
print (); print ();
(void) fclose (lastlogfile); (void) fclose (lastlogfile);
exit (EXIT_SUCCESS);
return EXIT_SUCCESS;
} }

View File

@ -51,7 +51,9 @@
#include "getdef.h" #include "getdef.h"
#include "prototypes.h" #include "prototypes.h"
#include "pwauth.h" #include "pwauth.h"
/*@-exitarg@*/
#include "exitcodes.h" #include "exitcodes.h"
#ifdef USE_PAM #ifdef USE_PAM
#include "pam_defs.h" #include "pam_defs.h"
@ -1324,8 +1326,7 @@ int main (int argc, char **argv)
/* exec the shell finally */ /* exec the shell finally */
err = shell (pwd->pw_shell, (char *) 0, newenvp); err = shell (pwd->pw_shell, (char *) 0, newenvp);
} }
exit (err == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
/* NOT REACHED */ return ((err == ENOENT) ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
return 0;
} }

View File

@ -42,7 +42,9 @@
#include "defines.h" #include "defines.h"
#include "getdef.h" #include "getdef.h"
#include "prototypes.h" #include "prototypes.h"
/*@-exitarg@*/
#include "exitcodes.h" #include "exitcodes.h"
/* /*
* Global variables * Global variables
*/ */
@ -345,7 +347,7 @@ static void syslog_sg (const char *name, const char *group)
(unsigned long) gid, name)); (unsigned long) gid, name));
} }
closelog (); closelog ();
exit (EXIT_SUCCESS); exit (E_SUCCESS);
} }
/* child - restore signals to their default state */ /* child - restore signals to their default state */
@ -728,7 +730,7 @@ int main (int argc, char **argv)
(unsigned int) getuid (), 0); (unsigned int) getuid (), 0);
#endif #endif
perror ("/bin/sh"); perror ("/bin/sh");
exit (errno == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC); exit ((errno == ENOENT) ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
} }
/* /*
@ -800,7 +802,7 @@ int main (int argc, char **argv)
* the previous environment which should be the user's login shell. * the previous environment which should be the user's login shell.
*/ */
err = shell (prog, initflag ? (char *) 0 : cp, newenvp); err = shell (prog, initflag ? (char *) 0 : cp, newenvp);
exit (err == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC); exit ((err == ENOENT) ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
/* @notreached@ */ /* @notreached@ */
failure: failure:

View File

@ -31,20 +31,24 @@
#include <stdio.h> #include <stdio.h>
#include <syslog.h> #include <syslog.h>
#include <unistd.h> #include <unistd.h>
#include "exitcodes.h"
int main (void) int main (void)
{ {
const char *user, *tty; const char *user, *tty;
if ((tty = ttyname (0)) == NULL) tty = ttyname (0);
if (NULL == tty) {
tty = "UNKNOWN"; tty = "UNKNOWN";
if ((user = getlogin ()) == NULL) }
user = getlogin ();
if (NULL == user) {
user = "UNKNOWN"; user = "UNKNOWN";
}
openlog ("nologin", LOG_CONS, LOG_AUTH); openlog ("nologin", LOG_CONS, LOG_AUTH);
syslog (LOG_CRIT, "Attempted login by %s on %s", user, tty); syslog (LOG_CRIT, "Attempted login by %s on %s", user, tty);
closelog (); closelog ();
printf ("%s", "This account is currently not available.\n"); printf ("%s", "This account is currently not available.\n");
return E_NOPERM;
return EXIT_FAILURE;
} }

View File

@ -55,9 +55,11 @@
#include "pwauth.h" #include "pwauth.h"
#include "pwio.h" #include "pwio.h"
#include "shadowio.h" #include "shadowio.h"
/* /*
* exit status values * exit status values
*/ */
/*@-exitarg@*/
#define E_SUCCESS 0 /* success */ #define E_SUCCESS 0 /* success */
#define E_NOPERM 1 /* permission denied */ #define E_NOPERM 1 /* permission denied */
#define E_USAGE 2 /* invalid combination of options */ #define E_USAGE 2 /* invalid combination of options */
@ -1004,7 +1006,7 @@ int main (int argc, char **argv)
if (NULL != user_context) { if (NULL != user_context) {
freecon (user_context); freecon (user_context);
} }
exit(1); exit (E_NOPERM);
} }
#endif /* WITH_SELINUX */ #endif /* WITH_SELINUX */
@ -1111,7 +1113,7 @@ int main (int argc, char **argv)
printf (_("%s: password expiry information changed."), Prog); printf (_("%s: password expiry information changed."), Prog);
} }
} }
exit (E_SUCCESS);
/*@notreached@*/ return E_SUCCESS;
} }

View File

@ -51,7 +51,7 @@
/* /*
* Exit codes * Exit codes
*/ */
/*@-exitarg@*/
#define E_OKAY 0 #define E_OKAY 0
#define E_USAGE 1 #define E_USAGE 1
#define E_BADENTRY 2 #define E_BADENTRY 2
@ -707,6 +707,6 @@ int main (int argc, char **argv)
} }
closelog (); closelog ();
exit ((0 != errors) ? E_BADENTRY : E_OKAY); return ((0 != errors) ? E_BADENTRY : E_OKAY);
} }

View File

@ -71,9 +71,11 @@
#include "pwio.h" #include "pwio.h"
#include "shadowio.h" #include "shadowio.h"
#include "nscd.h" #include "nscd.h"
/* /*
* exit status values * exit status values
*/ */
/*@-exitarg@*/
#define E_SUCCESS 0 /* success */ #define E_SUCCESS 0 /* success */
#define E_NOPERM 1 /* permission denied */ #define E_NOPERM 1 /* permission denied */
#define E_USAGE 2 /* invalid command syntax */ #define E_USAGE 2 /* invalid command syntax */
@ -269,6 +271,6 @@ int main (int argc, char **argv)
nscd_flush_cache ("passwd"); nscd_flush_cache ("passwd");
exit (E_SUCCESS); return E_SUCCESS;
} }

View File

@ -63,12 +63,14 @@
#include <sys/types.h> #include <sys/types.h>
#include "prototypes.h" #include "prototypes.h"
#include "defines.h" #include "defines.h"
#include "exitcodes.h"
#include "pwauth.h" #include "pwauth.h"
#include "getdef.h" #include "getdef.h"
#ifdef USE_PAM #ifdef USE_PAM
#include "pam_defs.h" #include "pam_defs.h"
#endif #endif /* USE_PAM */
/*@-exitarg@*/
#include "exitcodes.h"
/* /*
* Assorted #defines to control su's behavior * Assorted #defines to control su's behavior
*/ */

View File

@ -43,7 +43,9 @@
#include "getdef.h" #include "getdef.h"
#include "prototypes.h" #include "prototypes.h"
#include "pwauth.h" #include "pwauth.h"
/*@-exitarg@*/
#include "exitcodes.h" #include "exitcodes.h"
/* /*
* Global variables * Global variables
*/ */
@ -244,7 +246,7 @@ static RETSIGTYPE catch_signals (unused int sig)
#endif #endif
/* exec the shell finally. */ /* exec the shell finally. */
err = shell (pwent.pw_shell, (char *) 0, environ); err = shell (pwent.pw_shell, (char *) 0, environ);
exit ((err == ENOENT) ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
/*NOTREACHED*/ return (0); return ((err == ENOENT) ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
} }

View File

@ -153,6 +153,7 @@ static bool home_added = false;
/* /*
* exit status values * exit status values
*/ */
/*@-exitarg@*/
#define E_SUCCESS 0 /* success */ #define E_SUCCESS 0 /* success */
#define E_PW_UPDATE 1 /* can't update password file */ #define E_PW_UPDATE 1 /* can't update password file */
#define E_USAGE 2 /* invalid command syntax */ #define E_USAGE 2 /* invalid command syntax */

View File

@ -56,10 +56,12 @@
#include "pwauth.h" #include "pwauth.h"
#include "pwio.h" #include "pwio.h"
#include "shadowio.h" #include "shadowio.h"
#include "exitcodes.h"
#ifdef SHADOWGRP #ifdef SHADOWGRP
#include "sgroupio.h" #include "sgroupio.h"
#endif #endif
/*@-exitarg@*/
#include "exitcodes.h"
/* /*
* exit status values * exit status values
*/ */
@ -1021,7 +1023,6 @@ int main (int argc, char **argv)
nscd_flush_cache ("passwd"); nscd_flush_cache ("passwd");
nscd_flush_cache ("group"); nscd_flush_cache ("group");
exit ((0 != errors) ? E_HOMEDIR : E_SUCCESS); return ((0 != errors) ? E_HOMEDIR : E_SUCCESS);
/* NOT REACHED */
} }

View File

@ -63,11 +63,13 @@
#include "sgroupio.h" #include "sgroupio.h"
#endif #endif
#include "shadowio.h" #include "shadowio.h"
/* /*
* exit status values * exit status values
* for E_GRP_UPDATE and E_NOSPACE (not used yet), other update requests * for E_GRP_UPDATE and E_NOSPACE (not used yet), other update requests
* will be implemented (as documented in the Solaris 2.x man page). * will be implemented (as documented in the Solaris 2.x man page).
*/ */
/*@-exitarg@*/
#define E_SUCCESS 0 /* success */ #define E_SUCCESS 0 /* success */
#define E_PW_UPDATE 1 /* can't update password file */ #define E_PW_UPDATE 1 /* can't update password file */
#define E_USAGE 2 /* invalid command syntax */ #define E_USAGE 2 /* invalid command syntax */
@ -1792,8 +1794,7 @@ int main (int argc, char **argv)
user_gid, gflg ? user_newgid : user_gid); user_gid, gflg ? user_newgid : user_gid);
} }
exit (E_SUCCESS); return E_SUCCESS;
/* NOT REACHED */
} }
#ifdef WITH_SELINUX #ifdef WITH_SELINUX

View File

@ -29,6 +29,9 @@
#include <errno.h> #include <errno.h>
#include <getopt.h> #include <getopt.h>
#ifdef WITH_SELINUX
#include <selinux/selinux.h>
#endif
#include <signal.h> #include <signal.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -37,17 +40,14 @@
#include <unistd.h> #include <unistd.h>
#include <utime.h> #include <utime.h>
#include "defines.h" #include "defines.h"
#include "exitcodes.h"
#include "groupio.h" #include "groupio.h"
#include "nscd.h" #include "nscd.h"
#include "prototypes.h" #include "prototypes.h"
#include "pwio.h" #include "pwio.h"
#include "sgroupio.h" #include "sgroupio.h"
#include "shadowio.h" #include "shadowio.h"
/*@-exitarg@*/
#ifdef WITH_SELINUX #include "exitcodes.h"
#include <selinux/selinux.h>
#endif
#define MSG_WARN_EDIT_OTHER_FILE _( \ #define MSG_WARN_EDIT_OTHER_FILE _( \
"You have modified %s.\n"\ "You have modified %s.\n"\
@ -406,6 +406,6 @@ int main (int argc, char **argv)
nscd_flush_cache ("passwd"); nscd_flush_cache ("passwd");
nscd_flush_cache ("group"); nscd_flush_cache ("group");
exit (E_SUCCESS); return E_SUCCESS;
} }