diff options
author | Stef Walter <stefw@gnome.org> | 2012-04-11 15:02:10 +0200 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2012-06-12 21:28:06 -0400 |
commit | 3c60433641ce2e86b9b04778c8f8652ef0d097e4 (patch) | |
tree | 7e62e915dc54fc40305e5e81714190154783620c /src/responder | |
parent | 6199bd6b41e8b280e65db4b4bb17a1c5c0444aa9 (diff) | |
download | sssd-3c60433641ce2e86b9b04778c8f8652ef0d097e4.tar.gz sssd-3c60433641ce2e86b9b04778c8f8652ef0d097e4.tar.bz2 sssd-3c60433641ce2e86b9b04778c8f8652ef0d097e4.zip |
Make re_expression and full_name_format per domain options
* Allows different user/domain qualified names for different
domains. For example Domain\User or user@domain.
* The global re_expression and full_name_format options remain
as defaults for the domains.
* Subdomains get the re_expression and full_name_format of
their parent domain.
https://bugzilla.redhat.com/show_bug.cgi?id=811663
Diffstat (limited to 'src/responder')
-rw-r--r-- | src/responder/autofs/autofssrv_cmd.c | 4 | ||||
-rw-r--r-- | src/responder/common/negcache.c | 15 | ||||
-rw-r--r-- | src/responder/common/negcache.h | 1 | ||||
-rw-r--r-- | src/responder/common/responder.h | 6 | ||||
-rw-r--r-- | src/responder/common/responder_common.c | 14 | ||||
-rw-r--r-- | src/responder/nss/nsssrv.c | 3 | ||||
-rw-r--r-- | src/responder/nss/nsssrv_cmd.c | 22 | ||||
-rw-r--r-- | src/responder/nss/nsssrv_netgroup.c | 4 | ||||
-rw-r--r-- | src/responder/nss/nsssrv_services.c | 12 | ||||
-rw-r--r-- | src/responder/pam/pamsrv.c | 3 | ||||
-rw-r--r-- | src/responder/pam/pamsrv_cmd.c | 20 | ||||
-rw-r--r-- | src/responder/ssh/sshsrv_cmd.c | 4 | ||||
-rw-r--r-- | src/responder/sudo/sudosrv_cmd.c | 4 |
13 files changed, 57 insertions, 55 deletions
diff --git a/src/responder/autofs/autofssrv_cmd.c b/src/responder/autofs/autofssrv_cmd.c index 7064591a..4dfa94e4 100644 --- a/src/responder/autofs/autofssrv_cmd.c +++ b/src/responder/autofs/autofssrv_cmd.c @@ -374,8 +374,8 @@ setautomntent_send(TALLOC_CTX *mem_ctx, dctx->cmd_ctx = state->cmdctx; state->dctx = dctx; - ret = sss_parse_name(state, client->rctx->names, rawname, - &domname, &state->mapname); + ret = sss_parse_name_for_domains(state, client->rctx->domains, rawname, + &domname, &state->mapname); if (ret != EOK) { DEBUG(SSSDBG_FATAL_FAILURE, ("Invalid name received [%s]\n", rawname)); diff --git a/src/responder/common/negcache.c b/src/responder/common/negcache.c index dd4c0008..b59b1f34 100644 --- a/src/responder/common/negcache.c +++ b/src/responder/common/negcache.c @@ -565,7 +565,6 @@ int sss_ncache_reset_permament(struct sss_nc_ctx *ctx) errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache, struct confdb_ctx *cdb, - struct sss_names_ctx *names_ctx, struct resp_ctx *rctx) { errno_t ret; @@ -597,8 +596,8 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache, filter_set = true; for (i = 0; (filter_list && filter_list[i]); i++) { - ret = sss_parse_name(tmpctx, names_ctx, filter_list[i], - &domainname, &name); + ret = sss_parse_name_for_domains(tmpctx, domain_list, filter_list[i], + &domainname, &name); if (ret != EOK) { DEBUG(1, ("Invalid name in filterUsers list: [%s] (%d)\n", filter_list[i], ret)); @@ -642,8 +641,8 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache, else if (ret != EOK) goto done; for (i = 0; (filter_list && filter_list[i]); i++) { - ret = sss_parse_name(tmpctx, names_ctx, filter_list[i], - &domainname, &name); + ret = sss_parse_name_for_domains(tmpctx, domain_list, filter_list[i], + &domainname, &name); if (ret != EOK) { DEBUG(1, ("Invalid name in filterUsers list: [%s] (%d)\n", filter_list[i], ret)); @@ -694,7 +693,7 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache, filter_set = true; for (i = 0; (filter_list && filter_list[i]); i++) { - ret = sss_parse_name(tmpctx, names_ctx, filter_list[i], + ret = sss_parse_name(tmpctx, dom->names, filter_list[i], &domainname, &name); if (ret != EOK) { DEBUG(1, ("Invalid name in filterGroups list: [%s] (%d)\n", @@ -739,8 +738,8 @@ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache, else if (ret != EOK) goto done; for (i = 0; (filter_list && filter_list[i]); i++) { - ret = sss_parse_name(tmpctx, names_ctx, filter_list[i], - &domainname, &name); + ret = sss_parse_name_for_domains(tmpctx, domain_list, filter_list[i], + &domainname, &name); if (ret != EOK) { DEBUG(1, ("Invalid name in filterGroups list: [%s] (%d)\n", filter_list[i], ret)); diff --git a/src/responder/common/negcache.h b/src/responder/common/negcache.h index 9d070c69..b2e6a7a9 100644 --- a/src/responder/common/negcache.h +++ b/src/responder/common/negcache.h @@ -72,7 +72,6 @@ int sss_ncache_reset_permament(struct sss_nc_ctx *ctx); */ errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache, struct confdb_ctx *cdb, - struct sss_names_ctx *names_ctx, struct resp_ctx *rctx); #endif /* _NSS_NEG_CACHE_H_ */ diff --git a/src/responder/common/responder.h b/src/responder/common/responder.h index 27a58eae..2cc85445 100644 --- a/src/responder/common/responder.h +++ b/src/responder/common/responder.h @@ -93,8 +93,6 @@ struct resp_ctx { const char *sss_pipe_name; const char *confdb_service_path; - struct sss_names_ctx *names; - hash_table_t *dp_request_table; struct timeval get_domains_last_call; @@ -154,6 +152,10 @@ int sss_parse_name(TALLOC_CTX *memctx, struct sss_names_ctx *snctx, const char *orig, char **domain, char **name); +int sss_parse_name_for_domains(TALLOC_CTX *memctx, + struct sss_domain_info *domains, + const char *orig, char **domain, char **name); + int sss_dp_get_domain_conn(struct resp_ctx *rctx, const char *domain, struct be_conn **_conn); struct sss_domain_info * diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c index faff0feb..2e3e98a9 100644 --- a/src/responder/common/responder_common.c +++ b/src/responder/common/responder_common.c @@ -581,6 +581,14 @@ int sss_process_init(TALLOC_CTX *mem_ctx, continue; } + ret = sss_names_init(rctx->cdb, rctx->cdb, dom->name, &dom->names); + if (ret != EOK) { + DEBUG(SSSDBG_FATAL_FAILURE, + ("fatal error initializing regex data for domain: %s\n", + dom->name)); + return ret; + } + ret = sss_dp_init(rctx, dp_intf, cli_name, dom); if (ret != EOK) { DEBUG(0, ("fatal error setting up backend connector\n")); @@ -594,12 +602,6 @@ int sss_process_init(TALLOC_CTX *mem_ctx, return ret; } - ret = sss_names_init(rctx, rctx->cdb, &rctx->names); - if (ret != EOK) { - DEBUG(0, ("fatal error initializing regex data\n")); - return ret; - } - /* after all initializations we are ready to listen on our socket */ ret = set_unix_socket(rctx); if (ret != EOK) { diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c index 85bf6dc8..62253804 100644 --- a/src/responder/nss/nsssrv.c +++ b/src/responder/nss/nsssrv.c @@ -162,8 +162,7 @@ static int nss_get_config(struct nss_ctx *nctx, nctx->cache_refresh_percent = 0; } - ret = sss_ncache_prepopulate(nctx->ncache, cdb, nctx->rctx->names, - nctx->rctx); + ret = sss_ncache_prepopulate(nctx->ncache, cdb, nctx->rctx); if (ret != EOK) { goto done; } diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c index 9f286444..fc504700 100644 --- a/src/responder/nss/nsssrv_cmd.c +++ b/src/responder/nss/nsssrv_cmd.c @@ -235,11 +235,13 @@ static int fill_pwent(struct sss_packet *packet, int i, ret, num, t; bool add_domain = dom->fqnames; const char *domain = dom->name; - const char *namefmt = nctx->rctx->names->fq_fmt; + const char *namefmt; bool packet_initialized = false; int ncret; TALLOC_CTX *tmp_ctx = NULL; + namefmt = dom->names->fq_fmt; + if (add_domain) dom_len = strlen(domain); to_sized_string(&pwfield, nctx->pwfield); @@ -794,8 +796,8 @@ static int nss_cmd_getpwnam(struct cli_ctx *cctx) rawname = (const char *)body; domname = NULL; - ret = sss_parse_name(cmdctx, cctx->rctx->names, rawname, - &domname, &cmdctx->name); + ret = sss_parse_name_for_domains(cmdctx, cctx->rctx->domains, rawname, + &domname, &cmdctx->name); if (ret != EOK) { DEBUG(2, ("Invalid name received [%s]\n", rawname)); ret = ENOENT; @@ -1681,7 +1683,7 @@ static int fill_members(struct sss_packet *packet, size_t rsize = *_rsize; char *tmpstr; struct sized_string name; - const char *namefmt = nctx->rctx->names->fq_fmt; + const char *namefmt = dom->names->fq_fmt; TALLOC_CTX *tmp_ctx = NULL; size_t delim; @@ -1820,9 +1822,11 @@ static int fill_grent(struct sss_packet *packet, size_t rzero, rsize; bool add_domain = dom->fqnames; const char *domain = dom->name; - const char *namefmt = nctx->rctx->names->fq_fmt; + const char *namefmt; TALLOC_CTX *tmp_ctx = NULL; + namefmt = dom->names->fq_fmt; + if (add_domain) { delim = 1; dom_len = strlen(domain); @@ -2258,8 +2262,8 @@ static int nss_cmd_getgrnam(struct cli_ctx *cctx) rawname = (const char *)body; domname = NULL; - ret = sss_parse_name(cmdctx, cctx->rctx->names, rawname, - &domname, &cmdctx->name); + ret = sss_parse_name_for_domains(cmdctx, cctx->rctx->domains, rawname, + &domname, &cmdctx->name); if (ret != EOK) { DEBUG(2, ("Invalid name received [%s]\n", rawname)); ret = ENOENT; @@ -3368,8 +3372,8 @@ static int nss_cmd_initgroups(struct cli_ctx *cctx) rawname = (const char *)body; domname = NULL; - ret = sss_parse_name(cmdctx, cctx->rctx->names, rawname, - &domname, &cmdctx->name); + ret = sss_parse_name_for_domains(cmdctx, cctx->rctx->domains, rawname, + &domname, &cmdctx->name); if (ret != EOK) { DEBUG(2, ("Invalid name received [%s]\n", rawname)); ret = ENOENT; diff --git a/src/responder/nss/nsssrv_netgroup.c b/src/responder/nss/nsssrv_netgroup.c index 593b7e43..774d182b 100644 --- a/src/responder/nss/nsssrv_netgroup.c +++ b/src/responder/nss/nsssrv_netgroup.c @@ -197,8 +197,8 @@ static struct tevent_req *setnetgrent_send(TALLOC_CTX *mem_ctx, dctx = state->dctx; dctx->cmdctx = state->cmdctx; - ret = sss_parse_name(state, client->rctx->names, rawname, - &domname, &state->netgr_shortname); + ret = sss_parse_name_for_domains(state, client->rctx->domains, rawname, + &domname, &state->netgr_shortname); if (ret != EOK) { DEBUG(2, ("Invalid name received [%s]\n", rawname)); goto error; diff --git a/src/responder/nss/nsssrv_services.c b/src/responder/nss/nsssrv_services.c index 2e539f13..e0ee21c3 100644 --- a/src/responder/nss/nsssrv_services.c +++ b/src/responder/nss/nsssrv_services.c @@ -779,7 +779,7 @@ done: errno_t parse_getservbyname(TALLOC_CTX *mem_ctx, uint8_t *body, size_t blen, - struct sss_names_ctx *names, + struct sss_domain_info *domains, char **domain_name, char **service_name, char **service_protocol); @@ -820,7 +820,7 @@ int nss_cmd_getservbyname(struct cli_ctx *cctx) } ret = parse_getservbyname(cmdctx, body, blen, - cctx->rctx->names, + cctx->rctx->domains, &domname, &service_name, &service_protocol); @@ -870,7 +870,7 @@ done: errno_t parse_getservbyname(TALLOC_CTX *mem_ctx, uint8_t *body, size_t blen, - struct sss_names_ctx *names, + struct sss_domain_info *domains, char **domain_name, char **service_name, char **service_protocol) @@ -959,8 +959,8 @@ errno_t parse_getservbyname(TALLOC_CTX *mem_ctx, } } - ret = sss_parse_name(tmp_ctx, names, rawname, - &domname, &svc_name); + ret = sss_parse_name_for_domains(tmp_ctx, domains, rawname, + &domname, &svc_name); if (ret != EOK) { DEBUG(SSSDBG_MINOR_FAILURE, ("Could not split name and domain of [%s]\n", @@ -1034,7 +1034,6 @@ nss_cmd_getserv_done(struct tevent_req *req) errno_t parse_getservbyport(TALLOC_CTX *mem_ctx, uint8_t *body, size_t blen, - struct sss_names_ctx *names, uint16_t *service_port, char **service_protocol) { @@ -1138,7 +1137,6 @@ int nss_cmd_getservbyport(struct cli_ctx *cctx) } ret = parse_getservbyport(cmdctx, body, blen, - cctx->rctx->names, &port, &service_protocol); if (ret != EOK) { diff --git a/src/responder/pam/pamsrv.c b/src/responder/pam/pamsrv.c index ecbf7d9a..c94596c4 100644 --- a/src/responder/pam/pamsrv.c +++ b/src/responder/pam/pamsrv.c @@ -171,8 +171,7 @@ static int pam_process_init(TALLOC_CTX *mem_ctx, goto done; } - ret = sss_ncache_prepopulate(pctx->ncache, cdb, pctx->rctx->names, - pctx->rctx); + ret = sss_ncache_prepopulate(pctx->ncache, cdb, pctx->rctx); if (ret != EOK) { goto done; } diff --git a/src/responder/pam/pamsrv_cmd.c b/src/responder/pam/pamsrv_cmd.c index f1fdc3f0..f6c1e835 100644 --- a/src/responder/pam/pamsrv_cmd.c +++ b/src/responder/pam/pamsrv_cmd.c @@ -115,7 +115,7 @@ static int pd_set_primary_name(const struct ldb_message *msg,struct pam_data *pd return EOK; } -static int pam_parse_in_data_v2(struct sss_names_ctx *snctx, +static int pam_parse_in_data_v2(struct sss_domain_info *domains, struct pam_data *pd, uint8_t *body, size_t blen) { @@ -153,8 +153,8 @@ static int pam_parse_in_data_v2(struct sss_names_ctx *snctx, ret = extract_string(&pam_user, size, body, blen, &c); if (ret != EOK) return ret; - ret = sss_parse_name(pd, snctx, pam_user, - &pd->domain, &pd->user); + ret = sss_parse_name_for_domains(pd, domains, pam_user, + &pd->domain, &pd->user); if (ret != EOK) return ret; break; case SSS_PAM_ITEM_SERVICE: @@ -205,13 +205,13 @@ static int pam_parse_in_data_v2(struct sss_names_ctx *snctx, } -static int pam_parse_in_data_v3(struct sss_names_ctx *snctx, +static int pam_parse_in_data_v3(struct sss_domain_info *domains, struct pam_data *pd, uint8_t *body, size_t blen) { int ret; - ret = pam_parse_in_data_v2(snctx, pd, body, blen); + ret = pam_parse_in_data_v2(domains, pd, body, blen); if (ret != EOK) { DEBUG(1, ("pam_parse_in_data_v2 failed.\n")); return ret; @@ -225,7 +225,7 @@ static int pam_parse_in_data_v3(struct sss_names_ctx *snctx, return EOK; } -static int pam_parse_in_data(struct sss_names_ctx *snctx, +static int pam_parse_in_data(struct sss_domain_info *domains, struct pam_data *pd, uint8_t *body, size_t blen) { @@ -241,7 +241,7 @@ static int pam_parse_in_data(struct sss_names_ctx *snctx, for (start = end; end < last; end++) if (body[end] == '\0') break; if (body[end++] != '\0') return EINVAL; - ret = sss_parse_name(pd, snctx, (char *)&body[start], &pd->domain, &pd->user); + ret = sss_parse_name_for_domains(pd, domains, (char *)&body[start], &pd->domain, &pd->user); if (ret != EOK) return ret; for (start = end; end < last; end++) if (body[end] == '\0') break; @@ -891,13 +891,13 @@ static int pam_forwarder(struct cli_ctx *cctx, int pam_cmd) switch (cctx->cli_protocol_version->version) { case 1: - ret = pam_parse_in_data(cctx->rctx->names, pd, body, blen); + ret = pam_parse_in_data(cctx->rctx->domains, pd, body, blen); break; case 2: - ret = pam_parse_in_data_v2(cctx->rctx->names, pd, body, blen); + ret = pam_parse_in_data_v2(cctx->rctx->domains, pd, body, blen); break; case 3: - ret = pam_parse_in_data_v3(cctx->rctx->names, pd, body, blen); + ret = pam_parse_in_data_v3(cctx->rctx->domains, pd, body, blen); break; default: DEBUG(1, ("Illegal protocol version [%d].\n", diff --git a/src/responder/ssh/sshsrv_cmd.c b/src/responder/ssh/sshsrv_cmd.c index fa02025e..3c67fd4e 100644 --- a/src/responder/ssh/sshsrv_cmd.c +++ b/src/responder/ssh/sshsrv_cmd.c @@ -704,8 +704,8 @@ ssh_cmd_parse_request(struct ssh_cmd_ctx *cmd_ctx) } c += name_len; - ret = sss_parse_name(cmd_ctx, cctx->rctx->names, name, - &cmd_ctx->domname, &cmd_ctx->name); + ret = sss_parse_name_for_domains(cmd_ctx, cctx->rctx->domains, name, + &cmd_ctx->domname, &cmd_ctx->name); if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, ("Invalid name received [%s]\n", name)); return ENOENT; diff --git a/src/responder/sudo/sudosrv_cmd.c b/src/responder/sudo/sudosrv_cmd.c index 0f31df15..f72e2be7 100644 --- a/src/responder/sudo/sudosrv_cmd.c +++ b/src/responder/sudo/sudosrv_cmd.c @@ -214,8 +214,8 @@ static int sudosrv_cmd_get_sudorules(struct cli_ctx *cli_ctx) } domname = NULL; - ret = sss_parse_name(cmd_ctx, cli_ctx->rctx->names, rawname, - &domname, &cmd_ctx->username); + ret = sss_parse_name_for_domains(cmd_ctx, cli_ctx->rctx->domains, rawname, + &domname, &cmd_ctx->username); if (ret != EOK) { DEBUG(2, ("Invalid name received [%s]\n", rawname)); ret = ENOENT; |