62 lines
1.6 KiB
Diff
62 lines
1.6 KiB
Diff
|
diff --git a/config.h.in b/config.h.in
|
||
|
index 1a89e85..2df4786 100644
|
||
|
--- a/config.h.in
|
||
|
+++ b/config.h.in
|
||
|
@@ -801,6 +801,14 @@
|
||
|
#undef HAVE_SETREGID
|
||
|
#undef HAVE_DECL_SETREGID
|
||
|
|
||
|
+/* Define if you have the setregid function. */
|
||
|
+#undef HAVE_SETRESGID
|
||
|
+#undef HAVE_DECL_SETRESGID
|
||
|
+
|
||
|
+/* Define if you have the setresuid function. */
|
||
|
+#undef HAVE_SETRESUID
|
||
|
+#undef HAVE_DECL_SETRESUID
|
||
|
+
|
||
|
/* Define if you have the setvbuf function. */
|
||
|
#undef HAVE_SETVBUF
|
||
|
|
||
|
diff --git a/configure.ac b/configure.ac
|
||
|
index a3f6d8f..e5162c4 100644
|
||
|
--- a/configure.ac
|
||
|
+++ b/configure.ac
|
||
|
@@ -799,6 +799,7 @@ AC_CHECK_DECLS([confstr])
|
||
|
AC_CHECK_DECLS([printf])
|
||
|
AC_CHECK_DECLS([sbrk])
|
||
|
AC_CHECK_DECLS([setregid])
|
||
|
+AC_CHECK_DECLS[(setresuid, setresgid])
|
||
|
AC_CHECK_DECLS([strcpy])
|
||
|
AC_CHECK_DECLS([strsignal])
|
||
|
|
||
|
diff --git a/shell.c b/shell.c
|
||
|
index 4aae182..484d8a9 100644
|
||
|
--- a/shell.c
|
||
|
+++ b/shell.c
|
||
|
@@ -1286,7 +1286,11 @@ disable_priv_mode ()
|
||
|
{
|
||
|
int e;
|
||
|
|
||
|
+#if HAVE_DECL_SETRESUID
|
||
|
+ if (setresuid (current_user.uid, current_user.uid, current_user.uid) < 0)
|
||
|
+#else
|
||
|
if (setuid (current_user.uid) < 0)
|
||
|
+#endif
|
||
|
{
|
||
|
e = errno;
|
||
|
sys_error (_("cannot set uid to %d: effective uid %d"), current_user.uid, current_user.euid);
|
||
|
@@ -1295,7 +1299,11 @@ disable_priv_mode ()
|
||
|
exit (e);
|
||
|
#endif
|
||
|
}
|
||
|
+#if HAVE_DECL_SETRESGID
|
||
|
+ if (setresgid (current_user.gid, current_user.gid, current_user.gid) < 0)
|
||
|
+#else
|
||
|
if (setgid (current_user.gid) < 0)
|
||
|
+#endif
|
||
|
sys_error (_("cannot set gid to %d: effective gid %d"), current_user.gid, current_user.egid);
|
||
|
|
||
|
current_user.euid = current_user.uid;
|
||
|
--
|
||
|
2.25.4
|