summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--loginrec.c31
2 files changed, 27 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 841c9e68f..e5e9ea663 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@
5 openbsd-compat/bsd-closefrom.c openbsd-compat/bsd-misc.c 5 openbsd-compat/bsd-closefrom.c openbsd-compat/bsd-misc.c
6 openbsd-compat/bsd-misc.h openbsd-compat/openbsd-compat.h] Use smarter 6 openbsd-compat/bsd-misc.h openbsd-compat/openbsd-compat.h] Use smarter
7 closefrom() replacement from sudo; ok dtucker@ 7 closefrom() replacement from sudo; ok dtucker@
8 - (djm) [loginrec.c] Check that seek succeeded here too; ok dtucker
8 9
920040814 1020040814
10 - (dtucker) [auth-krb5.c gss-serv-krb5.c openbsd-compat/xmmap.c] 11 - (dtucker) [auth-krb5.c gss-serv-krb5.c openbsd-compat/xmmap.c]
@@ -1639,4 +1640,4 @@
1639 - (djm) Trim deprecated options from INSTALL. Mention UsePAM 1640 - (djm) Trim deprecated options from INSTALL. Mention UsePAM
1640 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu 1641 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
1641 1642
1642$Id: ChangeLog,v 1.3510 2004/08/15 08:40:59 djm Exp $ 1643$Id: ChangeLog,v 1.3511 2004/08/15 09:12:52 djm Exp $
diff --git a/loginrec.c b/loginrec.c
index af32b1867..f07f65fce 100644
--- a/loginrec.c
+++ b/loginrec.c
@@ -158,7 +158,7 @@
158#include "log.h" 158#include "log.h"
159#include "atomicio.h" 159#include "atomicio.h"
160 160
161RCSID("$Id: loginrec.c,v 1.57 2004/08/14 14:09:11 dtucker Exp $"); 161RCSID("$Id: loginrec.c,v 1.58 2004/08/15 09:12:52 djm Exp $");
162 162
163#ifdef HAVE_UTIL_H 163#ifdef HAVE_UTIL_H
164# include <util.h> 164# include <util.h>
@@ -818,8 +818,8 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut)
818 endttyent(); 818 endttyent();
819 819
820 if((struct ttyent *)0 == ty) { 820 if((struct ttyent *)0 == ty) {
821 logit("utmp_write_entry: tty not found"); 821 logit("%s: tty not found", __func__);
822 return(1); 822 return (0);
823 } 823 }
824#else /* FIXME */ 824#else /* FIXME */
825 825
@@ -828,7 +828,18 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut)
828#endif /* HAVE_GETTTYENT */ 828#endif /* HAVE_GETTTYENT */
829 829
830 if (tty > 0 && (fd = open(UTMP_FILE, O_RDWR|O_CREAT, 0644)) >= 0) { 830 if (tty > 0 && (fd = open(UTMP_FILE, O_RDWR|O_CREAT, 0644)) >= 0) {
831 (void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET); 831 off_t pos, ret;
832
833 pos = (off_t)tty * sizeof(struct utmp);
834 if ((ret = lseek(fd, pos, SEEK_SET)) == -1) {
835 logit("%s: llseek: %s", strerror(errno));
836 return (0);
837 }
838 if (ret != pos) {
839 logit("%s: Couldn't seek to tty %s slot in %s", tty,
840 UTMP_FILE);
841 return (0);
842 }
832 /* 843 /*
833 * Prevent luser from zero'ing out ut_host. 844 * Prevent luser from zero'ing out ut_host.
834 * If the new ut_line is empty but the old one is not 845 * 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)
841 (void)memcpy(ut->ut_host, old_ut.ut_host, sizeof(ut->ut_host)); 852 (void)memcpy(ut->ut_host, old_ut.ut_host, sizeof(ut->ut_host));
842 } 853 }
843 854
844 (void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET); 855 if ((ret = lseek(fd, pos, SEEK_SET)) == -1) {
856 logit("%s: llseek: %s", __func__, strerror(errno));
857 return (0);
858 }
859 if (ret != pos) {
860 logit("%s: Couldn't seek to tty %s slot in %s",
861 __func__, tty, UTMP_FILE);
862 return (0);
863 }
845 if (atomicio(vwrite, fd, ut, sizeof(*ut)) != sizeof(*ut)) 864 if (atomicio(vwrite, fd, ut, sizeof(*ut)) != sizeof(*ut))
846 logit("utmp_write_direct: error writing %s: %s", 865 logit("%s: error writing %s: %s", __func__,
847 UTMP_FILE, strerror(errno)); 866 UTMP_FILE, strerror(errno));
848 867
849 (void)close(fd); 868 (void)close(fd);