From f67f8ccbe007476e5eac098b91f3e6f314c92e44 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sun, 11 Jun 2023 22:32:51 +0300 Subject: [PATCH] Userspace: init now sets user and group ids before running their shell --- userspace/init/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/userspace/init/main.cpp b/userspace/init/main.cpp index ea6b3783..a1283fb7 100644 --- a/userspace/init/main.cpp +++ b/userspace/init/main.cpp @@ -131,6 +131,11 @@ int main() { printf("Welcome back %s!\n", user.name.data()); + if (setgid(user.gid) == -1) + perror("setgid"); + if (setuid(user.uid) == -1) + perror("setuid"); + execl(user.shell.data(), user.shell.data(), nullptr); perror("execl");