aboutsummaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-04-05 22:10:38 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-04-05 22:10:38 +0200
commit3a41611bc5ddeda6044e1f1e2956174b25389ce0 (patch)
treeadfc8a982cf321cc859900a28e9e92c82d43caea /loginutils
parent37f5bef63c0db4892d8ffa3c38a04c7998e10f83 (diff)
downloadbusybox-3a41611bc5ddeda6044e1f1e2956174b25389ce0.tar.gz
telnetd: write LOGIN/DEAD_PROCESS utmp records. Closes bug 1363
function old new delta write_new_utmp - 253 +253 skip_dev_pfx - 30 +30 handle_sigchld 42 72 +30 telnetd_main 1650 1673 +23 make_new_session 415 438 +23 ... login_main 1140 1148 +8 update_utmp 337 313 -24 write_wtmp 220 154 -66 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 11/6 up/down: 406/-115) Total: ~291 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/getty.c8
-rw-r--r--loginutils/login.c2
2 files changed, 6 insertions, 4 deletions
diff --git a/loginutils/getty.c b/loginutils/getty.c
index 8d1d5254e..d032357e2 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -19,7 +19,7 @@
#include <syslog.h>
#if ENABLE_FEATURE_UTMP
-#include <utmp.h> /* LOGIN_PROCESS */
+# include <utmp.h> /* LOGIN_PROCESS */
#endif
#ifndef IUCLC
@@ -579,6 +579,7 @@ int getty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int getty_main(int argc UNUSED_PARAM, char **argv)
{
int n;
+ pid_t pid;
char *fakehost = NULL; /* Fake hostname for ut_host */
char *logname; /* login name, given to /bin/login */
/* Merging these into "struct local" may _seem_ to reduce
@@ -651,17 +652,18 @@ int getty_main(int argc UNUSED_PARAM, char **argv)
/* tcgetattr() + error check */
ioctl_or_perror_and_die(0, TCGETS, &termios, "%s: TCGETS", options.tty);
+ pid = getpid();
#ifdef __linux__
// FIXME: do we need this? Otherwise "-" case seems to be broken...
// /* Forcibly make fd 0 our controlling tty, even if another session
// * has it as a ctty. (Another session loses ctty). */
// ioctl(0, TIOCSCTTY, (void*)1);
/* Make ourself a foreground process group within our session */
- tcsetpgrp(0, getpid());
+ tcsetpgrp(0, pid);
#endif
/* Update the utmp file. This tty is ours now! */
- update_utmp(LOGIN_PROCESS, options.tty, "LOGIN", fakehost);
+ update_utmp(pid, LOGIN_PROCESS, options.tty, "LOGIN", fakehost);
/* Initialize the termios settings (raw mode, eight-bit, blocking i/o). */
debug("calling termios_init\n");
diff --git a/loginutils/login.c b/loginutils/login.c
index 4a820379d..bf21d6121 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -384,7 +384,7 @@ int login_main(int argc UNUSED_PARAM, char **argv)
fchown(0, pw->pw_uid, pw->pw_gid);
fchmod(0, 0600);
- update_utmp(USER_PROCESS, short_tty, username, run_by_root ? opt_host : NULL);
+ update_utmp(getpid(), USER_PROCESS, short_tty, username, run_by_root ? opt_host : NULL);
/* We trust environment only if we run by root */
if (ENABLE_LOGIN_SCRIPTS && run_by_root)