- (djm) [loginrec.c] Check that seek succeeded here too; ok dtucker
This commit is contained in:
parent
36f4965020
commit
8140959de0
|
@ -5,6 +5,7 @@
|
|||
openbsd-compat/bsd-closefrom.c openbsd-compat/bsd-misc.c
|
||||
openbsd-compat/bsd-misc.h openbsd-compat/openbsd-compat.h] Use smarter
|
||||
closefrom() replacement from sudo; ok dtucker@
|
||||
- (djm) [loginrec.c] Check that seek succeeded here too; ok dtucker
|
||||
|
||||
20040814
|
||||
- (dtucker) [auth-krb5.c gss-serv-krb5.c openbsd-compat/xmmap.c]
|
||||
|
@ -1639,4 +1640,4 @@
|
|||
- (djm) Trim deprecated options from INSTALL. Mention UsePAM
|
||||
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
|
||||
|
||||
$Id: ChangeLog,v 1.3510 2004/08/15 08:40:59 djm Exp $
|
||||
$Id: ChangeLog,v 1.3511 2004/08/15 09:12:52 djm Exp $
|
||||
|
|
31
loginrec.c
31
loginrec.c
|
@ -158,7 +158,7 @@
|
|||
#include "log.h"
|
||||
#include "atomicio.h"
|
||||
|
||||
RCSID("$Id: loginrec.c,v 1.57 2004/08/14 14:09:11 dtucker Exp $");
|
||||
RCSID("$Id: loginrec.c,v 1.58 2004/08/15 09:12:52 djm Exp $");
|
||||
|
||||
#ifdef HAVE_UTIL_H
|
||||
# include <util.h>
|
||||
|
@ -818,8 +818,8 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut)
|
|||
endttyent();
|
||||
|
||||
if((struct ttyent *)0 == ty) {
|
||||
logit("utmp_write_entry: tty not found");
|
||||
return(1);
|
||||
logit("%s: tty not found", __func__);
|
||||
return (0);
|
||||
}
|
||||
#else /* FIXME */
|
||||
|
||||
|
@ -828,7 +828,18 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut)
|
|||
#endif /* HAVE_GETTTYENT */
|
||||
|
||||
if (tty > 0 && (fd = open(UTMP_FILE, O_RDWR|O_CREAT, 0644)) >= 0) {
|
||||
(void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET);
|
||||
off_t pos, ret;
|
||||
|
||||
pos = (off_t)tty * sizeof(struct utmp);
|
||||
if ((ret = lseek(fd, pos, SEEK_SET)) == -1) {
|
||||
logit("%s: llseek: %s", strerror(errno));
|
||||
return (0);
|
||||
}
|
||||
if (ret != pos) {
|
||||
logit("%s: Couldn't seek to tty %s slot in %s", tty,
|
||||
UTMP_FILE);
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* Prevent luser from zero'ing out ut_host.
|
||||
* If the new ut_line is empty but the old one is not
|
||||
|
@ -841,9 +852,17 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut)
|
|||
(void)memcpy(ut->ut_host, old_ut.ut_host, sizeof(ut->ut_host));
|
||||
}
|
||||
|
||||
(void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET);
|
||||
if ((ret = lseek(fd, pos, SEEK_SET)) == -1) {
|
||||
logit("%s: llseek: %s", __func__, strerror(errno));
|
||||
return (0);
|
||||
}
|
||||
if (ret != pos) {
|
||||
logit("%s: Couldn't seek to tty %s slot in %s",
|
||||
__func__, tty, UTMP_FILE);
|
||||
return (0);
|
||||
}
|
||||
if (atomicio(vwrite, fd, ut, sizeof(*ut)) != sizeof(*ut))
|
||||
logit("utmp_write_direct: error writing %s: %s",
|
||||
logit("%s: error writing %s: %s", __func__,
|
||||
UTMP_FILE, strerror(errno));
|
||||
|
||||
(void)close(fd);
|
||||
|
|
Loading…
Reference in New Issue