From a5963b445b8ddb482a8b3e39e365a38437a3b0d3 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Tue, 25 May 2021 11:26:32 +0200 Subject: [PATCH] import patch to fix euid_set bug in shepherd --- patch/fix_euid_set_bug.patch | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 patch/fix_euid_set_bug.patch diff --git a/patch/fix_euid_set_bug.patch b/patch/fix_euid_set_bug.patch new file mode 100644 index 0000000..3b8bf12 --- /dev/null +++ b/patch/fix_euid_set_bug.patch @@ -0,0 +1,33 @@ +diff --git a/source/daemons/shepherd/shepherd.c b/source/daemons/shepherd/shepherd.c +index 5af1463..e7b2831 100644 +--- a/source/daemons/shepherd/shepherd.c ++++ b/source/daemons/shepherd/shepherd.c +@@ -299,17 +299,24 @@ static int handle_io_file(const char* file, const char* owner, bool rw) { + } + } + +- /* reset egid and euid to the stored values */ +- if (sge_seteuid(old_euid) != 0) { +- shepherd_trace("Cannot reset euid %s due to %s", owner, strerror(errno)); +- SGE_CLOSE(fd); ++ /* set effective user-id to root again, because only root is allowed to change ++ * the euid to any other than the current user-id. */ ++ if (sge_seteuid(SGE_SUPERUSER_UID) != 0) { ++ shepherd_trace("Cannot become root due to %s", strerror(errno)); + return -1; + } ++ ++ /* reset egid and euid to the stored values (e.g. those of the sgeadmin user) */ + if (sge_setegid(old_egid) != 0) { + shepherd_trace("Cannot reset egid %s due to %s", owner, strerror(errno)); + SGE_CLOSE(fd); + return -1; + } ++ if (sge_seteuid(old_euid) != 0) { ++ shepherd_trace("Cannot reset euid %s due to %s", owner, strerror(errno)); ++ SGE_CLOSE(fd); ++ return -1; ++ } + + return fd; + }