[Pkg-shadow-commits] r3639 - in upstream/trunk: . src
Nicolas FRANÇOIS
nekral-guest at alioth.debian.org
Sat Nov 19 21:44:36 UTC 2011
Author: nekral-guest
Date: 2011-11-19 21:44:34 +0000 (Sat, 19 Nov 2011)
New Revision: 3639
Modified:
upstream/trunk/ChangeLog
upstream/trunk/src/faillog.c
Log:
* src/faillog.c: The fail_max field is a short, use a short also
for the max argument of setmax / setmax_one.
* src/faillog.c: Fail with an error message when faillog fails to
write to the faillog database.
Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog 2011-11-19 15:13:17 UTC (rev 3638)
+++ upstream/trunk/ChangeLog 2011-11-19 21:44:34 UTC (rev 3639)
@@ -1,5 +1,12 @@
2011-11-19 Nicolas François <nicolas.francois at centraliens.net>
+ * src/faillog.c: The fail_max field is a short, use a short also
+ for the max argument of setmax / setmax_one.
+ * src/faillog.c: Fail with an error message when faillog fails to
+ write to the faillog database.
+
+2011-11-19 Nicolas François <nicolas.francois at centraliens.net>
+
* man/gpasswd.1.xml: Document the difference between the -r and -R
options.
Modified: upstream/trunk/src/faillog.c
===================================================================
--- upstream/trunk/src/faillog.c 2011-11-19 15:13:17 UTC (rev 3638)
+++ upstream/trunk/src/faillog.c 2011-11-19 21:44:34 UTC (rev 3639)
@@ -52,8 +52,8 @@
static void print_one (/*@null@*/const struct passwd *pw, bool force);
static void set_locktime (long locktime);
static bool set_locktime_one (uid_t uid, long locktime);
-static void setmax (int max);
-static bool setmax_one (uid_t uid, int max);
+static void setmax (short max);
+static bool setmax_one (uid_t uid, short max);
static void print (void);
static bool reset_one (uid_t uid);
static void reset (void);
@@ -329,7 +329,7 @@
*
* This returns a boolean indicating if an error occurred.
*/
-static bool setmax_one (uid_t uid, int max)
+static bool setmax_one (uid_t uid, short max)
{
off_t offset;
struct faillog fl;
@@ -381,7 +381,7 @@
return true;
}
-static void setmax (int max)
+static void setmax (short max)
{
if (uflg && has_umin && has_umax && (umin==umax)) {
if (setmax_one ((uid_t)umin, max)) {
@@ -476,10 +476,10 @@
}
if (locktime == fl.fail_locktime) {
- /* If the max is already set to the right value, do not
+ /* If the locktime is already set to the right value, do not
* write in the file.
* This avoids writing 0 when no entries were present for
- * the user and the max argument is 0.
+ * the user and the locktime argument is 0.
*/
return false;
}
@@ -561,7 +561,7 @@
int main (int argc, char **argv)
{
long fail_locktime;
- long fail_max;
+ short fail_max;
long days;
/*
@@ -608,14 +608,19 @@
lflg = true;
break;
case 'm':
- if (getlong (optarg, &fail_max) == 0) {
+ {
+ long int lmax;
+ if ( (getlong (optarg, &lmax) == 0)
+ || ((long int)(short) lmax != lmax)) {
fprintf (stderr,
_("%s: invalid numeric argument '%s'\n"),
Prog, optarg);
exit (E_BAD_ARG);
}
+ fail_max = (short) lmax;
mflg = true;
break;
+ }
case 'r':
rflg = true;
break;
@@ -716,7 +721,20 @@
print ();
}
- fclose (fail);
+ if (lflg || mflg || rflg) {
+ if ( (ferror (fail) != 0)
+ || (fflush (fail) != 0)
+ || (fsync (fileno (fail)) != 0)
+ || (fclose (fail) != 0)) {
+ fprintf (stderr,
+ _("%s: Failed to write %s: %s\n"),
+ Prog, FAILLOG_FILE, strerror (errno));
+ (void) fclose (fail);
+ errors = true;
+ }
+ } else {
+ (void) fclose (fail);
+ }
exit (errors ? E_NOPERM : E_SUCCESS);
}
More information about the Pkg-shadow-commits
mailing list