c0971b7e39
- Resolves: upstream#3821 - crash related to sbus_router_destructor() - Resolves: upstream#3810 - sbus2: fix memory leak in sbus_message_bound_ref - Resolves: upstream#3819 - sssd only sets the SELinux login context if it differs from the default - Resolves: upstream#3807 - The sbus codegen script relies on "python" which might not be available on all distributions - Resolves: upstream#3820 - sudo: search with lower cased name for case insensitive domains - Resolves: upstream#3701 - [RFE] Allow changing default behavior of SSSD from an allow-any default to a deny-any default when it can't find any GPOs to apply to a user login. - Resolves: upstream#3828 - Invalid domain provider causes SSSD to abort startup - Resolves: upstream#3500 - Make sure sssd is a replacement for pam_pkcs11 also for local account authentication - Resolves: upstream#3812 - sssd 2.0.0 segfaults on startup - Resolves: upstream#3826 - Remove references of sss_user/group/add/del commands in man pages since local provider is deprecated - Resolves: upstream#3827 - SSSD should log to syslog if a domain is not started due to a misconfiguration - Resolves: upstream#3830 - Printing incorrect information about domain with sssctl utility - Resolves: upstream#3489 - p11_child should work wit openssl1.0+ - Resolves: upstream#3750 - [RFE] man 5 sssd-files should mention necessary changes in nsswitch.conf - Resovles: upstream#3650 - RFE: Require smartcard authentication - Resolves: upstream#3334 - sssctl config-check does not check any special characters in domain name of domain section - Resolves: upstream#3849 - Files: The files provider always enumerates which causes duplicate when running getent passwd - Related: upstream#3855 - session not recording for local user when groups defined - Resolves: upstream#3802 - Reuse sysdb_error_to_errno() outside sysdb - Related: upstream#3493 - Remove the pysss.local interface
141 lines
5.3 KiB
Diff
141 lines
5.3 KiB
Diff
From 0bf709ad348ca115443bd21e4e369abd5d7698c4 Mon Sep 17 00:00:00 2001
|
|
From: Sumit Bose <sbose@redhat.com>
|
|
Date: Fri, 29 Jun 2018 18:13:59 +0200
|
|
Subject: [PATCH 23/83] sysdb: add attr_map attribute to
|
|
sysdb_ldb_msg_attr_to_certmap_info()
|
|
|
|
Allow more flexible attribute mapping in
|
|
sysdb_ldb_msg_attr_to_certmap_info()
|
|
|
|
Related to https://pagure.io/SSSD/sssd/issue/3500
|
|
|
|
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
---
|
|
src/db/sysdb.h | 1 +
|
|
src/db/sysdb_certmap.c | 39 +++++++++++++++++++++++++++++++--------
|
|
2 files changed, 32 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
|
|
index cb04e1b..2187947 100644
|
|
--- a/src/db/sysdb.h
|
|
+++ b/src/db/sysdb.h
|
|
@@ -704,6 +704,7 @@ errno_t sysdb_update_certmap(struct sysdb_ctx *sysdb,
|
|
|
|
errno_t sysdb_ldb_msg_attr_to_certmap_info(TALLOC_CTX *mem_ctx,
|
|
struct ldb_message *msg,
|
|
+ const char **attr_map,
|
|
struct certmap_info **certmap);
|
|
|
|
errno_t sysdb_get_certmap(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb,
|
|
diff --git a/src/db/sysdb_certmap.c b/src/db/sysdb_certmap.c
|
|
index 0bb7ebc..e37f1ba 100644
|
|
--- a/src/db/sysdb_certmap.c
|
|
+++ b/src/db/sysdb_certmap.c
|
|
@@ -263,8 +263,19 @@ done:
|
|
return ret;
|
|
}
|
|
|
|
+enum certmap_info_member {
|
|
+ SSS_CMIM_NAME = 0,
|
|
+ SSS_CMIM_MAPPING_RULE,
|
|
+ SSS_CMIM_MATCHING_RULE,
|
|
+ SSS_CMIM_PRIORITY,
|
|
+ SSS_CMIM_DOMAINS,
|
|
+
|
|
+ SSS_CMIM_SENTINEL
|
|
+};
|
|
+
|
|
errno_t sysdb_ldb_msg_attr_to_certmap_info(TALLOC_CTX *mem_ctx,
|
|
struct ldb_message *msg,
|
|
+ const char **attr_map,
|
|
struct certmap_info **certmap)
|
|
{
|
|
int ret;
|
|
@@ -275,13 +286,24 @@ errno_t sysdb_ldb_msg_attr_to_certmap_info(TALLOC_CTX *mem_ctx,
|
|
uint64_t tmp_uint;
|
|
struct ldb_message_element *tmp_el;
|
|
|
|
+ if (msg == NULL || attr_map == NULL || certmap == NULL) {
|
|
+ DEBUG(SSSDBG_CRIT_FAILURE, "Invalid input.\n");
|
|
+ return EINVAL;
|
|
+ }
|
|
+
|
|
+ for (d = 0; d < SSS_CMIM_SENTINEL; d++) {
|
|
+ if (attr_map[d] == NULL) {
|
|
+ DEBUG(SSSDBG_CRIT_FAILURE, "Invalid attribute map");
|
|
+ return EINVAL;
|
|
+ }
|
|
+ }
|
|
|
|
map = talloc_zero(mem_ctx, struct certmap_info);
|
|
if (map == NULL) {
|
|
return ENOMEM;
|
|
}
|
|
|
|
- tmp_str = ldb_msg_find_attr_as_string(msg, SYSDB_NAME, NULL);
|
|
+ tmp_str = ldb_msg_find_attr_as_string(msg, attr_map[SSS_CMIM_NAME], NULL);
|
|
if (tmp_str == NULL) {
|
|
DEBUG(SSSDBG_MINOR_FAILURE, "The object [%s] doesn't have a name.\n",
|
|
ldb_dn_get_linearized(msg->dn));
|
|
@@ -295,7 +317,7 @@ errno_t sysdb_ldb_msg_attr_to_certmap_info(TALLOC_CTX *mem_ctx,
|
|
goto done;
|
|
}
|
|
|
|
- tmp_str = ldb_msg_find_attr_as_string(msg, SYSDB_CERTMAP_MAPPING_RULE,
|
|
+ tmp_str = ldb_msg_find_attr_as_string(msg, attr_map[SSS_CMIM_MAPPING_RULE],
|
|
NULL);
|
|
if (tmp_str != NULL) {
|
|
map->map_rule = talloc_strdup(map, tmp_str);
|
|
@@ -306,7 +328,7 @@ errno_t sysdb_ldb_msg_attr_to_certmap_info(TALLOC_CTX *mem_ctx,
|
|
}
|
|
}
|
|
|
|
- tmp_str = ldb_msg_find_attr_as_string(msg, SYSDB_CERTMAP_MATCHING_RULE,
|
|
+ tmp_str = ldb_msg_find_attr_as_string(msg, attr_map[SSS_CMIM_MATCHING_RULE],
|
|
NULL);
|
|
if (tmp_str != NULL) {
|
|
map->match_rule = talloc_strdup(map, tmp_str);
|
|
@@ -317,7 +339,7 @@ errno_t sysdb_ldb_msg_attr_to_certmap_info(TALLOC_CTX *mem_ctx,
|
|
}
|
|
}
|
|
|
|
- tmp_uint = ldb_msg_find_attr_as_uint64(msg, SYSDB_CERTMAP_PRIORITY,
|
|
+ tmp_uint = ldb_msg_find_attr_as_uint64(msg, attr_map[SSS_CMIM_PRIORITY],
|
|
(uint64_t) -1);
|
|
if (tmp_uint != (uint64_t) -1) {
|
|
if (tmp_uint > UINT32_MAX) {
|
|
@@ -332,7 +354,7 @@ errno_t sysdb_ldb_msg_attr_to_certmap_info(TALLOC_CTX *mem_ctx,
|
|
map->priority = SSS_CERTMAP_MIN_PRIO;
|
|
}
|
|
|
|
- tmp_el = ldb_msg_find_element(msg, SYSDB_CERTMAP_DOMAINS);
|
|
+ tmp_el = ldb_msg_find_element(msg, attr_map[SSS_CMIM_DOMAINS]);
|
|
if (tmp_el != NULL) {
|
|
num_values = tmp_el->num_values;
|
|
} else {
|
|
@@ -379,9 +401,9 @@ errno_t sysdb_get_certmap(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb,
|
|
TALLOC_CTX *tmp_ctx = NULL;
|
|
struct ldb_result *res;
|
|
const char *attrs[] = {SYSDB_NAME,
|
|
- SYSDB_CERTMAP_PRIORITY,
|
|
- SYSDB_CERTMAP_MATCHING_RULE,
|
|
SYSDB_CERTMAP_MAPPING_RULE,
|
|
+ SYSDB_CERTMAP_MATCHING_RULE,
|
|
+ SYSDB_CERTMAP_PRIORITY,
|
|
SYSDB_CERTMAP_DOMAINS,
|
|
NULL};
|
|
const char *config_attrs[] = {SYSDB_CERTMAP_USER_NAME_HINT,
|
|
@@ -434,7 +456,8 @@ errno_t sysdb_get_certmap(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb,
|
|
}
|
|
|
|
for (c = 0; c < res->count; c++) {
|
|
- ret = sysdb_ldb_msg_attr_to_certmap_info(maps, res->msgs[c], &maps[c]);
|
|
+ ret = sysdb_ldb_msg_attr_to_certmap_info(maps, res->msgs[c], attrs,
|
|
+ &maps[c]);
|
|
if (ret != EOK) {
|
|
DEBUG(SSSDBG_OP_FAILURE,
|
|
"sysdb_ldb_msg_attr_to_certmap_info failed.\n");
|
|
--
|
|
2.9.5
|
|
|