From 52fe9f62f6ed77e1504491f7f058e80ed44c7dcf Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Sun, 15 Jun 2008 00:01:46 +0000 Subject: [PATCH] * 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. --- ChangeLog | 7 +++++++ libmisc/failure.c | 30 +++++++++++++++++++----------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 70014017..0082fe10 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-06-15 Nicolas François + + * 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 * lib/defines.h: Avoid implicit conversion of pointers to diff --git a/libmisc/failure.c b/libmisc/failure.c index 0196fd14..cae4f876 100644 --- a/libmisc/failure.c +++ b/libmisc/failure.c @@ -250,7 +250,7 @@ void failprint (const struct faillog *fail) /* * Print all information we have. */ - strftime (lasttimeb, sizeof lasttimeb, "%c", tp); + (void) strftime (lasttimeb, sizeof lasttimeb, "%c", tp); #else /* @@ -271,12 +271,12 @@ void failprint (const struct faillog *fail) lasttime++; } #endif - printf (ngettext ("%d failure since last login.\n" - "Last was %s on %s.\n", - "%d failures since last login.\n" - "Last was %s on %s.\n", - (unsigned long) fail->fail_cnt), - fail->fail_cnt, lasttime, fail->fail_line); + (void) printf (ngettext ("%d failure since last login.\n" + "Last was %s on %s.\n", + "%d failures since last login.\n" + "Last was %s on %s.\n", + (unsigned long) fail->fail_cnt), + fail->fail_cnt, lasttime, fail->fail_line); } /* @@ -318,9 +318,13 @@ void failtmp ( fd = open (ftmp, O_WRONLY | O_APPEND); 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, - "Can't append failure of UID %lu to %s.", - (unsigned long) uid, ftmp)); + "Can't append failure of user %s to %s.", + ut_user, ftmp)); return; } @@ -330,9 +334,13 @@ void failtmp ( if ( (write (fd, (const void *) failent, sizeof *failent) != (ssize_t) sizeof *failent) || (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, - "Can't append failure of UID %lu to %s.", - (unsigned long) uid, ftmp)); + "Can't append failure of user %s to %s.", + ut_user, ftmp)); } }