diff options
author | Simo Sorce <idra@samba.org> | 2009-02-16 20:25:16 -0500 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2009-02-20 18:09:29 -0500 |
commit | b8f07efe5d98071777e3a2863688c8269a7912e4 (patch) | |
tree | 66693078c86c7d6ed289bce3f6aebbd9c6125ea7 /server/nss/nsssrv_dp.c | |
parent | 2d151b22408e78e4b556000125cfc5abe068c846 (diff) | |
download | sssd-b8f07efe5d98071777e3a2863688c8269a7912e4.tar.gz sssd-b8f07efe5d98071777e3a2863688c8269a7912e4.tar.bz2 sssd-b8f07efe5d98071777e3a2863688c8269a7912e4.zip |
Completely rework the nss interface to be able to use 2
types of domains: modern and legacy
modern uses member/meberof, legacy uses memberUid for group
memberships.
Rework the proxy backend to use the legacy style as that's the
format the data comes in (trying to convert would require too
many transformations and increased the number of queries).
Add support for fetching groups in nss.
Add support for enumerating users and groups (requires to enable enumeration
in config) both in nss and in the proxy provider.
Remove confdb_get_domain_basedn() and substitute with generic calls in
the nss init function.
Store a domain structure in the btree not the basedn so that we can add
enumeration flags.
Also make sure NSS understand how to make multiple calls on
enumerations, also make passing the domian parameter always
mandatory, passing in domain=* is not valid anymore.
This work fixes also a few memory, degfault, and logic bugs
found while testing all nss functions (there are still some to
fix that are less critical and much harder to find yet).
Diffstat (limited to 'server/nss/nsssrv_dp.c')
-rw-r--r-- | server/nss/nsssrv_dp.c | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/server/nss/nsssrv_dp.c b/server/nss/nsssrv_dp.c index d6aba556..487ac285 100644 --- a/server/nss/nsssrv_dp.c +++ b/server/nss/nsssrv_dp.c @@ -30,10 +30,21 @@ struct nss_dp_req { nss_dp_callback_t callback; void *callback_ctx; - bool replied; struct timed_event *te; + DBusPendingCall *pending_reply; }; +static int nss_dp_req_destructor(void *ptr) +{ + struct nss_dp_req *req = talloc_get_type(ptr, struct nss_dp_req); + + if (req->pending_reply) { + dbus_pending_call_cancel(req->pending_reply); + } + + return 0; +} + static void nss_dp_send_acct_timeout(struct event_context *ev, struct timed_event *te, struct timeval t, void *data) @@ -44,9 +55,10 @@ static void nss_dp_send_acct_timeout(struct event_context *ev, const char *err_msg = "Request timed out"; ndp_req = talloc_get_type(data, struct nss_dp_req); - ndp_req->replied = true; ndp_req->callback(err_maj, err_min, err_msg, ndp_req->callback_ctx); + + talloc_free(ndp_req); } static int nss_dp_get_reply(DBusPendingCall *pending, @@ -63,11 +75,10 @@ static void nss_dp_send_acct_callback(DBusPendingCall *pending, void *ptr) int ret; ndp_req = talloc_get_type(ptr, struct nss_dp_req); - if (ndp_req->replied) { - DEBUG(5, ("Callback called, but the request was already timed out!\n")); - talloc_free(ndp_req); - return; - } + + /* free timeout event and remove request destructor */ + talloc_free(ndp_req->te); + talloc_set_destructor(ndp_req, NULL); ret = nss_dp_get_reply(pending, &err_maj, &err_min, &err_msg); if (ret != EOK) { @@ -76,9 +87,9 @@ static void nss_dp_send_acct_callback(DBusPendingCall *pending, void *ptr) err_msg = "Failed to get reply from Data Provider"; } - talloc_free(ndp_req->te); - ndp_req->callback(err_maj, err_min, err_msg, ndp_req->callback_ctx); + + talloc_free(ndp_req); } int nss_dp_send_acct_req(struct nss_ctx *nctx, TALLOC_CTX *memctx, @@ -113,6 +124,9 @@ int nss_dp_send_acct_req(struct nss_ctx *nctx, TALLOC_CTX *memctx, case NSS_DP_GROUP: be_type = BE_REQ_GROUP; break; + case NSS_DP_INITGROUPS: + be_type = BE_REQ_INITGROUPS; + break; default: return EINVAL; } @@ -169,15 +183,19 @@ int nss_dp_send_acct_req(struct nss_ctx *nctx, TALLOC_CTX *memctx, return EIO; } - /* setup the timeout handler */ - ndp_req = talloc(memctx, struct nss_dp_req); + ndp_req = talloc_zero(memctx, struct nss_dp_req); if (!ndp_req) { dbus_message_unref(msg); return ENOMEM; } ndp_req->callback = callback; ndp_req->callback_ctx = callback_ctx; - ndp_req->replied = false; + + /* set up destructor */ + ndp_req->pending_reply = pending_reply; + talloc_set_destructor((TALLOC_CTX *)ndp_req, nss_dp_req_destructor); + + /* setup the timeout handler */ gettimeofday(&tv, NULL); tv.tv_sec += timeout/1000; tv.tv_usec += (timeout%1000) * 1000; |