* libmisc/failure.c: Ignore the return value of strftime() and

printf().
	* libmisc/failure.c: Fix syslog call. The UID is not available.
	User the username specified in the utmp/utmpx entry.
This commit is contained in:
nekral-guest 2008-06-15 00:01:46 +00:00
parent f42160862a
commit 52fe9f62f6
2 changed files with 26 additions and 11 deletions

View File

@ -1,3 +1,10 @@
2008-06-15 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/failure.c: Ignore the return value of strftime() and
printf().
* libmisc/failure.c: Fix syslog call. The UID is not available.
User the username specified in the utmp/utmpx entry.
2008-06-15 Nicolas François <nicolas.francois@centraliens.net> 2008-06-15 Nicolas François <nicolas.francois@centraliens.net>
* lib/defines.h: Avoid implicit conversion of pointers to * lib/defines.h: Avoid implicit conversion of pointers to

View File

@ -250,7 +250,7 @@ void failprint (const struct faillog *fail)
/* /*
* Print all information we have. * Print all information we have.
*/ */
strftime (lasttimeb, sizeof lasttimeb, "%c", tp); (void) strftime (lasttimeb, sizeof lasttimeb, "%c", tp);
#else #else
/* /*
@ -271,7 +271,7 @@ void failprint (const struct faillog *fail)
lasttime++; lasttime++;
} }
#endif #endif
printf (ngettext ("%d failure since last login.\n" (void) printf (ngettext ("%d failure since last login.\n"
"Last was %s on %s.\n", "Last was %s on %s.\n",
"%d failures since last login.\n" "%d failures since last login.\n"
"Last was %s on %s.\n", "Last was %s on %s.\n",
@ -318,9 +318,13 @@ void failtmp (
fd = open (ftmp, O_WRONLY | O_APPEND); fd = open (ftmp, O_WRONLY | O_APPEND);
if (-1 == fd) { if (-1 == fd) {
char ut_user[sizeof failent->ut_user];
(void) strncpy (&ut_user[0], failent->ut_user, sizeof ut_user);
ut_user[sizeof ut_user - 1] = '\0';
SYSLOG ((LOG_WARN, SYSLOG ((LOG_WARN,
"Can't append failure of UID %lu to %s.", "Can't append failure of user %s to %s.",
(unsigned long) uid, ftmp)); ut_user, ftmp));
return; return;
} }
@ -330,9 +334,13 @@ void failtmp (
if ( (write (fd, (const void *) failent, sizeof *failent) != (ssize_t) sizeof *failent) if ( (write (fd, (const void *) failent, sizeof *failent) != (ssize_t) sizeof *failent)
|| (close (fd) != 0)) { || (close (fd) != 0)) {
char ut_user[sizeof failent->ut_user];
(void) strncpy (&ut_user[0], failent->ut_user, sizeof ut_user);
ut_user[sizeof ut_user - 1] = '\0';
SYSLOG ((LOG_WARN, SYSLOG ((LOG_WARN,
"Can't append failure of UID %lu to %s.", "Can't append failure of user %s to %s.",
(unsigned long) uid, ftmp)); ut_user, ftmp));
} }
} }