bugzilla-daemon at mindrot.org
2002-Feb-12 22:32 UTC
[Bug 110] New: bogus error messages in lastlog_get_entry()
http://bugzilla.mindrot.org/show_bug.cgi?id=110
Summary: bogus error messages in lastlog_get_entry()
Product: Portable OpenSSH
Version: -current
Platform: ix86
OS/Version: Linux
Status: NEW
Severity: minor
Priority: P2
Component: sshd
AssignedTo: openssh-unix-dev at mindrot.org
ReportedBy: peak at argo.troja.mff.cuni.cz
When sshd tries to read beyond the end of lastlog, e.g. when logging to a
high-uid user that has never logged in yet, atomicio() returns 0 and
lastlog_get_entry() generates a bogus error message for errno==0 (e.g.
"lastlog_get_entry: Error reading from /var/log/lastlog: Success").
The
following patch prevents it. Also, I made an attempt to report partial reads in
a proper way.
diff -urN openssh-3.0.2p1.old/loginrec.c openssh-3.0.2p1/loginrec.c
--- openssh-3.0.2p1.old/loginrec.c Tue Oct 30 03:50:40 2001
+++ openssh-3.0.2p1/loginrec.c Tue Feb 12 23:16:43 2002
@@ -1486,15 +1486,23 @@
lastlog_get_entry(struct logininfo *li)
{
struct lastlog last;
- int fd;
+ int fd, r;
if (!lastlog_openseek(li, &fd, O_RDONLY))
return 0;
- if (atomicio(read, fd, &last, sizeof(last)) != sizeof(last)) {
+ r = atomicio(read, fd, &last, sizeof(last));
+ if (r == 0) {
+ /* no recorded login */
+ memset(&last, '\0', sizeof(last));
+ } else if (r != sizeof(last)) {
close(fd);
- log("lastlog_get_entry: Error reading from %s: %s",
- LASTLOG_FILE, strerror(errno));
+ if (r == -1)
+ log("lastlog_get_entry: Error reading from %s: %s",
+ LASTLOG_FILE, strerror(errno));
+ else
+ log("lastlog_get_entry: Error reading from %s: read %d bytes, expected
%d",
+ LASTLOG_FILE, r, sizeof(last));
return 0;
}
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
Possibly Parallel Threads
- [Bug 492] New: Spurious error message from loginrec when attempting to login in with the highest uid for the first time.
- [PATCH] openssh - loginrec.c - Non-atomic file operations.
- lastlog_get_entry error on IRIX
- [2.1.1p4] utmp related patches plus unresolved bugs description
- [2.1.1p4] utmp patch for SunOS 4.1.x
