aboutsummaryrefslogtreecommitdiff
path: root/loginutils/getty.c
diff options
context:
space:
mode:
Diffstat (limited to 'loginutils/getty.c')
-rw-r--r--loginutils/getty.c61
1 files changed, 2 insertions, 59 deletions
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 20411b04c..8d1d5254e 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -19,7 +19,7 @@
#include <syslog.h>
#if ENABLE_FEATURE_UTMP
-#include <utmp.h> /* updwtmp() */
+#include <utmp.h> /* LOGIN_PROCESS */
#endif
#ifndef IUCLC
@@ -575,61 +575,6 @@ static void termios_final(struct options *op, struct termios *tp, struct chardat
ioctl_or_perror_and_die(0, TCSETS, tp, "%s: TCSETS", op->tty);
}
-#if ENABLE_FEATURE_UTMP
-static void touch(const char *filename)
-{
- if (access(filename, R_OK | W_OK) == -1)
- close(open(filename, O_WRONLY | O_CREAT, 0664));
-}
-
-/* update_utmp - update our utmp entry */
-static NOINLINE void update_utmp(const char *line, char *fakehost)
-{
- struct utmp ut;
- struct utmp *utp;
- int mypid = getpid();
-
- /* In case we won't find an entry below... */
- memset(&ut, 0, sizeof(ut));
- safe_strncpy(ut.ut_id, line + 3, sizeof(ut.ut_id));
-
- /*
- * The utmp file holds miscellaneous information about things started by
- * /sbin/init and other system-related events. Our purpose is to update
- * the utmp entry for the current process, in particular the process type
- * and the tty line we are listening to. Return successfully only if the
- * utmp file can be opened for update, and if we are able to find our
- * entry in the utmp file.
- */
- touch(_PATH_UTMP);
-
- utmpname(_PATH_UTMP);
- setutent();
- while ((utp = getutent()) != NULL) {
- if (utp->ut_type == INIT_PROCESS && utp->ut_pid == mypid) {
- memcpy(&ut, utp, sizeof(ut));
- break;
- }
- }
-
- strcpy(ut.ut_user, "LOGIN");
- safe_strncpy(ut.ut_line, line, sizeof(ut.ut_line));
- if (fakehost)
- safe_strncpy(ut.ut_host, fakehost, sizeof(ut.ut_host));
- ut.ut_tv.tv_sec = time(NULL);
- ut.ut_type = LOGIN_PROCESS;
- ut.ut_pid = mypid;
-
- pututline(&ut);
- endutent();
-
-#if ENABLE_FEATURE_WTMP
- touch(bb_path_wtmp_file);
- updwtmp(bb_path_wtmp_file, &ut);
-#endif
-}
-#endif /* CONFIG_FEATURE_UTMP */
-
int getty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int getty_main(int argc UNUSED_PARAM, char **argv)
{
@@ -715,10 +660,8 @@ int getty_main(int argc UNUSED_PARAM, char **argv)
tcsetpgrp(0, getpid());
#endif
-#if ENABLE_FEATURE_UTMP
/* Update the utmp file. This tty is ours now! */
- update_utmp(options.tty, fakehost);
-#endif
+ update_utmp(LOGIN_PROCESS, options.tty, "LOGIN", fakehost);
/* Initialize the termios settings (raw mode, eight-bit, blocking i/o). */
debug("calling termios_init\n");