summaryrefslogtreecommitdiffstats
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 6a80928e..de49214c 100644
--- a/bsd-login.c
+++ b/bsd-login.c
@@ -73,7 +73,7 @@ struct utmp * utp;
int t = 0;
struct utmp * u;
-#ifdef HAVE_TYPE_IN_UTMP
+#if defined(HAVE_TYPE_IN_UTMP) || defined(HAVE_TYPE_IN_UTMPX)
setutent();
while((u = getutent()) != NULL) {
@@ -123,16 +123,26 @@ login(utp)
*/
tty = find_tty_slot(utp);
+#ifdef USE_UTMPX
+ fd = open(_PATH_UTMPX, O_RDWR|O_CREAT, 0644);
+ if (fd == -1) {
+ log("Couldn't open %s: %s", _PATH_UTMPX, strerror(errno));
+#else /* USE_UTMPX */
fd = open(_PATH_UTMP, O_RDWR|O_CREAT, 0644);
if (fd == -1) {
log("Couldn't open %s: %s", _PATH_UTMP, strerror(errno));
+#endif /* USE_UTMPX */
} else {
/* If no tty was found... */
if (tty == -1) {
/* ... append it to utmp on login */
-#ifdef HAVE_TYPE_IN_UTMP
+#if defined(HAVE_TYPE_IN_UTMP) || defined(HAVE_TYPE_IN_UTMPX)
if (utp->ut_type == USER_PROCESS) {
+#ifdef USE_UTMPX
+ if ((fd = open(_PATH_UTMPX, O_WRONLY|O_APPEND, 0)) >= 0) {
+#else /* USE_UTMPX */
if ((fd = open(_PATH_UTMP, O_WRONLY|O_APPEND, 0)) >= 0) {
+#endif /* USE_UTMPX */
(void)write(fd, utp, sizeof(struct utmp));
(void)close(fd);
}