+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,
#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
*/
#include <selinux/av_permissions.h>
#endif
#include "defines.h"
-#include "exitcodes.h"
#include "getdef.h"
#include "nscd.h"
#ifdef USE_PAM
#include "prototypes.h"
#include "pwauth.h"
#include "pwio.h"
+/*@-exitarg@*/
+#include "exitcodes.h"
+
/*
* Global variables.
*/
#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
*/
#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
*/
#else /* !USE_PAM */
if ( !eflg
- && ((NULL == crypt_method)
- (0 != strcmp (crypt_method, "NONE")))) {
+ && ( (NULL == crypt_method)
+ || (0 != strcmp (crypt_method, "NONE")))) {
void *arg = NULL;
if (md5flg) {
crypt_method = "MD5";
#include <selinux/av_permissions.h>
#endif
#include "defines.h"
-#include "exitcodes.h"
#include "getdef.h"
#include "nscd.h"
#include "prototypes.h"
#ifdef USE_PAM
#include "pam_defs.h"
#endif
+/*@-exitarg@*/
+#include "exitcodes.h"
+
#ifndef SHELLS_FILE
#define SHELLS_FILE "/etc/shells"
#endif
#include <time.h>
#include <assert.h>
#include "defines.h"
-#include "exitcodes.h"
#include "faillog.h"
#include "prototypes.h"
+/*@-exitarg@*/
+#include "exitcodes.h"
+
/*
* Global variables
*/
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
"faillog", optarg);
- usage ();
+ exit (E_BAD_ARG);
}
lflg = true;
break;
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
"faillog", optarg);
- usage ();
+ exit (E_BAD_ARG);
}
mflg = true;
break;
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
"faillog", optarg);
- usage ();
+ exit (E_BAD_ARG);
}
seconds = (time_t) days * DAY;
tflg = true;
fprintf (stderr,
_("lastlog: Unknown user or range: %s\n"),
optarg);
- exit (EXIT_FAILURE);
+ exit (E_BAD_ARG);
}
}
fprintf (stderr,
_("faillog: Cannot open %s: %s\n"),
FAILLOG_FILE, strerror (errno));
- exit (EXIT_FAILURE);
+ exit (E_NOPERM);
}
/* Get the size of the faillog */
fprintf (stderr,
_("faillog: Cannot get the size of %s: %s\n"),
FAILLOG_FILE, strerror (errno));
- exit (EXIT_FAILURE);
+ exit (E_NOPERM);
}
if (lflg) {
fclose (fail);
- exit (errors ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit (errors ? E_NOPERM : E_SUCCESS);
}
#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
*/
{
fprintf (stderr, _("%s: Permission denied.\n"), Prog);
log_gpasswd_failure (": Permission denied");
- exit (1);
+ exit (E_NOPERM);
}
/*
/* 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
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;
case 'M': /* set the list of members */
members = optarg;
if (!is_valid_user_list (members)) {
- exit (1);
+ exit (E_BAD_ARG);
}
Mflg = true;
break;
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, gr_dbname ());
- exit (1);
+ exit (E_NOPERM);
}
add_cleanup (cleanup_unlock_group, NULL);
fprintf (stderr,
_("%s: cannot lock %s; try again later.\n"),
Prog, sgr_dbname ());
- exit (1);
+ exit (E_NOPERM);
}
add_cleanup (cleanup_unlock_gshadow, NULL);
}
_("%s: cannot open %s\n"),
Prog, gr_dbname ());
SYSLOG ((LOG_WARN, "cannot open %s", gr_dbname ()));
- exit (1);
+ exit (E_NOPERM);
}
#ifdef SHADOWGRP
_("%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);
}
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);
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);
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);
fprintf (stderr,
_("%s: group '%s' does not exist in %s\n"),
Prog, group, gr_dbname ());
- exit (1);
+ exit (E_BAD_ARG);
}
*gr = *tmpgr;
SYSLOG ((LOG_ERR,
"failure while closing read-only %s",
gr_dbname ()));
- exit (1);
+ exit (E_NOPERM);
}
#ifdef SHADOWGRP
_("%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) {
SYSLOG ((LOG_ERR,
"failure while closing read-only %s",
sgr_dbname ()));
- exit (1);
+ exit (E_NOPERM);
}
}
#endif /* SHADOWGRP */
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);
*/
if (atexit (do_cleanups) != 0) {
fprintf(stderr, "%s: cannot set exit function\n", Prog);
- exit(EXIT_FAILURE);
+ exit (1);
}
/* Parse the options */
fprintf (stderr,
_("%s: user '%s' is not a member of '%s'\n"),
Prog, user, group);
- exit (1);
+ exit (E_BAD_ARG);
}
goto output;
}
*/
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 */
fputs (_("Cannot change ID to root.\n"), stderr);
SYSLOG ((LOG_ERR, "can't setuid(0)"));
closelog ();
- exit (1);
+ exit (E_NOPERM);
}
pwd_init ();
/*
* 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 */
/*
* 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 */
#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 */
/*
* 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 */
nscd_flush_cache ("group");
- exit (E_SUCCESS);
- /* NOT REACHED */
+ return E_SUCCESS;
}
/*
* Exit codes
*/
-
+/*@-exitarg@*/
#define E_OKAY 0
#define E_USAGE 1
#define E_BAD_ENTRY 2
}
}
- exit ((0 != errors) ? E_BAD_ENTRY : E_OKAY);
+ return ((0 != errors) ? E_BAD_ENTRY : E_OKAY);
}
print ();
(void) fclose (lastlogfile);
- exit (EXIT_SUCCESS);
+
+ return EXIT_SUCCESS;
}
#include "getdef.h"
#include "prototypes.h"
#include "pwauth.h"
+/*@-exitarg@*/
#include "exitcodes.h"
+
#ifdef USE_PAM
#include "pam_defs.h"
/* 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);
}
#include "defines.h"
#include "getdef.h"
#include "prototypes.h"
+/*@-exitarg@*/
#include "exitcodes.h"
+
/*
* Global variables
*/
(unsigned long) gid, name));
}
closelog ();
- exit (EXIT_SUCCESS);
+ exit (E_SUCCESS);
}
/* child - restore signals to their default state */
(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);
}
/*
* 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:
#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;
}
#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 */
if (NULL != user_context) {
freecon (user_context);
}
- exit(1);
+ exit (E_NOPERM);
}
#endif /* WITH_SELINUX */
printf (_("%s: password expiry information changed."), Prog);
}
}
- exit (E_SUCCESS);
- /*@notreached@*/
+
+ return E_SUCCESS;
}
/*
* Exit codes
*/
-
+/*@-exitarg@*/
#define E_OKAY 0
#define E_USAGE 1
#define E_BADENTRY 2
}
closelog ();
- exit ((0 != errors) ? E_BADENTRY : E_OKAY);
+ return ((0 != errors) ? E_BADENTRY : E_OKAY);
}
#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 */
nscd_flush_cache ("passwd");
- exit (E_SUCCESS);
+ return E_SUCCESS;
}
#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
*/
#include "getdef.h"
#include "prototypes.h"
#include "pwauth.h"
+/*@-exitarg@*/
#include "exitcodes.h"
+
/*
* Global variables
*/
#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);
}
/*
* 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 */
#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
*/
nscd_flush_cache ("passwd");
nscd_flush_cache ("group");
- exit ((0 != errors) ? E_HOMEDIR : E_SUCCESS);
- /* NOT REACHED */
+ return ((0 != errors) ? E_HOMEDIR : E_SUCCESS);
}
#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 */
user_gid, gflg ? user_newgid : user_gid);
}
- exit (E_SUCCESS);
- /* NOT REACHED */
+ return E_SUCCESS;
}
#ifdef WITH_SELINUX
#include <errno.h>
#include <getopt.h>
+#ifdef WITH_SELINUX
+#include <selinux/selinux.h>
+#endif
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#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"\
nscd_flush_cache ("passwd");
nscd_flush_cache ("group");
- exit (E_SUCCESS);
+ return E_SUCCESS;
}