summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2012-10-11 14:50:33 +0200
committerJakub Hrozek <jhrozek@redhat.com>2012-10-12 16:42:17 +0200
commit1774ee9a61b9d691dadd1a0538f32bcdcc84f72f (patch)
treea60de2d48749e3cbed3b62f1d2383eecda99def8
parent99bac83188601c2b07e0b141aac7dc7d882b464a (diff)
downloadsssd-1774ee9a61b9d691dadd1a0538f32bcdcc84f72f.tar.gz
sssd-1774ee9a61b9d691dadd1a0538f32bcdcc84f72f.tar.bz2
sssd-1774ee9a61b9d691dadd1a0538f32bcdcc84f72f.zip
Check for subdomains if getpwuid or getgrgid are the first requests
Fixes https://fedorahosted.org/sssd/ticket/1561
-rw-r--r--src/responder/nss/nsssrv_cmd.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
index 26a34736..42d32e9d 100644
--- a/src/responder/nss/nsssrv_cmd.c
+++ b/src/responder/nss/nsssrv_cmd.c
@@ -1090,6 +1090,7 @@ done:
}
}
+static void nss_cmd_getpwuid_cb(struct tevent_req *req);
static int nss_cmd_getpwuid(struct cli_ctx *cctx)
{
struct nss_cmd_ctx *cmdctx;
@@ -1098,6 +1099,7 @@ static int nss_cmd_getpwuid(struct cli_ctx *cctx)
uint8_t *body;
size_t blen;
int ret;
+ struct tevent_req *req;
nctx = talloc_get_type(cctx->rctx->pvt_ctx, struct nss_ctx);
@@ -1137,6 +1139,17 @@ static int nss_cmd_getpwuid(struct cli_ctx *cctx)
dctx->check_provider = NEED_CHECK_PROVIDER(dctx->domain->provider);
+ if (cctx->rctx->get_domains_last_call.tv_sec == 0) {
+ req = sss_dp_get_domains_send(cctx->rctx, cctx->rctx, false, NULL);
+ if (req == NULL) {
+ ret = ENOMEM;
+ } else {
+ tevent_req_set_callback(req, nss_cmd_getpwuid_cb, dctx);
+ ret = EAGAIN;
+ }
+ goto done;
+ }
+
/* ok, find it ! */
ret = nss_cmd_getpwuid_search(dctx);
if (ret == EOK) {
@@ -1148,6 +1161,29 @@ done:
return nss_cmd_done(cmdctx, ret);
}
+static void nss_cmd_getpwuid_cb(struct tevent_req *req)
+{
+ struct nss_dom_ctx *dctx = tevent_req_callback_data(req, struct nss_dom_ctx);
+ struct nss_cmd_ctx *cmdctx = dctx->cmdctx;
+ errno_t ret;
+
+ ret = sss_dp_get_domains_recv(req);
+ talloc_free(req);
+ if (ret != EOK) {
+ goto done;
+ }
+
+ /* ok, find it ! */
+ ret = nss_cmd_getpwuid_search(dctx);
+ if (ret == EOK) {
+ /* we have results to return */
+ ret = nss_cmd_getpw_send_reply(dctx, true);
+ }
+
+done:
+ nss_cmd_done(cmdctx, ret);
+}
+
/* to keep it simple at this stage we are retrieving the
* full enumeration again for each request for each process
* and we also block on setpwent() for the full time needed
@@ -2564,6 +2600,7 @@ done:
}
}
+static void nss_cmd_getgrgid_cb(struct tevent_req *req);
static int nss_cmd_getgrgid(struct cli_ctx *cctx)
{
struct nss_cmd_ctx *cmdctx;
@@ -2572,6 +2609,7 @@ static int nss_cmd_getgrgid(struct cli_ctx *cctx)
uint8_t *body;
size_t blen;
int ret;
+ struct tevent_req *req;
nctx = talloc_get_type(cctx->rctx->pvt_ctx, struct nss_ctx);
@@ -2611,6 +2649,17 @@ static int nss_cmd_getgrgid(struct cli_ctx *cctx)
dctx->check_provider = NEED_CHECK_PROVIDER(dctx->domain->provider);
+ if (cctx->rctx->get_domains_last_call.tv_sec == 0) {
+ req = sss_dp_get_domains_send(cctx->rctx, cctx->rctx, false, NULL);
+ if (req == NULL) {
+ ret = ENOMEM;
+ } else {
+ tevent_req_set_callback(req, nss_cmd_getgrgid_cb, dctx);
+ ret = EAGAIN;
+ }
+ goto done;
+ }
+
/* ok, find it ! */
ret = nss_cmd_getgrgid_search(dctx);
if (ret == EOK) {
@@ -2622,6 +2671,29 @@ done:
return nss_cmd_done(cmdctx, ret);
}
+static void nss_cmd_getgrgid_cb(struct tevent_req *req)
+{
+ struct nss_dom_ctx *dctx = tevent_req_callback_data(req, struct nss_dom_ctx);
+ struct nss_cmd_ctx *cmdctx = dctx->cmdctx;
+ errno_t ret;
+
+ ret = sss_dp_get_domains_recv(req);
+ talloc_free(req);
+ if (ret != EOK) {
+ goto done;
+ }
+
+ /* ok, find it ! */
+ ret = nss_cmd_getgrgid_search(dctx);
+ if (ret == EOK) {
+ /* we have results to return */
+ ret = nss_cmd_getpw_send_reply(dctx, true);
+ }
+
+done:
+ nss_cmd_done(cmdctx, ret);
+}
+
/* to keep it simple at this stage we are retrieving the
* full enumeration again for each request for each process
* and we also block on setgrent() for the full time needed