[Pkg-shadow-commits] r2189 - in upstream/trunk: . src
nekral-guest at alioth.debian.org
nekral-guest at alioth.debian.org
Sun Jun 15 22:25:52 UTC 2008
Author: nekral-guest
Date: 2008-06-15 22:25:51 +0000 (Sun, 15 Jun 2008)
New Revision: 2189
Modified:
upstream/trunk/ChangeLog
upstream/trunk/src/useradd.c
Log:
* src/useradd.c: If the faillog file exist, warn in case of
failure when open(), lssek(), write() or close() fails when the
new user's faillog entry is reset.
* src/useradd.c: Ditto for the lastlog entry.
Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog 2008-06-15 21:59:41 UTC (rev 2188)
+++ upstream/trunk/ChangeLog 2008-06-15 22:25:51 UTC (rev 2189)
@@ -1,3 +1,10 @@
+2008-06-16 Nicolas François <nicolas.francois at centraliens.net>
+
+ * src/useradd.c: If the faillog file exist, warn in case of
+ failure when open(), lssek(), write() or close() fails when the
+ new user's faillog entry is reset.
+ * src/useradd.c: Ditto for the lastlog entry.
+
2008-06-15 Nicolas François <nicolas.francois at centraliens.net>
* libmisc/limits.c: Add brackets and parenthesis.
Modified: upstream/trunk/src/useradd.c
===================================================================
--- upstream/trunk/src/useradd.c 2008-06-15 21:59:41 UTC (rev 2188)
+++ upstream/trunk/src/useradd.c 2008-06-15 22:25:51 UTC (rev 2189)
@@ -1403,13 +1403,22 @@
{
struct faillog fl;
int fd;
+ off_t offset_uid = (off_t) (sizeof fl) * uid;
+ if (access (FAILLOG_FILE, F_OK) != 0) {
+ return;
+ }
+
+ memzero (&fl, sizeof (fl));
+
fd = open (FAILLOG_FILE, O_RDWR);
- if (fd >= 0) {
- memzero (&fl, sizeof (fl));
- lseek (fd, (off_t) sizeof (fl) * uid, SEEK_SET);
- write (fd, &fl, sizeof (fl));
- close (fd);
+ if ( (-1 == fd)
+ || (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
+ || (write (fd, &fl, sizeof (fl)) != (ssize_t) sizeof (fl))
+ || (close (fd) != 0)) {
+ fprintf (stderr,
+ _("%s: failed to reset the faillog entry of UID %lu: %s\n"),
+ Prog, (unsigned long) uid, strerror(errno));
}
}
@@ -1417,13 +1426,22 @@
{
struct lastlog ll;
int fd;
+ off_t offset_uid = (off_t) (sizeof ll) * uid;
+ if (access (LASTLOG_FILE, F_OK) != 0) {
+ return;
+ }
+
+ memzero (&ll, sizeof (ll));
+
fd = open (LASTLOG_FILE, O_RDWR);
- if (fd >= 0) {
- memzero (&ll, sizeof (ll));
- lseek (fd, (off_t) sizeof (ll) * uid, SEEK_SET);
- write (fd, &ll, sizeof (ll));
- close (fd);
+ if ( (-1 == fd)
+ || (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
+ || (write (fd, &ll, sizeof (ll)) != (ssize_t) sizeof (ll))
+ || (close (fd) != 0)) {
+ fprintf (stderr,
+ _("%s: failed to reset the lastlog entry of UID %lu: %s\n"),
+ Prog, (unsigned long) uid, strerror(errno));
}
}
More information about the Pkg-shadow-commits
mailing list