UTMP: Only account for getty processes

This patch removes accounting for all processes to instead implement the
traditional SysV getty accounting.  (Telnet/SSH et al maintain their own
accounding for UTMP.)

TODO: WTMP support

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2016-08-17 18:43:49 +02:00
parent b6bf8bf518
commit 5bab329178
3 changed files with 4 additions and 11 deletions
-3
View File
@@ -106,9 +106,6 @@ int run(char *cmd)
for (i = 1; i < NSIG; i++)
DFLSIG(sa, i, 0);
/* Set INIT_PROCESS UTMP entry */
utmp_set_init(ttyname(0), 0);
/* Always redirect stdio for run() */
fp = fopen("/dev/null", "w");
if (fp) {
-8
View File
@@ -152,7 +152,6 @@ static int service_start(svc_t *svc)
pid = fork();
if (pid == 0) {
int status;
char id[5];
char *home = NULL;
#ifdef ENABLE_STATIC
int uid = 0; /* XXX: Fix better warning that dropprivs is disabled. */
@@ -161,10 +160,6 @@ static int service_start(svc_t *svc)
#endif
char *args[MAX_NUM_SVC_ARGS];
/* Set INIT_PROCESS UTMP entry */
snprintf(id, sizeof(id), "%d", svc->job);
utmp_set_init(ttyname(0), id);
/* Set desired user */
if (uid >= 0) {
setuid(uid);
@@ -667,9 +662,6 @@ void service_monitor(pid_t lost)
svc_t *svc;
char pidfile[MAX_ARG_LEN];
/* Set DEAD_PROCESS UTMP entry */
utmp_set_dead(lost);
if (fexist(SYNC_SHUTDOWN) || lost <= 1)
return;
+4
View File
@@ -31,6 +31,7 @@
#include "conf.h"
#include "helpers.h"
#include "tty.h"
#include "utmp-api.h"
LIST_HEAD(, tty_node) tty_list = LIST_HEAD_INITIALIZER();
@@ -198,6 +199,9 @@ int tty_respawn(pid_t pid)
if (!entry)
return 0;
/* Set DEAD_PROCESS UTMP entry */
utmp_set_dead(pid);
/* Clear PID to be able to respawn it. */
entry->data.pid = 0;