blob: 365a9795154e16c21934d7f11b4c2ccc59d7782d [file] [log] [blame]
Backport of: 951bdaad7a18cc0dc1036bba86b18b90874d39ff Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Mon, 1 Jul 2019 09:03:53 -0400
Subject: commit bash-20190628 snapshot
---
Index: bash-4.4.18/config.h.in
===================================================================
--- bash-4.4.18.orig/config.h.in
+++ bash-4.4.18/config.h.in
@@ -797,6 +797,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
Index: bash-4.4.18/configure
===================================================================
--- bash-4.4.18.orig/configure
+++ bash-4.4.18/configure
@@ -10241,6 +10241,17 @@ cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_STRSIGNAL $ac_have_decl
_ACEOF
+for ac_func in setresuid setresgid
+do :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
ac_fn_c_check_decl "$LINENO" "strtold" "ac_cv_have_decl_strtold" "$ac_includes_default"
if test "x$ac_cv_have_decl_strtold" = xyes; then :
Index: bash-4.4.18/configure.ac
===================================================================
--- bash-4.4.18.orig/configure.ac
+++ bash-4.4.18/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])
Index: bash-4.4.18/shell.c
===================================================================
--- bash-4.4.18.orig/shell.c
+++ bash-4.4.18/shell.c
@@ -1276,7 +1276,11 @@ disable_priv_mode ()
{
int e;
+#if HAVE_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);
@@ -1285,7 +1289,11 @@ disable_priv_mode ()
exit (e);
#endif
}
+#if HAVE_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;