>From 64cfaa1e1d034e7acbdd2e2b367a04719df4ab27 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Tue, 27 Jan 2015 20:32:33 +0100 Subject: [PATCH] SELINUX: Check the return value of setuid and setgid Silences a Coverity warning --- src/providers/ipa/selinux_child.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/providers/ipa/selinux_child.c b/src/providers/ipa/selinux_child.c index 7297f5ed3bafbd8ac9b14ee60ef07839a35587cf..63d4b929786d4b8cc0d40f0c65009673c7309094 100644 --- a/src/providers/ipa/selinux_child.c +++ b/src/providers/ipa/selinux_child.c @@ -220,11 +220,21 @@ int main(int argc, const char *argv[]) * We need to switch also the real ID to 0. */ if (getuid() != 0) { - setuid(0); + ret = setuid(0); + if (ret == -1) { + ret = errno; + DEBUG(SSSDBG_CRIT_FAILURE, + "setuid failed: %d, selinux_child might not work!\n", ret); + } } if (getgid() != 0) { - setgid(0); + ret = setgid(0); + if (ret == -1) { + ret = errno; + DEBUG(SSSDBG_CRIT_FAILURE, + "setgid failed: %d, selinux_child might not work!\n", ret); + } } DEBUG(SSSDBG_TRACE_INTERNAL, -- 2.1.0