loginrec.c (128460) | loginrec.c (137019) |
---|---|
1/* 2 * Copyright (c) 2000 Andre Lucas. All rights reserved. 3 * Portions copyright (c) 1998 Todd C. Miller 4 * Portions copyright (c) 1996 Jason Downs 5 * Portions copyright (c) 1996 Theo de Raadt 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 144 unchanged lines hidden (view full) --- 153#include "includes.h" 154 155#include "ssh.h" 156#include "xmalloc.h" 157#include "loginrec.h" 158#include "log.h" 159#include "atomicio.h" 160 | 1/* 2 * Copyright (c) 2000 Andre Lucas. All rights reserved. 3 * Portions copyright (c) 1998 Todd C. Miller 4 * Portions copyright (c) 1996 Jason Downs 5 * Portions copyright (c) 1996 Theo de Raadt 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 144 unchanged lines hidden (view full) --- 153#include "includes.h" 154 155#include "ssh.h" 156#include "xmalloc.h" 157#include "loginrec.h" 158#include "log.h" 159#include "atomicio.h" 160 |
161RCSID("$FreeBSD: head/crypto/openssh/loginrec.c 128460 2004-04-20 09:46:41Z des $"); 162RCSID("$Id: loginrec.c,v 1.54 2004/02/10 05:49:35 dtucker Exp $"); | 161RCSID("$Id: loginrec.c,v 1.58 2004/08/15 09:12:52 djm Exp $"); 162RCSID("$FreeBSD: head/crypto/openssh/loginrec.c 137019 2004-10-28 16:11:31Z des $"); |
163 164#ifdef HAVE_UTIL_H 165# include <util.h> 166#endif 167 168#ifdef HAVE_LIBUTIL_H 169# include <libutil.h> 170#endif --- 260 unchanged lines hidden (view full) --- 431 wtmp_write_entry(li); 432#endif 433#ifdef USE_UTMPX 434 utmpx_write_entry(li); 435#endif 436#ifdef USE_WTMPX 437 wtmpx_write_entry(li); 438#endif | 163 164#ifdef HAVE_UTIL_H 165# include <util.h> 166#endif 167 168#ifdef HAVE_LIBUTIL_H 169# include <libutil.h> 170#endif --- 260 unchanged lines hidden (view full) --- 431 wtmp_write_entry(li); 432#endif 433#ifdef USE_UTMPX 434 utmpx_write_entry(li); 435#endif 436#ifdef USE_WTMPX 437 wtmpx_write_entry(li); 438#endif |
439#ifdef CUSTOM_SYS_AUTH_RECORD_LOGIN 440 if (li->type == LTYPE_LOGIN && 441 !sys_auth_record_login(li->username,li->hostname,li->line)) 442 logit("Writing login record failed for %s", li->username); 443#endif |
|
439 return 0; 440} 441 442#ifdef LOGIN_NEEDS_UTMPX 443int 444login_utmp_only(struct logininfo *li) 445{ 446 li->type = LTYPE_LOGIN; --- 363 unchanged lines hidden (view full) --- 810 while ((struct ttyent *)0 != (ty = getttyent())) { 811 tty++; 812 if (!strncmp(ty->ty_name, ut->ut_line, sizeof(ut->ut_line))) 813 break; 814 } 815 endttyent(); 816 817 if((struct ttyent *)0 == ty) { | 444 return 0; 445} 446 447#ifdef LOGIN_NEEDS_UTMPX 448int 449login_utmp_only(struct logininfo *li) 450{ 451 li->type = LTYPE_LOGIN; --- 363 unchanged lines hidden (view full) --- 815 while ((struct ttyent *)0 != (ty = getttyent())) { 816 tty++; 817 if (!strncmp(ty->ty_name, ut->ut_line, sizeof(ut->ut_line))) 818 break; 819 } 820 endttyent(); 821 822 if((struct ttyent *)0 == ty) { |
818 logit("utmp_write_entry: tty not found"); 819 return(1); | 823 logit("%s: tty not found", __func__); 824 return (0); |
820 } 821#else /* FIXME */ 822 823 tty = ttyslot(); /* seems only to work for /dev/ttyp? style names */ 824 825#endif /* HAVE_GETTTYENT */ 826 827 if (tty > 0 && (fd = open(UTMP_FILE, O_RDWR|O_CREAT, 0644)) >= 0) { | 825 } 826#else /* FIXME */ 827 828 tty = ttyslot(); /* seems only to work for /dev/ttyp? style names */ 829 830#endif /* HAVE_GETTTYENT */ 831 832 if (tty > 0 && (fd = open(UTMP_FILE, O_RDWR|O_CREAT, 0644)) >= 0) { |
828 (void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET); | 833 off_t pos, ret; 834 835 pos = (off_t)tty * sizeof(struct utmp); 836 if ((ret = lseek(fd, pos, SEEK_SET)) == -1) { 837 logit("%s: llseek: %s", strerror(errno)); 838 return (0); 839 } 840 if (ret != pos) { 841 logit("%s: Couldn't seek to tty %s slot in %s", tty, 842 UTMP_FILE); 843 return (0); 844 } |
829 /* 830 * Prevent luser from zero'ing out ut_host. 831 * If the new ut_line is empty but the old one is not 832 * and ut_line and ut_name match, preserve the old ut_line. 833 */ 834 if (atomicio(read, fd, &old_ut, sizeof(old_ut)) == sizeof(old_ut) && 835 (ut->ut_host[0] == '\0') && (old_ut.ut_host[0] != '\0') && 836 (strncmp(old_ut.ut_line, ut->ut_line, sizeof(ut->ut_line)) == 0) && 837 (strncmp(old_ut.ut_name, ut->ut_name, sizeof(ut->ut_name)) == 0)) { 838 (void)memcpy(ut->ut_host, old_ut.ut_host, sizeof(ut->ut_host)); 839 } 840 | 845 /* 846 * Prevent luser from zero'ing out ut_host. 847 * If the new ut_line is empty but the old one is not 848 * and ut_line and ut_name match, preserve the old ut_line. 849 */ 850 if (atomicio(read, fd, &old_ut, sizeof(old_ut)) == sizeof(old_ut) && 851 (ut->ut_host[0] == '\0') && (old_ut.ut_host[0] != '\0') && 852 (strncmp(old_ut.ut_line, ut->ut_line, sizeof(ut->ut_line)) == 0) && 853 (strncmp(old_ut.ut_name, ut->ut_name, sizeof(ut->ut_name)) == 0)) { 854 (void)memcpy(ut->ut_host, old_ut.ut_host, sizeof(ut->ut_host)); 855 } 856 |
841 (void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET); | 857 if ((ret = lseek(fd, pos, SEEK_SET)) == -1) { 858 logit("%s: llseek: %s", __func__, strerror(errno)); 859 return (0); 860 } 861 if (ret != pos) { 862 logit("%s: Couldn't seek to tty %s slot in %s", 863 __func__, tty, UTMP_FILE); 864 return (0); 865 } |
842 if (atomicio(vwrite, fd, ut, sizeof(*ut)) != sizeof(*ut)) | 866 if (atomicio(vwrite, fd, ut, sizeof(*ut)) != sizeof(*ut)) |
843 logit("utmp_write_direct: error writing %s: %s", | 867 logit("%s: error writing %s: %s", __func__, |
844 UTMP_FILE, strerror(errno)); 845 846 (void)close(fd); 847 return 1; 848 } else { 849 return 0; 850 } 851} --- 705 unchanged lines hidden --- | 868 UTMP_FILE, strerror(errno)); 869 870 (void)close(fd); 871 return 1; 872 } else { 873 return 0; 874 } 875} --- 705 unchanged lines hidden --- |