summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2003-01-07 16:46:58 +1100
committerDamien Miller <djm@mindrot.org>2003-01-07 16:46:58 +1100
commit7df881d20e85ecbd389311cea999162a945774e1 (patch)
tree3e6547e9d35c679f1a2d2687ad0f2f9a75edfcf9
parent64004b5566282ceb395674e0c4aaa89e04b3847d (diff)
- (djm) Bug #110: bogus error messages in lastlog_get_entry(). Fix based
on one by peak@argo.troja.mff.cuni.cz
-rw-r--r--ChangeLog4
-rw-r--r--loginrec.c34
2 files changed, 25 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 28c340032..0ab9043a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,8 @@
6 - (djm) Bug #26: Use local mkstemp() rather than glibc's silly one. Fixes 6 - (djm) Bug #26: Use local mkstemp() rather than glibc's silly one. Fixes
7 Can't pass KRB4 TGT passing. Fix from: jan.iven@cern.ch 7 Can't pass KRB4 TGT passing. Fix from: jan.iven@cern.ch
8 - (djm) Fix Bug #442 for PAM case 8 - (djm) Fix Bug #442 for PAM case
9 - (djm) Bug #110: bogus error messages in lastlog_get_entry(). Fix based
10 on one by peak@argo.troja.mff.cuni.cz
9 11
1020030103 1220030103
11 - (djm) Bug #461: ssh-copy-id fails with no arguments. Patch from 13 - (djm) Bug #461: ssh-copy-id fails with no arguments. Patch from
@@ -934,4 +936,4 @@
934 save auth method before monitor_reset_key_state(); bugzilla bug #284; 936 save auth method before monitor_reset_key_state(); bugzilla bug #284;
935 ok provos@ 937 ok provos@
936 938
937$Id: ChangeLog,v 1.2544 2003/01/07 05:15:20 djm Exp $ 939$Id: ChangeLog,v 1.2545 2003/01/07 05:46:58 djm Exp $
diff --git a/loginrec.c b/loginrec.c
index a0d14dbdf..0a5fefad3 100644
--- a/loginrec.c
+++ b/loginrec.c
@@ -163,7 +163,7 @@
163#include "log.h" 163#include "log.h"
164#include "atomicio.h" 164#include "atomicio.h"
165 165
166RCSID("$Id: loginrec.c,v 1.45 2003/01/03 03:42:28 djm Exp $"); 166RCSID("$Id: loginrec.c,v 1.46 2003/01/07 05:46:58 djm Exp $");
167 167
168#ifdef HAVE_UTIL_H 168#ifdef HAVE_UTIL_H
169# include <util.h> 169# include <util.h>
@@ -1522,22 +1522,32 @@ int
1522lastlog_get_entry(struct logininfo *li) 1522lastlog_get_entry(struct logininfo *li)
1523{ 1523{
1524 struct lastlog last; 1524 struct lastlog last;
1525 int fd; 1525 int fd, ret;
1526 1526
1527 if (!lastlog_openseek(li, &fd, O_RDONLY)) 1527 if (!lastlog_openseek(li, &fd, O_RDONLY))
1528 return 0; 1528 return (0);
1529
1530 if (atomicio(read, fd, &last, sizeof(last)) != sizeof(last)) {
1531 close(fd);
1532 log("lastlog_get_entry: Error reading from %s: %s",
1533 LASTLOG_FILE, strerror(errno));
1534 return 0;
1535 }
1536 1529
1530 ret = atomicio(read, fd, &last, sizeof(last));
1537 close(fd); 1531 close(fd);
1538 1532
1539 lastlog_populate_entry(li, &last); 1533 switch (ret) {
1534 case 0:
1535 memset(&last, '\0', sizeof(last));
1536 /* FALLTHRU */
1537 case sizeof(last):
1538 lastlog_populate_entry(li, &last);
1539 return (1);
1540 case -1:
1541 error("%s: Error reading from %s: %s", __func__,
1542 LASTLOG_FILE, strerror(errno));
1543 return (0);
1544 default:
1545 error("%s: Error reading from %s: Expecting %d, got %d",
1546 __func__, LASTLOG_FILE, sizeof(last), ret);
1547 return (0);
1548 }
1540 1549
1541 return 1; 1550 /* NOTREACHED */
1551 return (0);
1542} 1552}
1543#endif /* USE_LASTLOG */ 1553#endif /* USE_LASTLOG */