* lib/prototypes.h: Replace HAVE_UTMPX_H by USE_UTMPX.

* lib/prototypes.h, libmisc/log.c: Added splint annotations.
	* libmisc/log.c: Added SYSLOG warning when lseek fails (should not
	happen).
This commit is contained in:
nekral-guest 2009-04-27 20:15:09 +00:00
parent e88d1f5803
commit 851245107d
3 changed files with 24 additions and 11 deletions

View File

@ -1,3 +1,10 @@
2009-04-27 Nicolas François <nicolas.francois@centraliens.net>
* lib/prototypes.h: Replace HAVE_UTMPX_H by USE_UTMPX.
* lib/prototypes.h, libmisc/log.c: Added splint annotations.
* libmisc/log.c: Added SYSLOG warning when lseek fails (should not
happen).
2009-04-27 Nicolas François <nicolas.francois@centraliens.net> 2009-04-27 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/mail.c, libmisc/copydir.c: Added missing include of * libmisc/mail.c, libmisc/copydir.c: Added missing include of

View File

@ -43,7 +43,7 @@
#define _PROTOTYPES_H #define _PROTOTYPES_H
#include <sys/stat.h> #include <sys/stat.h>
#if HAVE_UTMPX_H #if USE_UTMPX
#include <utmpx.h> #include <utmpx.h>
#else #else
#include <utmp.h> #include <utmp.h>
@ -217,10 +217,11 @@ extern bool is_on_list (char *const *list, const char *member);
extern /*@only@*/char **comma_to_list (const char *); extern /*@only@*/char **comma_to_list (const char *);
/* log.c */ /* log.c */
extern void dolastlog (struct lastlog *ll, extern void dolastlog (
const struct passwd *pw, struct lastlog *ll,
const char *line, const struct passwd *pw,
const char *host); /*@unique@*/const char *line,
/*@unique@*/const char *host);
/* login_nopam.c */ /* login_nopam.c */
extern int login_access (const char *user, const char *from); extern int login_access (const char *user, const char *from);
@ -362,13 +363,13 @@ extern struct utmp *prepare_utmp (const char *name,
const char *host, const char *host,
/*@null@*/const struct utmp *ut); /*@null@*/const struct utmp *ut);
extern int setutmp (struct utmp *ut); extern int setutmp (struct utmp *ut);
#ifdef HAVE_UTMPX_H #ifdef USE_UTMPX
extern struct utmpx *prepare_utmpx (const char *name, extern struct utmpx *prepare_utmpx (const char *name,
const char *line, const char *line,
const char *host, const char *host,
/*@null@*/const struct utmp *ut); /*@null@*/const struct utmp *ut);
extern int setutmpx (struct utmpx *utx); extern int setutmpx (struct utmpx *utx);
#endif #endif /* USE_UTMPX */
/* valid.c */ /* valid.c */
extern bool valid (const char *, const struct passwd *); extern bool valid (const char *, const struct passwd *);

View File

@ -49,9 +49,11 @@
* UID is extracted from the global (struct passwd) entry and the * UID is extracted from the global (struct passwd) entry and the
* TTY information is gotten from the (struct utmp). * TTY information is gotten from the (struct utmp).
*/ */
void void dolastlog (
dolastlog (struct lastlog *ll, const struct passwd *pw, const char *line, struct lastlog *ll,
const char *host) const struct passwd *pw,
/*@unique@*/const char *line,
/*@unique@*/const char *host)
{ {
int fd; int fd;
off_t offset; off_t offset;
@ -75,7 +77,10 @@ dolastlog (struct lastlog *ll, const struct passwd *pw, const char *line,
offset = (off_t) pw->pw_uid * sizeof newlog; offset = (off_t) pw->pw_uid * sizeof newlog;
if (lseek (fd, offset, SEEK_SET) != offset) { if (lseek (fd, offset, SEEK_SET) != offset) {
close (fd); SYSLOG ((LOG_WARN,
"Can't read last lastlog entry for UID %lu in %s. Entry not updated.",
(unsigned long) pw->pw_uid, LASTLOG_FILE));
(void) close (fd);
return; return;
} }