blob: f267875ed8c24a276ef29544ef72af38212e48e5 [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001From 86dae8010310d13bd2a2beb006b4085d06ae1556 Mon Sep 17 00:00:00 2001
Brad Bishopd7bf8c12018-02-25 22:55:05 -05002From: Khem Raj <raj.khem@gmail.com>
3Date: Sun, 25 Jun 2017 00:59:24 -0700
4Subject: [PATCH] tools.cc: fixed unused-result warning
5
6fix
7| ../../squid-3.5.26/src/tools.cc: In function 'void enter_suid()':
8| ../../squid-3.5.26/src/tools.cc:616:11: error: ignoring return value of 'int setuid(__uid_t)', declared with attribute warn_unused_result [-Werror=unused-result]
9| setuid(0);
10| ~~~~~~^~~
11
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
Brad Bishopd7bf8c12018-02-25 22:55:05 -050013
Brad Bishop316dfdd2018-06-25 12:45:53 -040014---
Brad Bishopc342db32019-05-15 21:57:59 -040015 src/tools.cc | 5 +++--
16 1 file changed, 3 insertions(+), 2 deletions(-)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050017
18diff --git a/src/tools.cc b/src/tools.cc
Brad Bishopc342db32019-05-15 21:57:59 -040019index 5829574..19f0836 100644
Brad Bishopd7bf8c12018-02-25 22:55:05 -050020--- a/src/tools.cc
21+++ b/src/tools.cc
Brad Bishopc342db32019-05-15 21:57:59 -040022@@ -581,8 +581,10 @@ enter_suid(void)
23 debugs (21, 3, "enter_suid: setresuid failed: " << xstrerr(xerrno));
24 }
Brad Bishopd7bf8c12018-02-25 22:55:05 -050025 #else
26-
27- setuid(0);
Brad Bishopc342db32019-05-15 21:57:59 -040028+ if (setuid(0) < 0) {
29+ const auto xerrno = errno;
30+ debugs(50, DBG_IMPORTANT, "WARNING: no_suid: setuid(0): " << xstrerr(xerrno));
31+ }
Brad Bishopd7bf8c12018-02-25 22:55:05 -050032 #endif
33 #if HAVE_PRCTL && defined(PR_SET_DUMPABLE)
34 /* Set Linux DUMPABLE flag */