diff options
author | Colin Watson <cjwatson@debian.org> | 2005-09-14 12:45:47 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2005-09-14 12:45:47 +0000 |
commit | 9b71add4cecf753c45f5fbd6ff0913bc95b3e95d (patch) | |
tree | d4ea8fdb30c7949c6433f5277c39548ea579d4dc /loginrec.c | |
parent | ed07bcbea56007ab5b218ddf3aa6a7d4e21966e0 (diff) | |
parent | 16704d57999d987fb8d9ba53379841a79f016d67 (diff) |
Merge 4.2p1 to the trunk.
Diffstat (limited to 'loginrec.c')
-rw-r--r-- | loginrec.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/loginrec.c b/loginrec.c index 361ac4cb7..c3783c991 100644 --- a/loginrec.c +++ b/loginrec.c | |||
@@ -165,7 +165,7 @@ | |||
165 | # include <libutil.h> | 165 | # include <libutil.h> |
166 | #endif | 166 | #endif |
167 | 167 | ||
168 | RCSID("$Id: loginrec.c,v 1.67 2005/02/15 11:19:28 dtucker Exp $"); | 168 | RCSID("$Id: loginrec.c,v 1.70 2005/07/17 07:26:44 djm Exp $"); |
169 | 169 | ||
170 | /** | 170 | /** |
171 | ** prototypes for helper functions in this file | 171 | ** prototypes for helper functions in this file |
@@ -362,7 +362,7 @@ login_init_entry(struct logininfo *li, int pid, const char *username, | |||
362 | strlcpy(li->username, username, sizeof(li->username)); | 362 | strlcpy(li->username, username, sizeof(li->username)); |
363 | pw = getpwnam(li->username); | 363 | pw = getpwnam(li->username); |
364 | if (pw == NULL) { | 364 | if (pw == NULL) { |
365 | fatal("%s: Cannot find user \"%s\"", __func__, | 365 | fatal("%s: Cannot find user \"%s\"", __func__, |
366 | li->username); | 366 | li->username); |
367 | } | 367 | } |
368 | li->uid = pw->pw_uid; | 368 | li->uid = pw->pw_uid; |
@@ -374,7 +374,7 @@ login_init_entry(struct logininfo *li, int pid, const char *username, | |||
374 | return (1); | 374 | return (1); |
375 | } | 375 | } |
376 | 376 | ||
377 | /* | 377 | /* |
378 | * login_set_current_time(struct logininfo *) - set the current time | 378 | * login_set_current_time(struct logininfo *) - set the current time |
379 | * | 379 | * |
380 | * Set the current time in a logininfo structure. This function is | 380 | * Set the current time in a logininfo structure. This function is |
@@ -443,8 +443,9 @@ login_write(struct logininfo *li) | |||
443 | wtmpx_write_entry(li); | 443 | wtmpx_write_entry(li); |
444 | #endif | 444 | #endif |
445 | #ifdef CUSTOM_SYS_AUTH_RECORD_LOGIN | 445 | #ifdef CUSTOM_SYS_AUTH_RECORD_LOGIN |
446 | if (li->type == LTYPE_LOGIN && | 446 | if (li->type == LTYPE_LOGIN && |
447 | !sys_auth_record_login(li->username,li->hostname,li->line, &loginmsg)) | 447 | !sys_auth_record_login(li->username,li->hostname,li->line, |
448 | &loginmsg)) | ||
448 | logit("Writing login record failed for %s", li->username); | 449 | logit("Writing login record failed for %s", li->username); |
449 | #endif | 450 | #endif |
450 | #ifdef SSH_AUDIT_EVENTS | 451 | #ifdef SSH_AUDIT_EVENTS |
@@ -534,7 +535,7 @@ getlast_entry(struct logininfo *li) | |||
534 | * sure dst has enough space, if not just copy src (ugh) | 535 | * sure dst has enough space, if not just copy src (ugh) |
535 | */ | 536 | */ |
536 | char * | 537 | char * |
537 | line_fullname(char *dst, const char *src, int dstsize) | 538 | line_fullname(char *dst, const char *src, u_int dstsize) |
538 | { | 539 | { |
539 | memset(dst, '\0', dstsize); | 540 | memset(dst, '\0', dstsize); |
540 | if ((strncmp(src, "/dev/", 5) == 0) || (dstsize < (strlen(src) + 5))) | 541 | if ((strncmp(src, "/dev/", 5) == 0) || (dstsize < (strlen(src) + 5))) |
@@ -558,7 +559,7 @@ line_stripname(char *dst, const char *src, int dstsize) | |||
558 | return (dst); | 559 | return (dst); |
559 | } | 560 | } |
560 | 561 | ||
561 | /* | 562 | /* |
562 | * line_abbrevname(): Return the abbreviated (usually four-character) | 563 | * line_abbrevname(): Return the abbreviated (usually four-character) |
563 | * form of the line (Just use the last <dstsize> characters of the | 564 | * form of the line (Just use the last <dstsize> characters of the |
564 | * full name.) | 565 | * full name.) |
@@ -808,7 +809,7 @@ utmp_write_library(struct logininfo *li, struct utmp *ut) | |||
808 | } | 809 | } |
809 | # else /* UTMP_USE_LIBRARY */ | 810 | # else /* UTMP_USE_LIBRARY */ |
810 | 811 | ||
811 | /* | 812 | /* |
812 | * Write a utmp entry direct to the file | 813 | * Write a utmp entry direct to the file |
813 | * This is a slightly modification of code in OpenBSD's login.c | 814 | * This is a slightly modification of code in OpenBSD's login.c |
814 | */ | 815 | */ |
@@ -852,7 +853,7 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut) | |||
852 | return (0); | 853 | return (0); |
853 | } | 854 | } |
854 | if (ret != pos) { | 855 | if (ret != pos) { |
855 | logit("%s: Couldn't seek to tty %d slot in %s", | 856 | logit("%s: Couldn't seek to tty %d slot in %s", |
856 | __func__, tty, UTMP_FILE); | 857 | __func__, tty, UTMP_FILE); |
857 | return (0); | 858 | return (0); |
858 | } | 859 | } |
@@ -1052,7 +1053,7 @@ utmpx_write_entry(struct logininfo *li) | |||
1052 | 1053 | ||
1053 | #ifdef USE_WTMP | 1054 | #ifdef USE_WTMP |
1054 | 1055 | ||
1055 | /* | 1056 | /* |
1056 | * Write a wtmp entry direct to the end of the file | 1057 | * Write a wtmp entry direct to the end of the file |
1057 | * This is a slight modification of code in OpenBSD's logwtmp.c | 1058 | * This is a slight modification of code in OpenBSD's logwtmp.c |
1058 | */ | 1059 | */ |
@@ -1113,7 +1114,7 @@ wtmp_write_entry(struct logininfo *li) | |||
1113 | } | 1114 | } |
1114 | 1115 | ||
1115 | 1116 | ||
1116 | /* | 1117 | /* |
1117 | * Notes on fetching login data from wtmp/wtmpx | 1118 | * Notes on fetching login data from wtmp/wtmpx |
1118 | * | 1119 | * |
1119 | * Logouts are usually recorded with (amongst other things) a blank | 1120 | * Logouts are usually recorded with (amongst other things) a blank |
@@ -1157,12 +1158,12 @@ wtmp_get_entry(struct logininfo *li) | |||
1157 | li->tv_sec = li->tv_usec = 0; | 1158 | li->tv_sec = li->tv_usec = 0; |
1158 | 1159 | ||
1159 | if ((fd = open(WTMP_FILE, O_RDONLY)) < 0) { | 1160 | if ((fd = open(WTMP_FILE, O_RDONLY)) < 0) { |
1160 | logit("%s: problem opening %s: %s", __func__, | 1161 | logit("%s: problem opening %s: %s", __func__, |
1161 | WTMP_FILE, strerror(errno)); | 1162 | WTMP_FILE, strerror(errno)); |
1162 | return (0); | 1163 | return (0); |
1163 | } | 1164 | } |
1164 | if (fstat(fd, &st) != 0) { | 1165 | if (fstat(fd, &st) != 0) { |
1165 | logit("%s: couldn't stat %s: %s", __func__, | 1166 | logit("%s: couldn't stat %s: %s", __func__, |
1166 | WTMP_FILE, strerror(errno)); | 1167 | WTMP_FILE, strerror(errno)); |
1167 | close(fd); | 1168 | close(fd); |
1168 | return (0); | 1169 | return (0); |
@@ -1177,7 +1178,7 @@ wtmp_get_entry(struct logininfo *li) | |||
1177 | 1178 | ||
1178 | while (!found) { | 1179 | while (!found) { |
1179 | if (atomicio(read, fd, &ut, sizeof(ut)) != sizeof(ut)) { | 1180 | if (atomicio(read, fd, &ut, sizeof(ut)) != sizeof(ut)) { |
1180 | logit("%s: read of %s failed: %s", __func__, | 1181 | logit("%s: read of %s failed: %s", __func__, |
1181 | WTMP_FILE, strerror(errno)); | 1182 | WTMP_FILE, strerror(errno)); |
1182 | close (fd); | 1183 | close (fd); |
1183 | return (0); | 1184 | return (0); |
@@ -1235,7 +1236,7 @@ wtmpx_write(struct logininfo *li, struct utmpx *utx) | |||
1235 | int fd, ret = 1; | 1236 | int fd, ret = 1; |
1236 | 1237 | ||
1237 | if ((fd = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) { | 1238 | if ((fd = open(WTMPX_FILE, O_WRONLY|O_APPEND, 0)) < 0) { |
1238 | logit("%s: problem opening %s: %s", __func__, | 1239 | logit("%s: problem opening %s: %s", __func__, |
1239 | WTMPX_FILE, strerror(errno)); | 1240 | WTMPX_FILE, strerror(errno)); |
1240 | return (0); | 1241 | return (0); |
1241 | } | 1242 | } |
@@ -1322,12 +1323,12 @@ wtmpx_get_entry(struct logininfo *li) | |||
1322 | li->tv_sec = li->tv_usec = 0; | 1323 | li->tv_sec = li->tv_usec = 0; |
1323 | 1324 | ||
1324 | if ((fd = open(WTMPX_FILE, O_RDONLY)) < 0) { | 1325 | if ((fd = open(WTMPX_FILE, O_RDONLY)) < 0) { |
1325 | logit("%s: problem opening %s: %s", __func__, | 1326 | logit("%s: problem opening %s: %s", __func__, |
1326 | WTMPX_FILE, strerror(errno)); | 1327 | WTMPX_FILE, strerror(errno)); |
1327 | return (0); | 1328 | return (0); |
1328 | } | 1329 | } |
1329 | if (fstat(fd, &st) != 0) { | 1330 | if (fstat(fd, &st) != 0) { |
1330 | logit("%s: couldn't stat %s: %s", __func__, | 1331 | logit("%s: couldn't stat %s: %s", __func__, |
1331 | WTMPX_FILE, strerror(errno)); | 1332 | WTMPX_FILE, strerror(errno)); |
1332 | close(fd); | 1333 | close(fd); |
1333 | return (0); | 1334 | return (0); |
@@ -1342,13 +1343,13 @@ wtmpx_get_entry(struct logininfo *li) | |||
1342 | 1343 | ||
1343 | while (!found) { | 1344 | while (!found) { |
1344 | if (atomicio(read, fd, &utx, sizeof(utx)) != sizeof(utx)) { | 1345 | if (atomicio(read, fd, &utx, sizeof(utx)) != sizeof(utx)) { |
1345 | logit("%s: read of %s failed: %s", __func__, | 1346 | logit("%s: read of %s failed: %s", __func__, |
1346 | WTMPX_FILE, strerror(errno)); | 1347 | WTMPX_FILE, strerror(errno)); |
1347 | close (fd); | 1348 | close (fd); |
1348 | return (0); | 1349 | return (0); |
1349 | } | 1350 | } |
1350 | /* | 1351 | /* |
1351 | * Logouts are recorded as a blank username on a particular | 1352 | * Logouts are recorded as a blank username on a particular |
1352 | * line. So, we just need to find the username in struct utmpx | 1353 | * line. So, we just need to find the username in struct utmpx |
1353 | */ | 1354 | */ |
1354 | if (wtmpx_islogin(li, &utx)) { | 1355 | if (wtmpx_islogin(li, &utx)) { |