summaryrefslogtreecommitdiff
path: root/bsd-login.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-05-20 14:53:09 +1000
committerDamien Miller <djm@mindrot.org>2000-05-20 14:53:09 +1000
commitad1bc5f986ac31ea3f429d2c49d7f34bd78e32fc (patch)
treed57ecfd942c6359a560e0a74ad52ea366b148d20 /bsd-login.c
parentd999ae26b7bad888b7a9b375faa38c1d6a8db1ce (diff)
- Don't touch utmp if USE_UTMPX defined
Diffstat (limited to 'bsd-login.c')
-rw-r--r--bsd-login.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/bsd-login.c b/bsd-login.c
index 6a80928e0..de49214c0 100644
--- a/bsd-login.c
+++ b/bsd-login.c
@@ -73,7 +73,7 @@ struct utmp * utp;
73 int t = 0; 73 int t = 0;
74 struct utmp * u; 74 struct utmp * u;
75 75
76#ifdef HAVE_TYPE_IN_UTMP 76#if defined(HAVE_TYPE_IN_UTMP) || defined(HAVE_TYPE_IN_UTMPX)
77 setutent(); 77 setutent();
78 78
79 while((u = getutent()) != NULL) { 79 while((u = getutent()) != NULL) {
@@ -123,16 +123,26 @@ login(utp)
123 */ 123 */
124 tty = find_tty_slot(utp); 124 tty = find_tty_slot(utp);
125 125
126#ifdef USE_UTMPX
127 fd = open(_PATH_UTMPX, O_RDWR|O_CREAT, 0644);
128 if (fd == -1) {
129 log("Couldn't open %s: %s", _PATH_UTMPX, strerror(errno));
130#else /* USE_UTMPX */
126 fd = open(_PATH_UTMP, O_RDWR|O_CREAT, 0644); 131 fd = open(_PATH_UTMP, O_RDWR|O_CREAT, 0644);
127 if (fd == -1) { 132 if (fd == -1) {
128 log("Couldn't open %s: %s", _PATH_UTMP, strerror(errno)); 133 log("Couldn't open %s: %s", _PATH_UTMP, strerror(errno));
134#endif /* USE_UTMPX */
129 } else { 135 } else {
130 /* If no tty was found... */ 136 /* If no tty was found... */
131 if (tty == -1) { 137 if (tty == -1) {
132 /* ... append it to utmp on login */ 138 /* ... append it to utmp on login */
133#ifdef HAVE_TYPE_IN_UTMP 139#if defined(HAVE_TYPE_IN_UTMP) || defined(HAVE_TYPE_IN_UTMPX)
134 if (utp->ut_type == USER_PROCESS) { 140 if (utp->ut_type == USER_PROCESS) {
141#ifdef USE_UTMPX
142 if ((fd = open(_PATH_UTMPX, O_WRONLY|O_APPEND, 0)) >= 0) {
143#else /* USE_UTMPX */
135 if ((fd = open(_PATH_UTMP, O_WRONLY|O_APPEND, 0)) >= 0) { 144 if ((fd = open(_PATH_UTMP, O_WRONLY|O_APPEND, 0)) >= 0) {
145#endif /* USE_UTMPX */
136 (void)write(fd, utp, sizeof(struct utmp)); 146 (void)write(fd, utp, sizeof(struct utmp));
137 (void)close(fd); 147 (void)close(fd);
138 } 148 }