summaryrefslogtreecommitdiff
path: root/loginrec.c
diff options
context:
space:
mode:
Diffstat (limited to 'loginrec.c')
-rw-r--r--loginrec.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/loginrec.c b/loginrec.c
index b74d412e6..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.56 2004/04/08 06:16:06 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>
@@ -435,6 +435,11 @@ login_write (struct logininfo *li)
435#ifdef USE_WTMPX 435#ifdef USE_WTMPX
436 wtmpx_write_entry(li); 436 wtmpx_write_entry(li);
437#endif 437#endif
438#ifdef CUSTOM_SYS_AUTH_RECORD_LOGIN
439 if (li->type == LTYPE_LOGIN &&
440 !sys_auth_record_login(li->username,li->hostname,li->line))
441 logit("Writing login record failed for %s", li->username);
442#endif
438 return 0; 443 return 0;
439} 444}
440 445
@@ -813,8 +818,8 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut)
813 endttyent(); 818 endttyent();
814 819
815 if((struct ttyent *)0 == ty) { 820 if((struct ttyent *)0 == ty) {
816 logit("utmp_write_entry: tty not found"); 821 logit("%s: tty not found", __func__);
817 return(1); 822 return (0);
818 } 823 }
819#else /* FIXME */ 824#else /* FIXME */
820 825
@@ -823,7 +828,18 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut)
823#endif /* HAVE_GETTTYENT */ 828#endif /* HAVE_GETTTYENT */
824 829
825 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) {
826 (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 }
827 /* 843 /*
828 * Prevent luser from zero'ing out ut_host. 844 * Prevent luser from zero'ing out ut_host.
829 * 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
@@ -836,9 +852,17 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut)
836 (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));
837 } 853 }
838 854
839 (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 }
840 if (atomicio(vwrite, fd, ut, sizeof(*ut)) != sizeof(*ut)) 864 if (atomicio(vwrite, fd, ut, sizeof(*ut)) != sizeof(*ut))
841 logit("utmp_write_direct: error writing %s: %s", 865 logit("%s: error writing %s: %s", __func__,
842 UTMP_FILE, strerror(errno)); 866 UTMP_FILE, strerror(errno));
843 867
844 (void)close(fd); 868 (void)close(fd);