From ffcc4fd03ad58b5ce183a6ca46c267e0e9e4ef78 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 2 Dec 2024 05:03:07 +0200 Subject: [PATCH] init: Make tty owned by logged in user --- userspace/programs/init/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/userspace/programs/init/main.cpp b/userspace/programs/init/main.cpp index 7ddc530c..597f6249 100644 --- a/userspace/programs/init/main.cpp +++ b/userspace/programs/init/main.cpp @@ -77,6 +77,9 @@ int main(int argc, char** argv) if (pwd == nullptr) continue; + if (chown(tty_name, pwd->pw_uid, 0) == -1) + perror("chown"); + pid_t pid = fork(); if (pid == 0) { @@ -124,6 +127,9 @@ int main(int argc, char** argv) if (tcsetpgrp(0, getpgrp()) == -1) perror("tcsetpgrp"); + + if (chown(tty_name, 0, 0) == -1) + perror("chown"); } }