summaryrefslogtreecommitdiffstats
path: root/src/providers/ldap/sdap_child_helpers.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2014-10-19 19:15:52 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-10-29 10:55:11 +0100
commitdde29ee9e0f9600453c360dc8544ef9beb07ea6c (patch)
tree92602a659827be895bd390b9f23fdbc762840ed2 /src/providers/ldap/sdap_child_helpers.c
parentc3209dd39a117898541285fe0c891f0d4b676598 (diff)
downloadsssd-dde29ee9e0f9600453c360dc8544ef9beb07ea6c.tar.gz
sssd-dde29ee9e0f9600453c360dc8544ef9beb07ea6c.tar.xz
sssd-dde29ee9e0f9600453c360dc8544ef9beb07ea6c.zip
LDAP: Drop privileges after kinit in ldap_child
After ldap_child initializes privileges using root-owned keytab, it drops privileges to the SSSD user, minimizing the amount of code that runs as root.
Diffstat (limited to 'src/providers/ldap/sdap_child_helpers.c')
-rw-r--r--src/providers/ldap/sdap_child_helpers.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/providers/ldap/sdap_child_helpers.c b/src/providers/ldap/sdap_child_helpers.c
index 448c5af10..e5d46b9b7 100644
--- a/src/providers/ldap/sdap_child_helpers.c
+++ b/src/providers/ldap/sdap_child_helpers.c
@@ -152,7 +152,7 @@ static errno_t create_tgt_req_send_buffer(TALLOC_CTX *mem_ctx,
return ENOMEM;
}
- buf->size = 4 * sizeof(uint32_t);
+ buf->size = 6 * sizeof(uint32_t);
if (realm_str) {
buf->size += strlen(realm_str);
}
@@ -201,6 +201,12 @@ static errno_t create_tgt_req_send_buffer(TALLOC_CTX *mem_ctx,
/* lifetime */
SAFEALIGN_SET_UINT32(&buf->data[rp], lifetime, &rp);
+ /* UID and GID to drop privileges to, if needed. The ldap_child process runs as
+ * setuid if the back end runs unprivileged as it needs to access the keytab
+ */
+ SAFEALIGN_SET_UINT32(&buf->data[rp], geteuid(), &rp);
+ SAFEALIGN_SET_UINT32(&buf->data[rp], getegid(), &rp);
+
*io_buf = buf;
return EOK;
}