[Pkg-shadow-commits] r2137 - in upstream/trunk: . libmisc
nekral-guest at alioth.debian.org
nekral-guest at alioth.debian.org
Fri Jun 13 19:24:28 UTC 2008
Author: nekral-guest
Date: 2008-06-13 19:24:27 +0000 (Fri, 13 Jun 2008)
New Revision: 2137
Modified:
upstream/trunk/ChangeLog
upstream/trunk/libmisc/age.c
Log:
* libmisc/age.c: fork() and wait return a pid_t, not an int.
* libmisc/age.c: Avoid implicit conversion of pointers to
booleans.
* libmisc/age.c: Avoid assignments in comparisons.
* libmisc/age.c: Ignore the return value of printf(), puts(),
fputs() and fflush().
* libmisc/age.c: Add brackets and parenthesis.
* libmisc/age.c: Cast the return value of time() to long and
converted to a date.
Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog 2008-06-13 18:34:27 UTC (rev 2136)
+++ upstream/trunk/ChangeLog 2008-06-13 19:24:27 UTC (rev 2137)
@@ -1,5 +1,17 @@
2008-06-13 Nicolas François <nicolas.francois at centraliens.net>
+ * libmisc/age.c: fork() and wait return a pid_t, not an int.
+ * libmisc/age.c: Avoid implicit conversion of pointers to
+ booleans.
+ * libmisc/age.c: Avoid assignments in comparisons.
+ * libmisc/age.c: Ignore the return value of printf(), puts(),
+ fputs() and fflush().
+ * libmisc/age.c: Add brackets and parenthesis.
+ * libmisc/age.c: Cast the return value of time() to long and
+ converted to a date.
+
+2008-06-13 Nicolas François <nicolas.francois at centraliens.net>
+
* libmisc/rlogin.c: The size argument of read() is a size_t.
Propagate this time to the callers (the get_remote_string() and
do_rlogin() functions).
Modified: upstream/trunk/libmisc/age.c
===================================================================
--- upstream/trunk/libmisc/age.c 2008-06-13 18:34:27 UTC (rev 2136)
+++ upstream/trunk/libmisc/age.c 2008-06-13 19:24:27 UTC (rev 2137)
@@ -56,28 +56,30 @@
int expire (const struct passwd *pw, const struct spwd *sp)
{
int status;
- int child;
- int pid;
+ pid_t child;
+ pid_t pid;
- if (!sp)
+ if (NULL == sp) {
sp = pwd_to_spwd (pw);
+ }
/*
* See if the user's password has expired, and if so
* force them to change their password.
*/
- switch (status = isexpired (pw, sp)) {
+ status = isexpired (pw, sp);
+ switch (status) {
case 0:
return 0;
case 1:
- fputs (_("Your password has expired."), stdout);
+ (void) fputs (_("Your password has expired."), stdout);
break;
case 2:
- fputs (_("Your password is inactive."), stdout);
+ (void) fputs (_("Your password is inactive."), stdout);
break;
case 3:
- fputs (_("Your login has expired."), stdout);
+ (void) fputs (_("Your login has expired."), stdout);
break;
}
@@ -88,12 +90,12 @@
* change that password.
*/
- if (status > 1 || sp->sp_max < sp->sp_min) {
- puts (_(" Contact the system administrator."));
+ if ((status > 1) || (sp->sp_max < sp->sp_min)) {
+ (void) puts (_(" Contact the system administrator."));
exit (1);
}
- puts (_(" Choose a new password."));
- fflush (stdout);
+ (void) puts (_(" Choose a new password."));
+ (void) fflush (stdout);
/*
* Close all the files so that unauthorized access won't
@@ -115,7 +117,8 @@
* change their password before being able to use the account.
*/
- if ((pid = fork ()) == 0) {
+ pid = fork ();
+ if (0 == pid) {
int err;
/*
@@ -123,21 +126,24 @@
* passwd to work just like it would had they executed
* it from the command line while logged in.
*/
- if (setup_uid_gid (pw, 0) != 0)
+ if (setup_uid_gid (pw, 0) != 0) {
_exit (126);
+ }
execl (PASSWD_PROGRAM, PASSWD_PROGRAM, pw->pw_name, (char *) 0);
err = errno;
perror ("Can't execute " PASSWD_PROGRAM);
- _exit (err == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
- } else if (pid == -1) {
+ _exit ((ENOENT == err) ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
+ } else if ((pid_t) -1 == pid) {
perror ("fork");
exit (1);
}
- while ((child = wait (&status)) != pid && child != -1);
- if (child == pid && status == 0)
+ while (((child = wait (&status)) != pid) && (child != (pid_t)-1));
+
+ if ((child == pid) && (0 == status)) {
return 1;
+ }
exit (1);
/*NOTREACHED*/}
@@ -151,28 +157,34 @@
void agecheck (const struct passwd *pw, const struct spwd *sp)
{
- long now = time ((long *) 0) / SCALE;
+ long now = (long) time ((time_t *) 0) / SCALE;
long remain;
- if (!sp)
+ if (NULL == sp) {
sp = pwd_to_spwd (pw);
+ }
/*
* The last, max, and warn fields must be supported or the
* warning period cannot be calculated.
*/
- if (sp->sp_lstchg == -1 || sp->sp_max == -1 || sp->sp_warn == -1)
+ if ( (-1 == sp->sp_lstchg)
+ || (-1 == sp->sp_max)
+ || (-1 == sp->sp_warn)) {
return;
- if ((remain = (sp->sp_lstchg + sp->sp_max) - now) <= sp->sp_warn) {
+ }
+ remain = sp->sp_lstchg + sp->sp_max - now;
+ if (remain <= sp->sp_warn) {
remain /= DAY / SCALE;
- if (remain > 1)
- printf (_
- ("Your password will expire in %ld days.\n"),
- remain);
- else if (remain == 1)
- puts (_("Your password will expire tomorrow."));
- else if (remain == 0)
- puts (_("Your password will expire today."));
+ if (remain > 1) {
+ (void) printf (_("Your password will expire in %ld days.\n"),
+ remain);
+ } else if (1 == remain) {
+ (void) puts (_("Your password will expire tomorrow."));
+ } else if (remain == 0) {
+ (void) puts (_("Your password will expire today."));
+ }
}
}
+
More information about the Pkg-shadow-commits
mailing list