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