From: Andreas Jaeger Date: Fri, 30 Nov 2012 13:21:22 +0000 (-0700) Subject: Fix OpenSUSE glibc 2.17 compile issues X-Git-Tag: SQUID_3_2_4~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a43d8333caf0a878fc69023fae0cbd58db85b371;p=thirdparty%2Fsquid.git Fix OpenSUSE glibc 2.17 compile issues --- diff --git a/src/icmp/pinger.cc b/src/icmp/pinger.cc index 1bbefdd122..ee13f7a537 100644 --- a/src/icmp/pinger.cc +++ b/src/icmp/pinger.cc @@ -180,8 +180,18 @@ main(int argc, char *argv[]) } max_fd = max(max_fd, squid_link); - setgid(getgid()); - setuid(getuid()); + if (setgid(getgid()) < 0) { + debugs(42, DBG_CRITICAL, "FATAL: pinger: setgid(" << getgid() << ") failed: " << xstrerror()); + icmp4.Close(); + icmp6.Close(); + exit (1); + } + if (setuid(getuid()) < 0) { + debugs(42, DBG_CRITICAL, "FATAL: pinger: setuid(" << getuid() << ") failed: " << xstrerror()); + icmp4.Close(); + icmp6.Close(); + exit (1); + } last_check_time = squid_curtime; diff --git a/src/tools.cc b/src/tools.cc index ce6f742873..c3f0f59fc6 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -754,10 +754,10 @@ leave_suid(void) void enter_suid(void) { - debugs(21, 3, "enter_suid: PID " << getpid() << " taking root priveleges"); + debugs(21, 3, "enter_suid: PID " << getpid() << " taking root privileges"); #if HAVE_SETRESUID - - setresuid((uid_t)-1, 0, (uid_t)-1); + if (setresuid((uid_t)-1, 0, (uid_t)-1) < 0) + debugs (21, 3, "enter_suid: setresuid failed: " << xstrerror ()); #else setuid(0); @@ -782,10 +782,11 @@ no_suid(void) uid = geteuid(); debugs(21, 3, "no_suid: PID " << getpid() << " giving up root priveleges forever"); - setuid(0); + if (setuid(0) < 0) + debugs(50, DBG_IMPORTANT, "WARNING: no_suid: setuid(0): " << xstrerror()); if (setuid(uid) < 0) - debugs(50, 1, "no_suid: setuid: " << xstrerror()); + debugs(50, DBG_IMPORTANT, "ERROR: no_suid: setuid(" << uid << "): " << xstrerror()); restoreCapabilities(0);