summaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2012-04-13 12:36:28 +0200
committerStephen Gallagher <sgallagh@redhat.com>2012-06-29 11:37:16 -0400
commitcda8ff6cfdef22356dc3c06ec5204344912f0f0b (patch)
treeb0367a4545ac08ea76d0843f86cb53b5d6c13a3a /src/db
parentb0abb3bfdfd95951a23c9fc223c735805ffd2969 (diff)
downloadsssd-cda8ff6cfdef22356dc3c06ec5204344912f0f0b.tar.gz
sssd-cda8ff6cfdef22356dc3c06ec5204344912f0f0b.tar.bz2
sssd-cda8ff6cfdef22356dc3c06ec5204344912f0f0b.zip
sudo sysdb: make sysdb_get_sudo_user_info more configurable
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb_sudo.c60
1 files changed, 35 insertions, 25 deletions
diff --git a/src/db/sysdb_sudo.c b/src/db/sysdb_sudo.c
index b1f181aa..b6e5509f 100644
--- a/src/db/sysdb_sudo.c
+++ b/src/db/sysdb_sudo.c
@@ -302,38 +302,48 @@ sysdb_get_sudo_user_info(TALLOC_CTX *mem_ctx, const char *username,
goto done;
}
- uid = ldb_msg_find_attr_as_uint64(msg, SYSDB_UIDNUM, 0);
- if (!uid) {
- DEBUG(SSSDBG_CRIT_FAILURE, ("A user with no UID?\n"));
- ret = EIO;
- goto done;
+ if (_uid != NULL) {
+ uid = ldb_msg_find_attr_as_uint64(msg, SYSDB_UIDNUM, 0);
+ if (!uid) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("A user with no UID?\n"));
+ ret = EIO;
+ goto done;
+ }
}
- groups = ldb_msg_find_element(msg, SYSDB_MEMBEROF);
- if (!groups || groups->num_values == 0) {
- /* No groups for this user in sysdb currently */
- sysdb_groupnames = NULL;
- } else {
- sysdb_groupnames = talloc_array(tmp_ctx, char *, groups->num_values+1);
- NULL_CHECK(sysdb_groupnames, ret, done);
-
- /* Get a list of the groups by groupname only */
- for (i = 0; i < groups->num_values; i++) {
- ret = sysdb_group_dn_name(sysdb,
- sysdb_groupnames,
- (const char *)groups->values[i].data,
- &sysdb_groupnames[i]);
- if (ret != EOK) {
- ret = ENOMEM;
- goto done;
+ if (groupnames != NULL) {
+ groups = ldb_msg_find_element(msg, SYSDB_MEMBEROF);
+ if (!groups || groups->num_values == 0) {
+ /* No groups for this user in sysdb currently */
+ sysdb_groupnames = NULL;
+ } else {
+ sysdb_groupnames = talloc_array(tmp_ctx, char *, groups->num_values+1);
+ NULL_CHECK(sysdb_groupnames, ret, done);
+
+ /* Get a list of the groups by groupname only */
+ for (i = 0; i < groups->num_values; i++) {
+ ret = sysdb_group_dn_name(sysdb,
+ sysdb_groupnames,
+ (const char *)groups->values[i].data,
+ &sysdb_groupnames[i]);
+ if (ret != EOK) {
+ ret = ENOMEM;
+ goto done;
+ }
}
+ sysdb_groupnames[groups->num_values] = NULL;
}
- sysdb_groupnames[groups->num_values] = NULL;
}
ret = EOK;
- *_uid = uid;
- *groupnames = talloc_steal(mem_ctx, sysdb_groupnames);
+
+ if (_uid != NULL) {
+ *_uid = uid;
+ }
+
+ if (groupnames != NULL) {
+ *groupnames = talloc_steal(mem_ctx, sysdb_groupnames);
+ }
done:
talloc_free(tmp_ctx);
return ret;