From a260e157ebdf5c01c530aadf5a5129decbe811d8 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 25 Mar 2021 17:26:31 +0100 Subject: [PATCH] Move external getty and sh to user cgroup Signed-off-by: Joachim Wiberg --- src/exec.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/exec.c b/src/exec.c index cc2fc40f..0d0a728c 100644 --- a/src/exec.c +++ b/src/exec.c @@ -35,6 +35,7 @@ #include #include "finit.h" +#include "cgroup.h" #include "conf.h" #include "helpers.h" #include "sig.h" @@ -418,6 +419,15 @@ pid_t run_getty2(char *tty, char *cmd, char *args[], int noclear, int nowait, st _exit(rc); } + /* + * at this point we're just guessing the username + * would be nice to catch new logins dynamically + * and add them to the correct group, this would + * also work for SSH/Telnet logins. + */ + if (pid > 1) + cgroup_user("root", pid); + return pid; } @@ -436,6 +446,9 @@ pid_t run_sh(char *tty, int noclear, int nowait, struct rlimit rlimit[]) _exit(rc); } + if (pid > 1) + cgroup_user("root", pid); + return pid; }