* 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>
* 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/av_permissions.h>
#endif
#include "exitcodes.h"
#include "prototypes.h"
#include "defines.h"
#include "pwio.h"
#include "shadowio.h"
/*@-exitarg@*/
#include "exitcodes.h"
/*
* Global variables
*/

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -53,7 +53,7 @@
/*
* Exit codes
*/
/*@-exitarg@*/
#define E_OKAY 0
#define E_USAGE 1
#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 ();
(void) fclose (lastlogfile);
exit (EXIT_SUCCESS);
return EXIT_SUCCESS;
}

View File

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

View File

@ -42,7 +42,9 @@
#include "defines.h"
#include "getdef.h"
#include "prototypes.h"
/*@-exitarg@*/
#include "exitcodes.h"
/*
* Global variables
*/
@ -345,7 +347,7 @@ static void syslog_sg (const char *name, const char *group)
(unsigned long) gid, name));
}
closelog ();
exit (EXIT_SUCCESS);
exit (E_SUCCESS);
}
/* child - restore signals to their default state */
@ -728,7 +730,7 @@ int main (int argc, char **argv)
(unsigned int) getuid (), 0);
#endif
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.
*/
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@ */
failure:

View File

@ -31,20 +31,24 @@
#include <stdio.h>
#include <syslog.h>
#include <unistd.h>
#include "exitcodes.h"
int main (void)
{
const char *user, *tty;
if ((tty = ttyname (0)) == NULL)
tty = ttyname (0);
if (NULL == tty) {
tty = "UNKNOWN";
if ((user = getlogin ()) == NULL)
}
user = getlogin ();
if (NULL == user) {
user = "UNKNOWN";
}
openlog ("nologin", LOG_CONS, LOG_AUTH);
syslog (LOG_CRIT, "Attempted login by %s on %s", user, tty);
closelog ();
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 "pwio.h"
#include "shadowio.h"
/*
* exit status values
*/
/*@-exitarg@*/
#define E_SUCCESS 0 /* success */
#define E_NOPERM 1 /* permission denied */
#define E_USAGE 2 /* invalid combination of options */
@ -1004,7 +1006,7 @@ int main (int argc, char **argv)
if (NULL != user_context) {
freecon (user_context);
}
exit(1);
exit (E_NOPERM);
}
#endif /* WITH_SELINUX */
@ -1111,7 +1113,7 @@ int main (int argc, char **argv)
printf (_("%s: password expiry information changed."), Prog);
}
}
exit (E_SUCCESS);
/*@notreached@*/
return E_SUCCESS;
}

View File

@ -51,7 +51,7 @@
/*
* Exit codes
*/
/*@-exitarg@*/
#define E_OKAY 0
#define E_USAGE 1
#define E_BADENTRY 2
@ -707,6 +707,6 @@ int main (int argc, char **argv)
}
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 "shadowio.h"
#include "nscd.h"
/*
* exit status values
*/
/*@-exitarg@*/
#define E_SUCCESS 0 /* success */
#define E_NOPERM 1 /* permission denied */
#define E_USAGE 2 /* invalid command syntax */
@ -269,6 +271,6 @@ int main (int argc, char **argv)
nscd_flush_cache ("passwd");
exit (E_SUCCESS);
return E_SUCCESS;
}

View File

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

View File

@ -43,7 +43,9 @@
#include "getdef.h"
#include "prototypes.h"
#include "pwauth.h"
/*@-exitarg@*/
#include "exitcodes.h"
/*
* Global variables
*/
@ -244,7 +246,7 @@ static RETSIGTYPE catch_signals (unused int sig)
#endif
/* exec the shell finally. */
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
*/
/*@-exitarg@*/
#define E_SUCCESS 0 /* success */
#define E_PW_UPDATE 1 /* can't update password file */
#define E_USAGE 2 /* invalid command syntax */

View File

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

View File

@ -63,11 +63,13 @@
#include "sgroupio.h"
#endif
#include "shadowio.h"
/*
* exit status values
* 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).
*/
/*@-exitarg@*/
#define E_SUCCESS 0 /* success */
#define E_PW_UPDATE 1 /* can't update password file */
#define E_USAGE 2 /* invalid command syntax */
@ -1792,8 +1794,7 @@ int main (int argc, char **argv)
user_gid, gflg ? user_newgid : user_gid);
}
exit (E_SUCCESS);
/* NOT REACHED */
return E_SUCCESS;
}
#ifdef WITH_SELINUX

View File

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