summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2015-01-26 15:15:29 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-01-27 18:13:19 +0100
commita77f0b5c39b1f6c497b2b5c6c072d2f4f6e7a745 (patch)
tree8d2723ae12adccc17cace9e4335a7a1cbaebd438 /src
parent8ffc33de4e1ea85159ee72178efafaac060a8c3b (diff)
downloadsssd-a77f0b5c39b1f6c497b2b5c6c072d2f4f6e7a745.tar.gz
sssd-a77f0b5c39b1f6c497b2b5c6c072d2f4f6e7a745.tar.xz
sssd-a77f0b5c39b1f6c497b2b5c6c072d2f4f6e7a745.zip
SELINUX: Call setuid(0)/setgid(0) to also set the real IDs to root
https://fedorahosted.org/sssd/ticket/2564 libselinux uses many access(2) calls and access() uses the real UID, not the effective UID for the check. Therefore, the setuid selinux_child, which only has effective UID of root would fail the check. Reviewed-by: Michal Židek <mzidek@redhat.com> (cherry picked from commit 486f0d5227a9b81815aaaf7d9a2c39aafcbfdf6a)
Diffstat (limited to 'src')
-rw-r--r--src/providers/ipa/selinux_child.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/providers/ipa/selinux_child.c b/src/providers/ipa/selinux_child.c
index a38ffcb26..bda89c847 100644
--- a/src/providers/ipa/selinux_child.c
+++ b/src/providers/ipa/selinux_child.c
@@ -197,7 +197,23 @@ int main(int argc, const char *argv[])
DEBUG(SSSDBG_TRACE_FUNC, "selinux_child started.\n");
DEBUG(SSSDBG_TRACE_INTERNAL,
- "Running as [%"SPRIuid"][%"SPRIgid"].\n", geteuid(), getegid());
+ "Running with effective IDs: [%"SPRIuid"][%"SPRIgid"].\n",
+ geteuid(), getegid());
+
+ /* libsemanage calls access(2) which works with real IDs, not effective.
+ * We need to switch also the real ID to 0.
+ */
+ if (getuid() != 0) {
+ setuid(0);
+ }
+
+ if (getgid() != 0) {
+ setgid(0);
+ }
+
+ DEBUG(SSSDBG_TRACE_INTERNAL,
+ "Running with real IDs [%"SPRIuid"][%"SPRIgid"].\n",
+ getuid(), getgid());
main_ctx = talloc_new(NULL);
if (main_ctx == NULL) {