- (djm) Bug #110: bogus error messages in lastlog_get_entry(). Fix based

on one by peak@argo.troja.mff.cuni.cz
This commit is contained in:
Damien Miller 2003-01-07 16:46:58 +11:00
parent 64004b5566
commit 7df881d20e
2 changed files with 25 additions and 13 deletions

View File

@ -6,6 +6,8 @@
- (djm) Bug #26: Use local mkstemp() rather than glibc's silly one. Fixes
Can't pass KRB4 TGT passing. Fix from: jan.iven@cern.ch
- (djm) Fix Bug #442 for PAM case
- (djm) Bug #110: bogus error messages in lastlog_get_entry(). Fix based
on one by peak@argo.troja.mff.cuni.cz
20030103
- (djm) Bug #461: ssh-copy-id fails with no arguments. Patch from
@ -934,4 +936,4 @@
save auth method before monitor_reset_key_state(); bugzilla bug #284;
ok provos@
$Id: ChangeLog,v 1.2544 2003/01/07 05:15:20 djm Exp $
$Id: ChangeLog,v 1.2545 2003/01/07 05:46:58 djm Exp $

View File

@ -163,7 +163,7 @@
#include "log.h"
#include "atomicio.h"
RCSID("$Id: loginrec.c,v 1.45 2003/01/03 03:42:28 djm Exp $");
RCSID("$Id: loginrec.c,v 1.46 2003/01/07 05:46:58 djm Exp $");
#ifdef HAVE_UTIL_H
# include <util.h>
@ -1522,22 +1522,32 @@ int
lastlog_get_entry(struct logininfo *li)
{
struct lastlog last;
int fd;
int fd, ret;
if (!lastlog_openseek(li, &fd, O_RDONLY))
return 0;
return (0);
if (atomicio(read, fd, &last, sizeof(last)) != sizeof(last)) {
ret = atomicio(read, fd, &last, sizeof(last));
close(fd);
log("lastlog_get_entry: Error reading from %s: %s",
switch (ret) {
case 0:
memset(&last, '\0', sizeof(last));
/* FALLTHRU */
case sizeof(last):
lastlog_populate_entry(li, &last);
return (1);
case -1:
error("%s: Error reading from %s: %s", __func__,
LASTLOG_FILE, strerror(errno));
return 0;
return (0);
default:
error("%s: Error reading from %s: Expecting %d, got %d",
__func__, LASTLOG_FILE, sizeof(last), ret);
return (0);
}
close(fd);
lastlog_populate_entry(li, &last);
return 1;
/* NOTREACHED */
return (0);
}
#endif /* USE_LASTLOG */