|
|
6cf099 |
From 83e150a2b200ec50f2f02229d9662e1468e286df Mon Sep 17 00:00:00 2001
|
|
|
6cf099 |
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
|
|
|
6cf099 |
Date: Wed, 19 Aug 2015 12:28:21 +0200
|
|
|
6cf099 |
Subject: [PATCH 62/66] sss_override: support domains that require fqname
|
|
|
6cf099 |
|
|
|
6cf099 |
Resolves:
|
|
|
6cf099 |
https://fedorahosted.org/sssd/ticket/2757
|
|
|
6cf099 |
|
|
|
6cf099 |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
6cf099 |
---
|
|
|
6cf099 |
src/tools/sss_override.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++--
|
|
|
6cf099 |
1 file changed, 57 insertions(+), 2 deletions(-)
|
|
|
6cf099 |
|
|
|
6cf099 |
diff --git a/src/tools/sss_override.c b/src/tools/sss_override.c
|
|
|
6cf099 |
index e84a7b922dfcf179f8010dc4cced0eafd89a2c76..84b51c537842b7281a523f58c2cfbdfd38e54c72 100644
|
|
|
6cf099 |
--- a/src/tools/sss_override.c
|
|
|
6cf099 |
+++ b/src/tools/sss_override.c
|
|
|
6cf099 |
@@ -272,6 +272,54 @@ static struct sysdb_attrs *build_group_attrs(TALLOC_CTX *mem_ctx,
|
|
|
6cf099 |
return build_attrs(mem_ctx, group->name, 0, group->gid, 0, NULL, NULL);
|
|
|
6cf099 |
}
|
|
|
6cf099 |
|
|
|
6cf099 |
+static char *get_fqname(TALLOC_CTX *mem_ctx,
|
|
|
6cf099 |
+ struct sss_domain_info *domain,
|
|
|
6cf099 |
+ const char *name)
|
|
|
6cf099 |
+{
|
|
|
6cf099 |
+ char *fqname;
|
|
|
6cf099 |
+ size_t fqlen;
|
|
|
6cf099 |
+ size_t check;
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ if (domain == NULL) {
|
|
|
6cf099 |
+ return NULL;
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ /* Get length. */
|
|
|
6cf099 |
+ fqlen = sss_fqname(NULL, 0, domain->names, domain, name);
|
|
|
6cf099 |
+ if (fqlen > 0) {
|
|
|
6cf099 |
+ fqlen++; /* \0 */
|
|
|
6cf099 |
+ } else {
|
|
|
6cf099 |
+ return NULL;
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ fqname = talloc_zero_array(mem_ctx, char, fqlen);
|
|
|
6cf099 |
+ if (fqname == NULL) {
|
|
|
6cf099 |
+ DEBUG(SSSDBG_CRIT_FAILURE, "talloc_zero_array() failed\n");
|
|
|
6cf099 |
+ return NULL;
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ check = sss_fqname(fqname, fqlen, domain->names, domain, name);
|
|
|
6cf099 |
+ if (check != fqlen - 1) {
|
|
|
6cf099 |
+ DEBUG(SSSDBG_CRIT_FAILURE, "Failed to generate a fully qualified name "
|
|
|
6cf099 |
+ "for user [%s] in [%s]! Skipping user.\n", name, domain->name);
|
|
|
6cf099 |
+ talloc_free(fqname);
|
|
|
6cf099 |
+ return NULL;
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ return fqname;
|
|
|
6cf099 |
+}
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+static char *get_sysname(TALLOC_CTX *mem_ctx,
|
|
|
6cf099 |
+ struct sss_domain_info *domain,
|
|
|
6cf099 |
+ const char *name)
|
|
|
6cf099 |
+{
|
|
|
6cf099 |
+ if (domain == NULL || !domain->fqnames) {
|
|
|
6cf099 |
+ return talloc_strdup(mem_ctx, name);
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
+
|
|
|
6cf099 |
+ return get_fqname(mem_ctx, domain, name);
|
|
|
6cf099 |
+}
|
|
|
6cf099 |
+
|
|
|
6cf099 |
static const char *get_object_dn_and_domain(TALLOC_CTX *mem_ctx,
|
|
|
6cf099 |
enum sysdb_member_type type,
|
|
|
6cf099 |
const char *name,
|
|
|
6cf099 |
@@ -284,6 +332,7 @@ static const char *get_object_dn_and_domain(TALLOC_CTX *mem_ctx,
|
|
|
6cf099 |
struct ldb_result *res;
|
|
|
6cf099 |
const char *dn;
|
|
|
6cf099 |
const char *strtype;
|
|
|
6cf099 |
+ char *sysname;
|
|
|
6cf099 |
bool check_next;
|
|
|
6cf099 |
errno_t ret;
|
|
|
6cf099 |
|
|
|
6cf099 |
@@ -292,16 +341,22 @@ static const char *get_object_dn_and_domain(TALLOC_CTX *mem_ctx,
|
|
|
6cf099 |
return NULL;
|
|
|
6cf099 |
}
|
|
|
6cf099 |
|
|
|
6cf099 |
+ sysname = get_sysname(tmp_ctx, domain, name);
|
|
|
6cf099 |
+ if (sysname == NULL) {
|
|
|
6cf099 |
+ ret = ENOMEM;
|
|
|
6cf099 |
+ goto done;
|
|
|
6cf099 |
+ }
|
|
|
6cf099 |
+
|
|
|
6cf099 |
/* Ensure that the object is in cache. */
|
|
|
6cf099 |
switch (type) {
|
|
|
6cf099 |
case SYSDB_MEMBER_USER:
|
|
|
6cf099 |
- if (getpwnam(name) == NULL) {
|
|
|
6cf099 |
+ if (getpwnam(sysname) == NULL) {
|
|
|
6cf099 |
ret = ENOENT;
|
|
|
6cf099 |
goto done;
|
|
|
6cf099 |
}
|
|
|
6cf099 |
break;
|
|
|
6cf099 |
case SYSDB_MEMBER_GROUP:
|
|
|
6cf099 |
- if (getgrnam(name) == NULL) {
|
|
|
6cf099 |
+ if (getgrnam(sysname) == NULL) {
|
|
|
6cf099 |
ret = ENOENT;
|
|
|
6cf099 |
goto done;
|
|
|
6cf099 |
}
|
|
|
6cf099 |
--
|
|
|
6cf099 |
2.4.3
|
|
|
6cf099 |
|