From 2668d799b828d864c13d8a55b58965493d52a4f5 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 19 Nov 2013 02:30:33 +0100 Subject: set supplemental groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/cerberus.c | 12 +++++++++++- src/cerberus.h | 3 +-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/cerberus.c b/src/cerberus.c index 01cbe08..4f9dd0c 100644 --- a/src/cerberus.c +++ b/src/cerberus.c @@ -242,6 +242,8 @@ void do_login(int argc, char** argv) } else if (child_pid == 0) { + int ret; + /* In case the shell does not do this */ setsid(); @@ -251,7 +253,15 @@ void do_login(int argc, char** argv) signal(SIGINT, SIG_DFL); /* Partial login */ - /* TODO set supplemental groups */ + ret = entry->pw_uid + ? initgroups(username, entry->pw_gid) /* supplemental groups for user, can require network */ + : setgroups(0, NULL); /* supplemental groups for root, does not require netork */ + if (ret == -1) + { + perror(entry->pw_uid ? "initgroups" : "setgroups"); + sleep(ERROR_SLEEP); + _exit(1); + } set_user(entry); exec_shell(entry); } diff --git a/src/cerberus.h b/src/cerberus.h index 706925a..a2df554 100644 --- a/src/cerberus.h +++ b/src/cerberus.h @@ -30,9 +30,8 @@ #include #include #include -#ifdef USE_TTY_GROUP +#include #include -#endif #include "config.h" -- cgit v1.2.3-70-g09d2