diff options
author | Damien Miller <djm@mindrot.org> | 2000-08-15 10:01:22 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2000-08-15 10:01:22 +1000 |
commit | 348c9b7a9564986000743fe379de21ae6f73f7d4 (patch) | |
tree | c12f2adbd94e7298b0cc26d5891ddea58c59ce61 /loginrec.c | |
parent | ef7ed5eadf75a06fd9d9cd9868cd5f4072ae9e56 (diff) |
- (djm) More SunOS 4.1.x fixes from Nate Itkin <nitkin@europa.com>
Diffstat (limited to 'loginrec.c')
-rw-r--r-- | loginrec.c | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/loginrec.c b/loginrec.c index e7542c92a..798e966f0 100644 --- a/loginrec.c +++ b/loginrec.c | |||
@@ -160,7 +160,7 @@ | |||
160 | #include "xmalloc.h" | 160 | #include "xmalloc.h" |
161 | #include "loginrec.h" | 161 | #include "loginrec.h" |
162 | 162 | ||
163 | RCSID("$Id: loginrec.c,v 1.18 2000/08/09 06:34:28 djm Exp $"); | 163 | RCSID("$Id: loginrec.c,v 1.19 2000/08/15 00:01:22 djm Exp $"); |
164 | 164 | ||
165 | /** | 165 | /** |
166 | ** prototypes for helper functions in this file | 166 | ** prototypes for helper functions in this file |
@@ -273,7 +273,7 @@ login_get_lastlog(struct logininfo *li, const int uid) | |||
273 | { | 273 | { |
274 | struct passwd *pw; | 274 | struct passwd *pw; |
275 | 275 | ||
276 | memset(li, '\0', sizeof(struct logininfo)); | 276 | memset(li, '\0', sizeof(*li)); |
277 | li->uid = uid; | 277 | li->uid = uid; |
278 | 278 | ||
279 | /* | 279 | /* |
@@ -311,7 +311,7 @@ logininfo *login_alloc_entry(int pid, const char *username, | |||
311 | { | 311 | { |
312 | struct logininfo *newli; | 312 | struct logininfo *newli; |
313 | 313 | ||
314 | newli = (struct logininfo *) xmalloc (sizeof(struct logininfo)); | 314 | newli = (struct logininfo *) xmalloc (sizeof(*newli)); |
315 | (void)login_init_entry(newli, pid, username, hostname, line); | 315 | (void)login_init_entry(newli, pid, username, hostname, line); |
316 | return newli; | 316 | return newli; |
317 | } | 317 | } |
@@ -339,7 +339,7 @@ login_init_entry(struct logininfo *li, int pid, const char *username, | |||
339 | { | 339 | { |
340 | struct passwd *pw; | 340 | struct passwd *pw; |
341 | 341 | ||
342 | memset(li, 0, sizeof(struct logininfo)); | 342 | memset(li, 0, sizeof(*li)); |
343 | 343 | ||
344 | li->pid = pid; | 344 | li->pid = pid; |
345 | 345 | ||
@@ -569,7 +569,7 @@ void | |||
569 | construct_utmp(struct logininfo *li, | 569 | construct_utmp(struct logininfo *li, |
570 | struct utmp *ut) | 570 | struct utmp *ut) |
571 | { | 571 | { |
572 | memset(ut, '\0', sizeof(struct utmp)); | 572 | memset(ut, '\0', sizeof(*ut)); |
573 | 573 | ||
574 | /* First fill out fields used for both logins and logouts */ | 574 | /* First fill out fields used for both logins and logouts */ |
575 | 575 | ||
@@ -643,7 +643,7 @@ set_utmpx_time(struct logininfo *li, struct utmpx *utx) | |||
643 | void | 643 | void |
644 | construct_utmpx(struct logininfo *li, struct utmpx *utx) | 644 | construct_utmpx(struct logininfo *li, struct utmpx *utx) |
645 | { | 645 | { |
646 | memset(utx, '\0', sizeof(struct utmpx)); | 646 | memset(utx, '\0', sizeof(*utx)); |
647 | # ifdef HAVE_ID_IN_UTMPX | 647 | # ifdef HAVE_ID_IN_UTMPX |
648 | line_abbrevname(utx->ut_id, li->line, sizeof(utx->ut_id)); | 648 | line_abbrevname(utx->ut_id, li->line, sizeof(utx->ut_id)); |
649 | # endif | 649 | # endif |
@@ -723,8 +723,30 @@ utmp_write_direct(struct logininfo *li, struct utmp *ut) | |||
723 | int tty; | 723 | int tty; |
724 | 724 | ||
725 | /* FIXME: (ATL) ttyslot() needs local implementation */ | 725 | /* FIXME: (ATL) ttyslot() needs local implementation */ |
726 | |||
727 | #if defined(SUNOS4) && defined(HAVE_GETTTYENT) | ||
728 | register struct ttyent *ty; | ||
729 | |||
730 | tty=0; | ||
731 | |||
732 | setttyent(); | ||
733 | while ((struct ttyent *)0 != (ty = getttyent())) { | ||
734 | tty++; | ||
735 | if (!strncmp(ty->ty_name, ut->ut_line, sizeof(ut->ut_line))) | ||
736 | break; | ||
737 | } | ||
738 | endttyent(); | ||
739 | |||
740 | if((struct ttyent *)0 == ty) { | ||
741 | log("utmp_write_entry: tty not found"); | ||
742 | return(1); | ||
743 | } | ||
744 | #else /* FIXME */ | ||
745 | |||
726 | tty = ttyslot(); /* seems only to work for /dev/ttyp? style names */ | 746 | tty = ttyslot(); /* seems only to work for /dev/ttyp? style names */ |
727 | 747 | ||
748 | #endif /* SUNOS4 && HAVE_GETTTYENT */ | ||
749 | |||
728 | if (tty > 0 && (fd = open(UTMP_FILE, O_RDWR|O_CREAT, 0644)) >= 0) { | 750 | if (tty > 0 && (fd = open(UTMP_FILE, O_RDWR|O_CREAT, 0644)) >= 0) { |
729 | (void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET); | 751 | (void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET); |
730 | /* | 752 | /* |
@@ -1031,7 +1053,7 @@ wtmp_get_entry(struct logininfo *li) | |||
1031 | } | 1053 | } |
1032 | 1054 | ||
1033 | /* Seek to the start of the last struct utmp */ | 1055 | /* Seek to the start of the last struct utmp */ |
1034 | if (lseek(fd, (off_t)(0-sizeof(struct utmp)), SEEK_END) == -1) { | 1056 | if (lseek(fd, (off_t)(0 - sizeof(struct utmp)), SEEK_END) == -1) { |
1035 | /* Looks like we've got a fresh wtmp file */ | 1057 | /* Looks like we've got a fresh wtmp file */ |
1036 | close(fd); | 1058 | close(fd); |
1037 | return 0; | 1059 | return 0; |
@@ -1238,7 +1260,7 @@ syslogin_perform_login(struct logininfo *li) | |||
1238 | { | 1260 | { |
1239 | struct utmp *ut; | 1261 | struct utmp *ut; |
1240 | 1262 | ||
1241 | if (! (ut = (struct utmp *)malloc(sizeof(struct utmp)))) { | 1263 | if (! (ut = (struct utmp *)malloc(sizeof(*ut)))) { |
1242 | log("syslogin_perform_login: couldn't malloc()"); | 1264 | log("syslogin_perform_login: couldn't malloc()"); |
1243 | return 0; | 1265 | return 0; |
1244 | } | 1266 | } |
@@ -1301,7 +1323,7 @@ static void | |||
1301 | lastlog_construct(struct logininfo *li, struct lastlog *last) | 1323 | lastlog_construct(struct logininfo *li, struct lastlog *last) |
1302 | { | 1324 | { |
1303 | /* clear the structure */ | 1325 | /* clear the structure */ |
1304 | memset(last, '\0', sizeof(struct lastlog)); | 1326 | memset(last, '\0', sizeof(*last)); |
1305 | 1327 | ||
1306 | (void)line_stripname(last->ll_line, li->line, sizeof(last->ll_line)); | 1328 | (void)line_stripname(last->ll_line, li->line, sizeof(last->ll_line)); |
1307 | strlcpy(last->ll_host, li->hostname, | 1329 | strlcpy(last->ll_host, li->hostname, |