diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2014-01-24 10:02:23 +0100 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-01-24 13:54:16 +0100 |
commit | 3a091bd11739af7807b394470bb7a7f3c42f7b7b (patch) | |
tree | b7c21b8db1568b1e068bc28f458f04cc5582bdec | |
parent | 863b086dc8402a28f35b5def9a336c8112194102 (diff) | |
download | sssd-3a091bd11739af7807b394470bb7a7f3c42f7b7b.tar.gz sssd-3a091bd11739af7807b394470bb7a7f3c42f7b7b.tar.xz sssd-3a091bd11739af7807b394470bb7a7f3c42f7b7b.zip |
LDAP: Don't abort request if no id mapping domain matches
If an ID was requested from the back end, but no ID mapping domain
matched, the request ended with a scary error message. It's better to
treat the request as if no such ID was found in the domain
Related:
https://fedorahosted.org/sssd/ticket/2200
-rw-r--r-- | src/providers/ad/ad_id.c | 2 | ||||
-rw-r--r-- | src/providers/ldap/ldap_id.c | 44 |
2 files changed, 40 insertions, 6 deletions
diff --git a/src/providers/ad/ad_id.c b/src/providers/ad/ad_id.c index ada47753f..e74653b73 100644 --- a/src/providers/ad/ad_id.c +++ b/src/providers/ad/ad_id.c @@ -386,7 +386,7 @@ ad_account_info_complete(struct tevent_req *req) error_text = NULL; } else { DEBUG(SSSDBG_FATAL_FAILURE, - ("Bug: dp_error is OK on failed request")); + ("Bug: dp_error is OK on failed request\n")); dp_error = DP_ERR_FATAL; error_text = req_error_text; } diff --git a/src/providers/ldap/ldap_id.c b/src/providers/ldap/ldap_id.c index 793bc99eb..e36c1f697 100644 --- a/src/providers/ldap/ldap_id.c +++ b/src/providers/ldap/ldap_id.c @@ -129,7 +129,20 @@ struct tevent_req *users_get_send(TALLOC_CTX *memctx, /* Convert the UID to its objectSID */ err = sss_idmap_unix_to_sid(ctx->opts->idmap_ctx->map, uid, &sid); - if (err != IDMAP_SUCCESS) { + if (err == IDMAP_NO_DOMAIN) { + DEBUG(SSSDBG_MINOR_FAILURE, + ("[%s] did not match any configured ID mapping domain\n", + name)); + + ret = sysdb_delete_user(state->sysdb, + state->domain, NULL, uid); + if (ret == ENOENT) { + /* Ignore errors to remove users that were not cached previously */ + ret = EOK; + } + + goto fail; + } else if (err != IDMAP_SUCCESS) { DEBUG(SSSDBG_MINOR_FAILURE, ("Mapping ID [%s] to SID failed: [%s]\n", name, idmap_error_string(err))); @@ -213,7 +226,11 @@ struct tevent_req *users_get_send(TALLOC_CTX *memctx, return req; fail: - tevent_req_error(req, ret); + if (ret != EOK) { + tevent_req_error(req, ret); + } else { + tevent_req_done(req); + } tevent_req_post(req, ev); return req; } @@ -496,10 +513,23 @@ struct tevent_req *groups_get_send(TALLOC_CTX *memctx, goto fail; } - /* Convert the UID to its objectSID */ + /* Convert the GID to its objectSID */ err = sss_idmap_unix_to_sid(ctx->opts->idmap_ctx->map, gid, &sid); - if (err != IDMAP_SUCCESS) { + if (err == IDMAP_NO_DOMAIN) { + DEBUG(SSSDBG_MINOR_FAILURE, + ("[%s] did not match any configured ID mapping domain\n", + name)); + + ret = sysdb_delete_group(state->sysdb, + state->domain, NULL, gid); + if (ret == ENOENT) { + /* Ignore errors to remove users that were not cached previously */ + ret = EOK; + } + + goto fail; + } else if (err != IDMAP_SUCCESS) { DEBUG(SSSDBG_MINOR_FAILURE, ("Mapping ID [%s] to SID failed: [%s]\n", name, idmap_error_string(err))); @@ -587,7 +617,11 @@ struct tevent_req *groups_get_send(TALLOC_CTX *memctx, return req; fail: - tevent_req_error(req, ret); + if (ret != EOK) { + tevent_req_error(req, ret); + } else { + tevent_req_done(req); + } tevent_req_post(req, ev); return req; } |