1
0
mirror of https://github.com/tmate-io/tmate-ssh-server.git synced 2020-11-18 19:53:51 -08:00

setgid first

This commit is contained in:
Nicolas Viennot 2015-10-10 06:41:24 -04:00
parent 48ff5669a3
commit f37e5ad855

View File

@ -279,6 +279,17 @@ static void jail(void)
if (setgroups(1, (gid_t[]){gid}) < 0)
tmate_fatal("Cannot setgroups()");
#if HAVE_SETRESGID
if (setresgid(gid, gid, gid) < 0)
tmate_fatal("Cannot setresgid() %d", gid);
#elif HAVE_SETREGID
if (setregid(gid, gid) < 0)
tmate_fatal("Cannot setregid()");
#else
if (setgid(gid) < 0)
tmate_fatal("Cannot setgid()");
#endif
#if HAVE_SETRESUID
if (setresuid(uid, uid, uid) < 0)
tmate_fatal("Cannot setresuid()");
@ -290,17 +301,6 @@ static void jail(void)
tmate_fatal("Cannot setuid()");
#endif
#if HAVE_SETRESGID
if (setresgid(gid, gid, gid) < 0)
tmate_fatal("Cannot setresgid()");
#elif HAVE_SETREGID
if (setregid(gid, gid) < 0)
tmate_fatal("Cannot setregid()");
#else
if (setgid(gid) < 0)
tmate_fatal("Cannot setgid()");
#endif
if (nice(1) < 0)
tmate_fatal("Cannot nice()");