UTMP: Add support for INIT_PROCESS & DEAD_PROCESS

Services started by Finit are now properly accounted for in UTMP.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2016-08-09 00:58:00 +02:00
1 parent 8c54fde36c
commit 2718c709aa
4 files changed
+67 -20

No files matched your search

+12 -3
View File
@@ -29,16 +29,17 @@
#include <net/if.h>
#include <lite/lite.h>
#include "finit.h"
#include "conf.h"
#include "cond.h"
#include "finit.h"
#include "helpers.h"
#include "inetd.h"
#include "private.h"
#include "sig.h"
#include "tty.h"
#include "service.h"
#include "inetd.h"
#include "sm.h"
#include "tty.h"
#include "utmp-api.h"
#define RESPAWN_MAX 10 /* Prevent endless respawn of faulty services. */
@@ -151,6 +152,7 @@ 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. */
@@ -159,6 +161,10 @@ 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);
@@ -661,6 +667,9 @@ 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;