[Pkg-shadow-commits] r3230 - in upstream/trunk: . lib libmisc src
Nicolas FRANÇOIS
nekral-guest at alioth.debian.org
Sun Aug 22 12:49:08 UTC 2010
Author: nekral-guest
Date: 2010-08-22 12:49:07 +0000 (Sun, 22 Aug 2010)
New Revision: 3230
Modified:
upstream/trunk/ChangeLog
upstream/trunk/lib/encrypt.c
upstream/trunk/lib/prototypes.h
upstream/trunk/libmisc/copydir.c
upstream/trunk/libmisc/obscure.c
upstream/trunk/libmisc/tz.c
upstream/trunk/src/passwd.c
upstream/trunk/src/su.c
upstream/trunk/src/sulogin.c
upstream/trunk/src/vipw.c
Log:
* libmisc/obscure.c, lib/prototypes.h (obscure): Return a bool
instead of an int.
* libmisc/obscure.c, libmisc/tz.c, src/passwd.c, lib/encrypt.c,
libmisc/copydir.c, lib/prototypes.h: Add splint annotations.
* libmisc/tz.c: Fix some const issues.
* libmisc/tz.c: Avoid multi-statements lines.
* libmisc/tz.c: Add brackets.
* libmisc/copydir.c: Do not check *printf/*puts return value.
* libmisc/copydir.c: Fail if we cannot set or reset the SELinux
fscreate context.
* libmisc/copydir.c: Use xmalloc instead of malloc.
* libmisc/copydir.c: Do not check lutimes return value
* src/vipw.c: Avoid implicit conversion of integer to boolean.
* src/su.c (iswheel): Return a bool instead of an int.
* src/passwd.c: Remove insert_crypt_passwd(). Use xstrdup instead.
* src/passwd.c: Return constant strings when sufficient.
* src/passwd.c: Do not check *printf/*puts return value.
* src/passwd.c: Avoid implicit conversion of character to boolean.
* src/passwd.c: Do not check sleep return value.
* src/sulogin.c: Do not check *printf/*puts return value.
* lib/encrypt.c: Do not check fprintf return value.
Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog 2010-08-21 20:37:23 UTC (rev 3229)
+++ upstream/trunk/ChangeLog 2010-08-22 12:49:07 UTC (rev 3230)
@@ -1,3 +1,27 @@
+2010-08-22 Nicolas François <nicolas.francois at centraliens.net>
+
+ * libmisc/obscure.c, lib/prototypes.h (obscure): Return a bool
+ instead of an int.
+ * libmisc/obscure.c, libmisc/tz.c, src/passwd.c, lib/encrypt.c,
+ libmisc/copydir.c, lib/prototypes.h: Add splint annotations.
+ * libmisc/tz.c: Fix some const issues.
+ * libmisc/tz.c: Avoid multi-statements lines.
+ * libmisc/tz.c: Add brackets.
+ * libmisc/copydir.c: Do not check *printf/*puts return value.
+ * libmisc/copydir.c: Fail if we cannot set or reset the SELinux
+ fscreate context.
+ * libmisc/copydir.c: Use xmalloc instead of malloc.
+ * libmisc/copydir.c: Do not check lutimes return value
+ * src/vipw.c: Avoid implicit conversion of integer to boolean.
+ * src/su.c (iswheel): Return a bool instead of an int.
+ * src/passwd.c: Remove insert_crypt_passwd(). Use xstrdup instead.
+ * src/passwd.c: Return constant strings when sufficient.
+ * src/passwd.c: Do not check *printf/*puts return value.
+ * src/passwd.c: Avoid implicit conversion of character to boolean.
+ * src/passwd.c: Do not check sleep return value.
+ * src/sulogin.c: Do not check *printf/*puts return value.
+ * lib/encrypt.c: Do not check fprintf return value.
+
2010-08-21 Nicolas François <nicolas.francois at centraliens.net>
* src/passwd.c: Fix a const issue.
Modified: upstream/trunk/lib/encrypt.c
===================================================================
--- upstream/trunk/lib/encrypt.c 2010-08-21 20:37:23 UTC (rev 3229)
+++ upstream/trunk/lib/encrypt.c 2010-08-22 12:49:07 UTC (rev 3230)
@@ -40,7 +40,7 @@
#include "prototypes.h"
#include "defines.h"
-char *pw_encrypt (const char *clear, const char *salt)
+/*@exposed@*/char *pw_encrypt (const char *clear, const char *salt)
{
static char cipher[128];
char *cp;
@@ -60,7 +60,7 @@
* supported, and return a DES encrypted password. */
if ((NULL != salt) && (salt[0] == '$') && (strlen (cp) <= 13))
{
- const char *method;
+ /*@observer@*/const char *method;
switch (salt[1])
{
case '1':
@@ -79,9 +79,9 @@
method = &nummethod[0];
}
}
- fprintf (stderr,
- _("crypt method not supported by libcrypt? (%s)\n"),
- method);
+ (void) fprintf (stderr,
+ _("crypt method not supported by libcrypt? (%s)\n"),
+ method);
exit (EXIT_FAILURE);
}
Modified: upstream/trunk/lib/prototypes.h
===================================================================
--- upstream/trunk/lib/prototypes.h 2010-08-21 20:37:23 UTC (rev 3229)
+++ upstream/trunk/lib/prototypes.h 2010-08-22 12:49:07 UTC (rev 3230)
@@ -127,7 +127,7 @@
#endif
/* encrypt.c */
-extern char *pw_encrypt (const char *, const char *);
+extern /*@exposed@*/char *pw_encrypt (const char *, const char *);
/* entry.c */
extern void pw_entry (const char *, struct passwd *);
@@ -250,7 +250,7 @@
/* obscure.c */
#ifndef USE_PAM
-extern int obscure (const char *, const char *, const struct passwd *);
+extern bool obscure (const char *, const char *, const struct passwd *);
#endif
/* pam_pass.c */
@@ -363,7 +363,7 @@
/* tz.c */
#ifndef USE_PAM
-extern char *tz (const char *);
+extern /*@observer@*/const char *tz (const char *);
#endif
/* ulimit.c */
Modified: upstream/trunk/libmisc/copydir.c
===================================================================
--- upstream/trunk/libmisc/copydir.c 2010-08-21 20:37:23 UTC (rev 3229)
+++ upstream/trunk/libmisc/copydir.c 2010-08-22 12:49:07 UTC (rev 3230)
@@ -77,7 +77,7 @@
uid_t old_uid, uid_t new_uid,
gid_t old_gid, gid_t new_gid);
#ifdef S_IFLNK
-static char *readlink_malloc (const char *filename);
+static /*@null@*/char *readlink_malloc (const char *filename);
static int copy_symlink (const char *src, const char *dst,
unused bool reset_selinux,
const struct stat *statp, const struct timeval mt[],
@@ -123,7 +123,7 @@
{
static bool selinux_checked = false;
static bool selinux_enabled;
- security_context_t scontext = NULL;
+ /*@null@*/security_context_t scontext = NULL;
if (!selinux_checked) {
selinux_enabled = is_selinux_enabled () > 0;
@@ -236,7 +236,7 @@
lp->ln_count = sb->st_nlink;
len = name_len - src_len + dst_len + 1;
lp->ln_name = (char *) xmalloc (len);
- snprintf (lp->ln_name, len, "%s%s", dst_orig, name + src_len);
+ (void) snprintf (lp->ln_name, len, "%s%s", dst_orig, name + src_len);
lp->ln_next = links;
links = lp;
@@ -342,10 +342,10 @@
* Build the filename for both the source and
* the destination files.
*/
- snprintf (src_name, src_len, "%s/%s",
- src_root, ent->d_name);
- snprintf (dst_name, dst_len, "%s/%s",
- dst_root, ent->d_name);
+ (void) snprintf (src_name, src_len, "%s/%s",
+ src_root, ent->d_name);
+ (void) snprintf (dst_name, dst_len, "%s/%s",
+ dst_root, ent->d_name);
err = copy_entry (src_name, dst_name,
reset_selinux,
@@ -374,7 +374,9 @@
#ifdef WITH_SELINUX
/* Reset SELinux to create files with default contexts */
- setfscreatecon (NULL);
+ if (setfscreatecon (NULL) != 0) {
+ err = -1;
+ }
#endif /* WITH_SELINUX */
return err;
@@ -509,7 +511,9 @@
*/
#ifdef WITH_SELINUX
- selinux_file_context (dst);
+ if (selinux_file_context (dst) != 0) {
+ return -1;
+ }
#endif /* WITH_SELINUX */
if ( (mkdir (dst, statp->st_mode) != 0)
|| (chown_if_needed (dst, statp,
@@ -545,11 +549,11 @@
* return NULL on error.
* The return string shall be freed by the caller.
*/
-static char *readlink_malloc (const char *filename)
+static /*@null@*/char *readlink_malloc (const char *filename)
{
size_t size = 1024;
- while (1) {
+ while (true) {
ssize_t nchars;
char *buffer = (char *) malloc (size);
if (NULL == buffer) {
@@ -563,7 +567,7 @@
return NULL;
}
- if ( (size_t) nchars < size) { /* The buffer was large enough */
+ if ((size_t) nchars < size) { /* The buffer was large enough */
/* readlink does not nul-terminate */
buffer[nchars] = '\0';
return buffer;
@@ -616,16 +620,19 @@
*/
if (strncmp (oldlink, src_orig, strlen (src_orig)) == 0) {
size_t len = strlen (dst_orig) + strlen (oldlink) - strlen (src_orig) + 1;
- char *dummy = (char *) malloc (len);
- snprintf (dummy, len, "%s%s",
- dst_orig,
- oldlink + strlen (src_orig));
+ char *dummy = (char *) xmalloc (len);
+ (void) snprintf (dummy, len, "%s%s",
+ dst_orig,
+ oldlink + strlen (src_orig));
free (oldlink);
oldlink = dummy;
}
#ifdef WITH_SELINUX
- selinux_file_context (dst);
+ if (selinux_file_context (dst) != 0) {
+ free (oldlink);
+ return -1;
+ }
#endif /* WITH_SELINUX */
if ( (symlink (oldlink, dst) != 0)
|| (lchown_if_needed (dst, statp,
@@ -648,7 +655,7 @@
* it returns ENOSYS on many system
* - not implemented
*/
- lutimes (dst, mt);
+ (void) lutimes (dst, mt);
#endif /* HAVE_LUTIMES */
return 0;
@@ -701,7 +708,9 @@
int err = 0;
#ifdef WITH_SELINUX
- selinux_file_context (dst);
+ if (selinux_file_context (dst) != 0) {
+ return -1;
+ }
#endif /* WITH_SELINUX */
if ( (mknod (dst, statp->st_mode & ~07777, statp->st_rdev) != 0)
@@ -756,7 +765,9 @@
return -1;
}
#ifdef WITH_SELINUX
- selinux_file_context (dst);
+ if (selinux_file_context (dst) != 0) {
+ return -1;
+ }
#endif /* WITH_SELINUX */
ofd = open (dst, O_WRONLY | O_CREAT | O_TRUNC, statp->st_mode & 07777);
if ( (ofd < 0)
Modified: upstream/trunk/libmisc/obscure.c
===================================================================
--- upstream/trunk/libmisc/obscure.c 2010-08-21 20:37:23 UTC (rev 3229)
+++ upstream/trunk/libmisc/obscure.c 2010-08-22 12:49:07 UTC (rev 3230)
@@ -304,15 +304,15 @@
* check passwords.
*/
-int obscure (const char *old, const char *new, const struct passwd *pwdp)
+bool obscure (const char *old, const char *new, const struct passwd *pwdp)
{
const char *msg = obscure_msg (old, new, pwdp);
if (NULL != msg) {
printf (_("Bad password: %s. "), msg);
- return 0;
+ return false;
}
- return 1;
+ return true;
}
#else /* !USE_PAM */
Modified: upstream/trunk/libmisc/tz.c
===================================================================
--- upstream/trunk/libmisc/tz.c 2010-08-21 20:37:23 UTC (rev 3229)
+++ upstream/trunk/libmisc/tz.c 2010-08-22 12:49:07 UTC (rev 3230)
@@ -49,23 +49,28 @@
* tz() determines the name of the local timezone by reading the
* contents of the file named by ``fname''.
*/
-char *tz (const char *fname)
+/*@observer@*/const char *tz (const char *fname)
{
- FILE *fp = 0;
+ FILE *fp = NULL;
static char tzbuf[BUFSIZ];
const char *def_tz = "TZ=CST6CDT";
- if ((fp = fopen (fname, "r")) == NULL ||
- fgets (tzbuf, (int) sizeof (tzbuf), fp) == NULL) {
- if (!(def_tz = getdef_str ("ENV_TZ")) || def_tz[0] == '/')
+ fp = fopen (fname, "r");
+ if ( (NULL == fp)
+ || (fgets (tzbuf, (int) sizeof (tzbuf), fp) == NULL)) {
+ def_tz = getdef_str ("ENV_TZ");
+ if ((NULL == def_tz) || ('/' == def_tz[0])) {
def_tz = "TZ=CST6CDT";
+ }
strcpy (tzbuf, def_tz);
- } else
+ } else {
tzbuf[strlen (tzbuf) - 1] = '\0';
+ }
- if (fp)
+ if (NULL != fp) {
(void) fclose (fp);
+ }
return tzbuf;
}
Modified: upstream/trunk/src/passwd.c
===================================================================
--- upstream/trunk/src/passwd.c 2010-08-21 20:37:23 UTC (rev 3229)
+++ upstream/trunk/src/passwd.c 2010-08-22 12:49:07 UTC (rev 3230)
@@ -131,20 +131,19 @@
*/
/* local function prototypes */
-static void usage (int);
+static /*@noreturn@*/void usage (int);
#ifndef USE_PAM
-static int reuse (const char *, const struct passwd *);
+static bool reuse (const char *, const struct passwd *);
static int new_password (const struct passwd *);
static void check_password (const struct passwd *, const struct spwd *);
-static char *insert_crypt_passwd (const char *, const char *);
#endif /* !USE_PAM */
-static char *date_to_str (time_t);
-static const char *pw_status (const char *);
+static /*@observer@*/const char *date_to_str (time_t);
+static /*@observer@*/const char *pw_status (const char *);
static void print_status (const struct passwd *);
-static void fail_exit (int);
-static void oom (void);
+static /*@noreturn@*/void fail_exit (int);
+static /*@noreturn@*/void oom (void);
static char *update_crypt_pw (char *);
static void update_noshadow (void);
@@ -158,8 +157,9 @@
/*
* usage - print command usage and exit
*/
-static void usage (int status)
+static /*@noreturn@*/void usage (int status)
{
+ (void)
fputs (_("Usage: passwd [options] [LOGIN]\n"
"\n"
"Options:\n"
@@ -185,7 +185,7 @@
}
#ifndef USE_PAM
-static int reuse (const char *pass, const struct passwd *pw)
+static bool reuse (const char *pass, const struct passwd *pw)
{
#ifdef HAVE_LIBCRACK_HIST
const char *reason;
@@ -200,11 +200,11 @@
reason = FascistHistory (pass, pw->pw_uid);
#endif /* !HAVE_LIBCRACK_PW */
if (NULL != reason) {
- printf (_("Bad password: %s. "), reason);
- return 1;
+ (void) printf (_("Bad password: %s. "), reason);
+ return true;
}
#endif /* HAVE_LIBCRACK_HIST */
- return 0;
+ return false;
}
/*
@@ -219,7 +219,7 @@
char orig[200]; /* Original password */
char pass[200]; /* New password */
int i; /* Counter for retries */
- int warned;
+ bool warned;
int pass_max_len = -1;
const char *method;
@@ -232,7 +232,7 @@
* password.
*/
- if (!amroot && crypt_passwd[0]) {
+ if (!amroot && ('\0' != crypt_passwd[0])) {
clear = getpass (_("Old password: "));
if (NULL == clear) {
return -1;
@@ -240,12 +240,14 @@
cipher = pw_encrypt (clear, crypt_passwd);
if (strcmp (cipher, crypt_passwd) != 0) {
+ strzero (clear);
+ strzero (cipher);
SYSLOG ((LOG_WARN, "incorrect password for %s",
- pw->pw_name));
- sleep (1);
- fprintf (stderr,
- _("Incorrect password for %s.\n"),
- pw->pw_name);
+ pw->pw_name));
+ (void) sleep (1);
+ (void) fprintf (stderr,
+ _("Incorrect password for %s.\n"),
+ pw->pw_name);
return -1;
}
STRFCPY (orig, clear);
@@ -280,19 +282,19 @@
}
if (!qflg) {
if (pass_max_len == -1) {
- printf (_(
+ (void) printf (_(
"Enter the new password (minimum of %d characters)\n"
"Please use a combination of upper and lower case letters and numbers.\n"),
getdef_num ("PASS_MIN_LEN", 5));
} else {
- printf (_(
+ (void) printf (_(
"Enter the new password (minimum of %d, maximum of %d characters)\n"
"Please use a combination of upper and lower case letters and numbers.\n"),
getdef_num ("PASS_MIN_LEN", 5), pass_max_len);
}
}
- warned = 0;
+ warned = false;
for (i = getdef_num ("PASS_CHANGE_TRIES", 5); i > 0; i--) {
cp = getpass (_("New password: "));
if (NULL == cp) {
@@ -300,13 +302,13 @@
return -1;
}
if (warned && (strcmp (pass, cp) != 0)) {
- warned = 0;
+ warned = false;
}
STRFCPY (pass, cp);
strzero (cp);
if (!amroot && (!obscure (orig, pass, pw) || reuse (pass, pw))) {
- puts (_("Try again."));
+ (void) puts (_("Try again."));
continue;
}
@@ -317,8 +319,8 @@
*/
if (amroot && !warned && getdef_bool ("PASS_ALWAYS_WARN")
&& (!obscure (orig, pass, pw) || reuse (pass, pw))) {
- puts (_("\nWarning: weak password (enter it again to use it anyway)."));
- warned++;
+ (void) puts (_("\nWarning: weak password (enter it again to use it anyway)."));
+ warned = true;
continue;
}
cp = getpass (_("Re-enter new password: "));
@@ -327,7 +329,7 @@
return -1;
}
if (strcmp (cp, pass) != 0) {
- fputs (_("They don't match; try again.\n"), stderr);
+ (void) fputs (_("They don't match; try again.\n"), stderr);
} else {
strzero (cp);
break;
@@ -393,9 +395,9 @@
|| (exp_status > 1)
|| ( (sp->sp_max >= 0)
&& (sp->sp_min > sp->sp_max))) {
- fprintf (stderr,
- _("The password for %s cannot be changed.\n"),
- sp->sp_namp);
+ (void) fprintf (stderr,
+ _("The password for %s cannot be changed.\n"),
+ sp->sp_namp);
SYSLOG ((LOG_WARN, "password locked for '%s'", sp->sp_namp));
closelog ();
exit (E_NOPERM);
@@ -410,42 +412,33 @@
ok = last + (sp->sp_min > 0 ? sp->sp_min * SCALE : 0);
if (now < ok) {
- fprintf (stderr,
- _("The password for %s cannot be changed yet.\n"),
- pw->pw_name);
+ (void) fprintf (stderr,
+ _("The password for %s cannot be changed yet.\n"),
+ pw->pw_name);
SYSLOG ((LOG_WARN, "now < minimum age for '%s'", pw->pw_name));
closelog ();
exit (E_NOPERM);
}
}
}
-
-/*
- * insert_crypt_passwd - add an "old-style" password to authentication
- * string result now malloced to avoid overflow, just in case. --marekm
- */
-static char *insert_crypt_passwd (const char *string, const char *passwd)
-{
- return xstrdup (passwd);
-}
#endif /* !USE_PAM */
-static char *date_to_str (time_t t)
+static /*@observer@*/const char *date_to_str (time_t t)
{
static char buf[80];
struct tm *tm;
tm = gmtime (&t);
#ifdef HAVE_STRFTIME
- strftime (buf, sizeof buf, "%m/%d/%Y", tm);
+ (void) strftime (buf, sizeof buf, "%m/%d/%Y", tm);
#else /* !HAVE_STRFTIME */
- snprintf (buf, sizeof buf, "%02d/%02d/%04d",
- tm->tm_mon + 1, tm->tm_mday, tm->tm_year + 1900);
+ (void) snprintf (buf, sizeof buf, "%02d/%02d/%04d",
+ tm->tm_mon + 1, tm->tm_mday, tm->tm_year + 1900);
#endif /* !HAVE_STRFTIME */
return buf;
}
-static const char *pw_status (const char *pass)
+static /*@observer@*/const char *pw_status (const char *pass)
{
if (*pass == '*' || *pass == '!') {
return "L";
@@ -465,25 +458,26 @@
sp = getspnam (pw->pw_name); /* local, no need for xgetspnam */
if (NULL != sp) {
- printf ("%s %s %s %ld %ld %ld %ld\n",
- pw->pw_name,
- pw_status (sp->sp_pwdp),
- date_to_str (sp->sp_lstchg * SCALE),
- (sp->sp_min * SCALE) / DAY,
- (sp->sp_max * SCALE) / DAY,
- (sp->sp_warn * SCALE) / DAY,
- (sp->sp_inact * SCALE) / DAY);
+ (void) printf ("%s %s %s %ld %ld %ld %ld\n",
+ pw->pw_name,
+ pw_status (sp->sp_pwdp),
+ date_to_str (sp->sp_lstchg * SCALE),
+ (sp->sp_min * SCALE) / DAY,
+ (sp->sp_max * SCALE) / DAY,
+ (sp->sp_warn * SCALE) / DAY,
+ (sp->sp_inact * SCALE) / DAY);
} else {
- printf ("%s %s\n", pw->pw_name, pw_status (pw->pw_passwd));
+ (void) printf ("%s %s\n",
+ pw->pw_name, pw_status (pw->pw_passwd));
}
}
-static void fail_exit (int status)
+static /*@noreturn@*/void fail_exit (int status)
{
if (pw_locked) {
if (pw_unlock () == 0) {
- fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
+ (void) fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
/* continue */
}
@@ -491,7 +485,7 @@
if (spw_locked) {
if (spw_unlock () == 0) {
- fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ());
+ (void) fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ());
SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ()));
/* continue */
}
@@ -500,9 +494,9 @@
exit (status);
}
-static void oom (void)
+static /*@noreturn@*/void oom (void)
{
- fprintf (stderr, _("%s: out of memory\n"), Prog);
+ (void) fprintf (stderr, _("%s: out of memory\n"), Prog);
fail_exit (E_FAILURE);
}
@@ -510,7 +504,7 @@
{
#ifndef USE_PAM
if (do_update_pwd) {
- cp = insert_crypt_passwd (cp, crypt_passwd);
+ cp = xstrdup (crypt_passwd);
}
#endif /* !USE_PAM */
@@ -520,10 +514,10 @@
if (uflg && *cp == '!') {
if (cp[1] == '\0') {
- fprintf (stderr,
- _("%s: unlocking the password would result in a passwordless account.\n"
- "You should set a password with usermod -p to unlock the password of this account.\n"),
- Prog);
+ (void) fprintf (stderr,
+ _("%s: unlocking the password would result in a passwordless account.\n"
+ "You should set a password with usermod -p to unlock the password of this account.\n"),
+ Prog);
fail_exit (E_FAILURE);
} else {
cp++;
@@ -547,24 +541,24 @@
struct passwd *npw;
if (pw_lock () == 0) {
- fprintf (stderr,
- _("%s: cannot lock %s; try again later.\n"),
- Prog, pw_dbname ());
+ (void) fprintf (stderr,
+ _("%s: cannot lock %s; try again later.\n"),
+ Prog, pw_dbname ());
exit (E_PWDBUSY);
}
pw_locked = true;
if (pw_open (O_RDWR) == 0) {
- fprintf (stderr,
- _("%s: cannot open %s\n"),
- Prog, pw_dbname ());
+ (void) fprintf (stderr,
+ _("%s: cannot open %s\n"),
+ Prog, pw_dbname ());
SYSLOG ((LOG_WARN, "cannot open %s", pw_dbname ()));
fail_exit (E_MISSING);
}
pw = pw_locate (name);
if (NULL == pw) {
- fprintf (stderr,
- _("%s: user '%s' does not exist in %s\n"),
- Prog, name, pw_dbname ());
+ (void) fprintf (stderr,
+ _("%s: user '%s' does not exist in %s\n"),
+ Prog, name, pw_dbname ());
fail_exit (E_NOPERM);
}
npw = __pw_dup (pw);
@@ -573,20 +567,22 @@
}
npw->pw_passwd = update_crypt_pw (npw->pw_passwd);
if (pw_update (npw) == 0) {
- fprintf (stderr,
- _("%s: failed to prepare the new %s entry '%s'\n"),
- Prog, pw_dbname (), npw->pw_name);
+ (void) fprintf (stderr,
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, pw_dbname (), npw->pw_name);
fail_exit (E_FAILURE);
}
if (pw_close () == 0) {
- fprintf (stderr,
- _("%s: failure while writing changes to %s\n"),
- Prog, pw_dbname ());
+ (void) fprintf (stderr,
+ _("%s: failure while writing changes to %s\n"),
+ Prog, pw_dbname ());
SYSLOG ((LOG_ERR, "failure while writing changes to %s", pw_dbname ()));
fail_exit (E_FAILURE);
}
if (pw_unlock () == 0) {
- fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ());
+ (void) fprintf (stderr,
+ _("%s: failed to unlock %s\n"),
+ Prog, pw_dbname ());
SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
/* continue */
}
@@ -599,14 +595,16 @@
struct spwd *nsp;
if (spw_lock () == 0) {
- fprintf (stderr,
- _("%s: cannot lock %s; try again later.\n"),
- Prog, spw_dbname ());
+ (void) fprintf (stderr,
+ _("%s: cannot lock %s; try again later.\n"),
+ Prog, spw_dbname ());
exit (E_PWDBUSY);
}
spw_locked = true;
if (spw_open (O_RDWR) == 0) {
- fprintf (stderr, _("%s: cannot open %s\n"), Prog, spw_dbname ());
+ (void) fprintf (stderr,
+ _("%s: cannot open %s\n"),
+ Prog, spw_dbname ());
SYSLOG ((LOG_WARN, "cannot open %s", spw_dbname ()));
fail_exit (E_FAILURE);
}
@@ -616,7 +614,9 @@
(void) spw_close ();
update_noshadow ();
if (spw_unlock () == 0) {
- fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ());
+ (void) fprintf (stderr,
+ _("%s: failed to unlock %s\n"),
+ Prog, spw_dbname ());
SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ()));
/* continue */
}
@@ -661,20 +661,22 @@
}
if (spw_update (nsp) == 0) {
- fprintf (stderr,
- _("%s: failed to prepare the new %s entry '%s'\n"),
- Prog, spw_dbname (), nsp->sp_namp);
+ (void) fprintf (stderr,
+ _("%s: failed to prepare the new %s entry '%s'\n"),
+ Prog, spw_dbname (), nsp->sp_namp);
fail_exit (E_FAILURE);
}
if (spw_close () == 0) {
- fprintf (stderr,
- _("%s: failure while writing changes to %s\n"),
- Prog, spw_dbname ());
+ (void) fprintf (stderr,
+ _("%s: failure while writing changes to %s\n"),
+ Prog, spw_dbname ());
SYSLOG ((LOG_ERR, "failure while writing changes to %s", spw_dbname ()));
fail_exit (E_FAILURE);
}
if (spw_unlock () == 0) {
- fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ());
+ (void) fprintf (stderr,
+ _("%s: failed to unlock %s\n"),
+ Prog, spw_dbname ());
SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ()));
/* continue */
}
@@ -880,9 +882,9 @@
case 'w':
if ( (getlong (optarg, &warn) == 0)
|| (warn < -1)) {
- fprintf (stderr,
- _("%s: invalid numeric argument '%s'\n"),
- Prog, optarg);
+ (void) fprintf (stderr,
+ _("%s: invalid numeric argument '%s'\n"),
+ Prog, optarg);
usage (E_BAD_ARG);
}
wflg = true;
@@ -891,9 +893,9 @@
case 'x':
if ( (getlong (optarg, &age_max) == 0)
|| (age_max < -1)) {
- fprintf (stderr,
- _("%s: invalid numeric argument '%s'\n"),
- Prog, optarg);
+ (void) fprintf (stderr,
+ _("%s: invalid numeric argument '%s'\n"),
+ Prog, optarg);
usage (E_BAD_ARG);
}
xflg = true;
@@ -901,7 +903,7 @@
break;
case 'h':
usage (E_SUCCESS);
- break;
+ /*@notreached@*/break;
default:
usage (E_BAD_ARG);
}
@@ -915,8 +917,9 @@
*/
pw = get_my_pwent ();
if (NULL == pw) {
- fprintf (stderr,
- _("%s: Cannot determine your user name.\n"), Prog);
+ (void) fprintf (stderr,
+ _("%s: Cannot determine your user name.\n"),
+ Prog);
SYSLOG ((LOG_WARN, "Cannot determine the user name of the caller (UID %lu)",
(unsigned long) getuid ()));
exit (E_NOPERM);
@@ -944,7 +947,9 @@
usage (E_USAGE);
}
if (!amroot) {
- fprintf (stderr, _("%s: Permission denied.\n"), Prog);
+ (void) fprintf (stderr,
+ _("%s: Permission denied.\n"),
+ Prog);
exit (E_NOPERM);
}
setpwent ();
@@ -984,13 +989,15 @@
}
if (anyflag && !amroot) {
- fprintf (stderr, _("%s: Permission denied.\n"), Prog);
+ (void) fprintf (stderr, _("%s: Permission denied.\n"), Prog);
exit (E_NOPERM);
}
pw = xgetpwnam (name);
if (NULL == pw) {
- fprintf (stderr, _("%s: user '%s' does not exist\n"), Prog, name);
+ (void) fprintf (stderr,
+ _("%s: user '%s' does not exist\n"),
+ Prog, name);
exit (E_NOPERM);
}
#ifdef WITH_SELINUX
@@ -1001,14 +1008,14 @@
security_context_t user_context = NULL;
const char *user = "Unknown user context";
if (getprevcon (&user_context) == 0) {
- user = user_context;
+ user = user_context; /* FIXME: use context_user_get? */
}
SYSLOG ((LOG_ALERT,
"%s is not authorized to change the password of %s",
user, name));
- fprintf(stderr,
- _("%s: %s is not authorized to change the password of %s\n"),
- Prog, user, name);
+ (void) fprintf(stderr,
+ _("%s: %s is not authorized to change the password of %s\n"),
+ Prog, user, name);
if (NULL != user_context) {
freecon (user_context);
}
@@ -1021,12 +1028,12 @@
* check if I'm root.
*/
if (!amroot && (pw->pw_uid != getuid ())) {
- fprintf (stderr,
- _("%s: You may not view or modify password information for %s.\n"),
- Prog, name);
+ (void) fprintf (stderr,
+ _("%s: You may not view or modify password information for %s.\n"),
+ Prog, name);
SYSLOG ((LOG_WARN,
- "%s: can't view or modify password information for %s",
- Prog, name));
+ "%s: can't view or modify password information for %s",
+ Prog, name));
closelog ();
exit (E_NOPERM);
}
@@ -1062,13 +1069,13 @@
* Let the user know whose password is being changed.
*/
if (!qflg) {
- printf (_("Changing password for %s\n"), name);
+ (void) printf (_("Changing password for %s\n"), name);
}
- if (new_password (pw)) {
- fprintf (stderr,
- _("The password for %s is unchanged.\n"),
- name);
+ if (new_password (pw) != 0) {
+ (void) fprintf (stderr,
+ _("The password for %s is unchanged.\n"),
+ name);
closelog ();
exit (E_NOPERM);
}
@@ -1094,7 +1101,7 @@
}
#endif /* USE_PAM */
if (setuid (0) != 0) {
- fputs (_("Cannot change ID to root.\n"), stderr);
+ (void) fputs (_("Cannot change ID to root.\n"), stderr);
SYSLOG ((LOG_ERR, "can't setuid(0)"));
closelog ();
exit (E_NOPERM);
@@ -1113,10 +1120,10 @@
if (!qflg) {
if (!anyflag) {
#ifndef USE_PAM
- printf (_("%s: password changed.\n"), Prog);
+ (void) printf (_("%s: password changed.\n"), Prog);
#endif /* USE_PAM */
} else {
- printf (_("%s: password expiry information changed.\n"), Prog);
+ (void) printf (_("%s: password expiry information changed.\n"), Prog);
}
}
Modified: upstream/trunk/src/su.c
===================================================================
--- upstream/trunk/src/su.c 2010-08-21 20:37:23 UTC (rev 3229)
+++ upstream/trunk/src/su.c 2010-08-22 12:49:07 UTC (rev 3230)
@@ -112,7 +112,7 @@
static RETSIGTYPE kill_child (int unused(s));
#else /* !USE_PAM */
static RETSIGTYPE die (int);
-static int iswheel (const char *);
+static bool iswheel (const char *);
#endif /* !USE_PAM */
#ifndef USE_PAM
@@ -138,14 +138,14 @@
}
}
-static int iswheel (const char *username)
+static bool iswheel (const char *username)
{
struct group *grp;
grp = getgrnam ("wheel"); /* !USE_PAM, no need for xgetgrnam */
if ( (NULL ==grp)
|| (NULL == grp->gr_mem)) {
- return 0;
+ return false;
}
return is_on_list (grp->gr_mem, username);
}
Modified: upstream/trunk/src/sulogin.c
===================================================================
--- upstream/trunk/src/sulogin.c 2010-08-21 20:37:23 UTC (rev 3229)
+++ upstream/trunk/src/sulogin.c 2010-08-22 12:49:07 UTC (rev 3230)
@@ -126,7 +126,7 @@
}
}
if (access (PASSWD_FILE, F_OK) == -1) { /* must be a password file! */
- puts (_("No password file"));
+ (void) puts (_("No password file"));
#ifdef USE_SYSLOG
SYSLOG (LOG_WARN, "No password file\n");
closelog ();
@@ -152,7 +152,7 @@
if (getppid() == 1) {
setsid();
if (ioctl(0, TIOCSCTTY, 1) != 0) {
- fputs (_("TIOCSCTTY failed"), stderr);
+ (void) fputs (_("TIOCSCTTY failed"), stderr);
}
}
while (NULL != *envp) { /* add inherited environment, */
@@ -184,7 +184,7 @@
/*
* Fail secure
*/
- puts (_("No password entry for 'root'"));
+ (void) puts (_("No password entry for 'root'"));
#ifdef USE_SYSLOG
SYSLOG (LOG_WARN, "No password entry for 'root'\n");
closelog ();
@@ -198,10 +198,10 @@
*/
/* get a password for root */
- cp = getpass (_
- ("\n"
- "Type control-d to proceed with normal startup,\n"
- "(or give root password for system maintenance):"));
+ cp = getpass (_(
+"\n"
+"Type control-d to proceed with normal startup,\n"
+"(or give root password for system maintenance):"));
/*
* XXX - can't enter single user mode if root password is
* empty. I think this doesn't happen very often :-). But
@@ -213,7 +213,7 @@
SYSLOG (LOG_INFO, "Normal startup\n");
closelog ();
#endif
- puts ("");
+ (void) puts ("");
#ifdef TELINIT
execl (PATH_TELINIT, "telinit", RUNLEVEL, (char *) 0);
#endif
@@ -230,14 +230,14 @@
SYSLOG (LOG_WARN, "Incorrect root password\n");
#endif
sleep (2);
- puts (_("Login incorrect"));
+ (void) puts (_("Login incorrect"));
}
strzero (pass);
(void) alarm (0);
(void) signal (SIGALRM, SIG_DFL);
environ = newenvp; /* make new environment active */
- puts (_("Entering System Maintenance Mode"));
+ (void) puts (_("Entering System Maintenance Mode"));
#ifdef USE_SYSLOG
SYSLOG (LOG_INFO, "System Maintenance Mode\n");
#endif
Modified: upstream/trunk/src/vipw.c
===================================================================
--- upstream/trunk/src/vipw.c 2010-08-21 20:37:23 UTC (rev 3229)
+++ upstream/trunk/src/vipw.c 2010-08-22 12:49:07 UTC (rev 3230)
@@ -333,7 +333,7 @@
#ifdef WITH_SELINUX
/* unset the fscreatecon */
if (is_selinux_enabled ()) {
- if (setfscreatecon (NULL)) {
+ if (setfscreatecon (NULL) != 0) {
vipwexit (_("setfscreatecon () failed"), errno, 1);
}
}
More information about the Pkg-shadow-commits
mailing list