From c6b36ce57391a083162e0918be34f685385df91a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 9 Aug 2009 07:31:31 -0400 Subject: s3:winbind: WINBIND_USERINFO -> wbint_userinfo --- source3/winbindd/wb_getpwsid.c | 2 +- source3/winbindd/wb_queryuser.c | 36 ++++++++++------------------------- source3/winbindd/winbindd.h | 20 ++++--------------- source3/winbindd/winbindd_ads.c | 17 ++++++++++------- source3/winbindd/winbindd_async.c | 2 +- source3/winbindd/winbindd_cache.c | 11 ++++++----- source3/winbindd/winbindd_dual_srv.c | 19 ++---------------- source3/winbindd/winbindd_passdb.c | 10 +++++----- source3/winbindd/winbindd_proto.h | 4 ++-- source3/winbindd/winbindd_reconnect.c | 4 ++-- source3/winbindd/winbindd_rpc.c | 7 ++++--- source3/winbindd/winbindd_user.c | 4 ++-- 12 files changed, 49 insertions(+), 87 deletions(-) (limited to 'source3') diff --git a/source3/winbindd/wb_getpwsid.c b/source3/winbindd/wb_getpwsid.c index fc696cb9a1..1295d5bcbc 100644 --- a/source3/winbindd/wb_getpwsid.c +++ b/source3/winbindd/wb_getpwsid.c @@ -25,7 +25,7 @@ struct wb_getpwsid_state { struct winbindd_domain *user_domain; struct tevent_context *ev; struct dom_sid sid; - struct winbind_userinfo *userinfo; + struct wbint_userinfo *userinfo; struct winbindd_pw *pw; }; diff --git a/source3/winbindd/wb_queryuser.c b/source3/winbindd/wb_queryuser.c index 27b8d29951..1af44000fe 100644 --- a/source3/winbindd/wb_queryuser.c +++ b/source3/winbindd/wb_queryuser.c @@ -23,7 +23,7 @@ struct wb_queryuser_state { struct dom_sid sid; - struct wbint_userinfo info; + struct wbint_userinfo *info; }; static void wb_queryuser_done(struct tevent_req *subreq); @@ -35,7 +35,6 @@ struct tevent_req *wb_queryuser_send(TALLOC_CTX *mem_ctx, struct tevent_req *req, *subreq; struct wb_queryuser_state *state; struct winbindd_domain *domain; - struct winbind_userinfo info; NTSTATUS status; req = tevent_req_create(mem_ctx, &state, struct wb_queryuser_state); @@ -50,21 +49,19 @@ struct tevent_req *wb_queryuser_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } - status = wcache_query_user(domain, state, &state->sid, &info); + state->info = talloc(state, struct wbint_userinfo); + if (tevent_req_nomem(state->info, req)) { + return tevent_req_post(req, ev); + } + + status = wcache_query_user(domain, state, &state->sid, state->info); if (NT_STATUS_IS_OK(status)) { - state->info.acct_name = info.acct_name; - state->info.full_name = info.full_name; - state->info.homedir = info.homedir; - state->info.shell = info.shell; - state->info.primary_gid = info.primary_gid; - sid_copy(&state->info.user_sid, &info.user_sid); - sid_copy(&state->info.group_sid, &info.group_sid); tevent_req_done(req); return tevent_req_post(req, ev); } subreq = rpccli_wbint_QueryUser_send(state, ev, domain->child.rpccli, - &state->sid, &state->info); + &state->sid, state->info); if (tevent_req_nomem(subreq, req)) { return tevent_req_post(req, ev); } @@ -94,28 +91,15 @@ static void wb_queryuser_done(struct tevent_req *subreq) } NTSTATUS wb_queryuser_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, - struct winbind_userinfo **pinfo) + struct wbint_userinfo **pinfo) { struct wb_queryuser_state *state = tevent_req_data( req, struct wb_queryuser_state); - struct winbind_userinfo *info; NTSTATUS status; if (tevent_req_is_nterror(req, &status)) { return status; } - - info = talloc(mem_ctx, struct winbind_userinfo); - if (info == NULL) { - return NT_STATUS_NO_MEMORY; - } - info->acct_name = talloc_move(info, &state->info.acct_name); - info->full_name = talloc_move(info, &state->info.full_name); - info->homedir = talloc_move(info, &state->info.homedir); - info->shell = talloc_move(info, &state->info.shell); - info->primary_gid = state->info.primary_gid; - sid_copy(&info->user_sid, &state->info.user_sid); - sid_copy(&info->group_sid, &state->info.group_sid); - *pinfo = info; + *pinfo = talloc_move(mem_ctx, &state->info); return NT_STATUS_OK; } diff --git a/source3/winbindd/winbindd.h b/source3/winbindd/winbindd.h index baab7fd11a..44ac022720 100644 --- a/source3/winbindd/winbindd.h +++ b/source3/winbindd/winbindd.h @@ -25,6 +25,7 @@ #include "nsswitch/winbind_struct_protocol.h" #include "nsswitch/libwbclient/wbclient.h" +#include "librpc/gen_ndr/wbint.h" #ifdef HAVE_LIBNSCD #include @@ -89,19 +90,6 @@ struct getpwent_user { DOM_SID group_sid; }; -/* Server state structure */ - -typedef struct winbind_userinfo { - const char *acct_name; - const char *full_name; - const char *homedir; - const char *shell; - gid_t primary_gid; /* allow the nss_info - backend to set the primary group */ - DOM_SID user_sid; /* NT user and primary group SIDs */ - DOM_SID group_sid; -} WINBIND_USERINFO; - /* Our connection to the DC */ struct winbindd_cm_conn { @@ -227,11 +215,11 @@ struct winbindd_methods { always correct) */ bool consistent; - /* get a list of users, returning a WINBIND_USERINFO for each one */ + /* get a list of users, returning a wbint_userinfo for each one */ NTSTATUS (*query_user_list)(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, uint32 *num_entries, - WINBIND_USERINFO **info); + struct wbint_userinfo **info); /* get a list of domain groups */ NTSTATUS (*enum_dom_groups)(struct winbindd_domain *domain, @@ -275,7 +263,7 @@ struct winbindd_methods { NTSTATUS (*query_user)(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, const DOM_SID *user_sid, - WINBIND_USERINFO *user_info); + struct wbint_userinfo *user_info); /* lookup all groups that a user is a member of. The backend can also choose to lookup by username or rid for this diff --git a/source3/winbindd/winbindd_ads.c b/source3/winbindd/winbindd_ads.c index 665dd53df1..a9df61d5f4 100644 --- a/source3/winbindd/winbindd_ads.c +++ b/source3/winbindd/winbindd_ads.c @@ -153,7 +153,7 @@ static ADS_STRUCT *ads_cached_connection(struct winbindd_domain *domain) static NTSTATUS query_user_list(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, uint32 *num_entries, - WINBIND_USERINFO **info) + struct wbint_userinfo **info) { ADS_STRUCT *ads = NULL; const char *attrs[] = { "*", NULL }; @@ -192,7 +192,7 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain, goto done; } - (*info) = TALLOC_ZERO_ARRAY(mem_ctx, WINBIND_USERINFO, count); + (*info) = TALLOC_ZERO_ARRAY(mem_ctx, struct wbint_userinfo, count); if (!*info) { status = NT_STATUS_NO_MEMORY; goto done; @@ -452,7 +452,7 @@ static NTSTATUS rids_to_names(struct winbindd_domain *domain, static NTSTATUS query_user(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, const DOM_SID *sid, - WINBIND_USERINFO *info) + struct wbint_userinfo *info) { ADS_STRUCT *ads = NULL; const char *attrs[] = { "*", NULL }; @@ -464,6 +464,7 @@ static NTSTATUS query_user(struct winbindd_domain *domain, uint32 group_rid; NTSTATUS status = NT_STATUS_UNSUCCESSFUL; struct netr_SamInfo3 *user = NULL; + gid_t gid; DEBUG(3,("ads: query_user\n")); @@ -475,7 +476,6 @@ static NTSTATUS query_user(struct winbindd_domain *domain, if ( (user = netsamlogon_cache_get( mem_ctx, sid )) != NULL ) { - DEBUG(5,("query_user: Cache lookup succeeded for %s\n", sid_string_dbg(sid))); @@ -487,7 +487,8 @@ static NTSTATUS query_user(struct winbindd_domain *domain, nss_get_info_cached( domain, sid, mem_ctx, NULL, NULL, &info->homedir, &info->shell, &info->full_name, - &info->primary_gid ); + &gid ); + info->primary_gid = gid; TALLOC_FREE(user); @@ -512,7 +513,8 @@ static NTSTATUS query_user(struct winbindd_domain *domain, nss_get_info_cached( domain, sid, mem_ctx, NULL, NULL, &info->homedir, &info->shell, &info->full_name, - &info->primary_gid ); + &gid); + info->primary_gid = gid; status = NT_STATUS_OK; goto done; @@ -550,7 +552,8 @@ static NTSTATUS query_user(struct winbindd_domain *domain, nss_get_info_cached( domain, sid, mem_ctx, ads, msg, &info->homedir, &info->shell, &info->full_name, - &info->primary_gid ); + &gid); + info->primary_gid = gid; if (info->full_name == NULL) { info->full_name = ads_pull_string(ads, mem_ctx, msg, "name"); diff --git a/source3/winbindd/winbindd_async.c b/source3/winbindd/winbindd_async.c index 094602160d..58080a8800 100644 --- a/source3/winbindd/winbindd_async.c +++ b/source3/winbindd/winbindd_async.c @@ -494,7 +494,7 @@ void winbindd_listent_async(TALLOC_CTX *mem_ctx, enum winbindd_result winbindd_dual_list_users(struct winbindd_domain *domain, struct winbindd_cli_state *state) { - WINBIND_USERINFO *info; + struct wbint_userinfo *info; NTSTATUS status; struct winbindd_methods *methods; uint32 num_entries = 0; diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index 5dfdc5ae29..3def0159a5 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -898,7 +898,8 @@ static void wcache_save_sid_to_name(struct winbindd_domain *domain, NTSTATUS sta } -static void wcache_save_user(struct winbindd_domain *domain, NTSTATUS status, WINBIND_USERINFO *info) +static void wcache_save_user(struct winbindd_domain *domain, NTSTATUS status, + struct wbint_userinfo *info) { struct cache_entry *centry; fstring sid_string; @@ -1334,7 +1335,7 @@ NTSTATUS wcache_save_creds(struct winbindd_domain *domain, static NTSTATUS query_user_list(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, uint32 *num_entries, - WINBIND_USERINFO **info) + struct wbint_userinfo **info) { struct winbind_cache *cache = get_cache(domain); struct cache_entry *centry = NULL; @@ -1353,7 +1354,7 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain, if (*num_entries == 0) goto do_cached; - (*info) = TALLOC_ARRAY(mem_ctx, WINBIND_USERINFO, *num_entries); + (*info) = TALLOC_ARRAY(mem_ctx, struct wbint_userinfo, *num_entries); if (! (*info)) { smb_panic_fn("query_user_list out of memory"); } @@ -1942,7 +1943,7 @@ static NTSTATUS rids_to_names(struct winbindd_domain *domain, NTSTATUS wcache_query_user(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, const struct dom_sid *user_sid, - struct winbind_userinfo *info) + struct wbint_userinfo *info) { struct winbind_cache *cache = get_cache(domain); struct cache_entry *centry = NULL; @@ -2003,7 +2004,7 @@ NTSTATUS wcache_query_user(struct winbindd_domain *domain, static NTSTATUS query_user(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, const DOM_SID *user_sid, - WINBIND_USERINFO *info) + struct wbint_userinfo *info) { NTSTATUS status; diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c index 23d3de13a7..4771f424b7 100644 --- a/source3/winbindd/winbindd_dual_srv.c +++ b/source3/winbindd/winbindd_dual_srv.c @@ -109,28 +109,13 @@ NTSTATUS _wbint_Gid2Sid(pipes_struct *p, struct wbint_Gid2Sid *r) NTSTATUS _wbint_QueryUser(pipes_struct *p, struct wbint_QueryUser *r) { struct winbindd_domain *domain = wb_child_domain(); - WINBIND_USERINFO uinfo; - NTSTATUS status; if (domain == NULL) { return NT_STATUS_REQUEST_NOT_ACCEPTED; } - status = domain->methods->query_user(domain, p->mem_ctx, r->in.sid, - &uinfo); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - r->out.info->acct_name = uinfo.acct_name; - r->out.info->full_name = uinfo.full_name; - r->out.info->homedir = uinfo.homedir; - r->out.info->shell = uinfo.shell; - r->out.info->primary_gid = uinfo.primary_gid; - sid_copy(&r->out.info->user_sid, &uinfo.user_sid); - sid_copy(&r->out.info->group_sid, &uinfo.group_sid); - - return NT_STATUS_OK; + return domain->methods->query_user(domain, p->mem_ctx, r->in.sid, + r->out.info); } NTSTATUS _wbint_LookupUserAliases(pipes_struct *p, diff --git a/source3/winbindd/winbindd_passdb.c b/source3/winbindd/winbindd_passdb.c index b6e572d197..4b3095ac83 100644 --- a/source3/winbindd/winbindd_passdb.c +++ b/source3/winbindd/winbindd_passdb.c @@ -379,7 +379,7 @@ static NTSTATUS builtin_enum_dom_groups(struct winbindd_domain *domain, static NTSTATUS builtin_query_user_list(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, uint32 *num_entries, - WINBIND_USERINFO **info) + struct wbint_userinfo **info) { /* We don't have users */ *num_entries = 0; @@ -391,7 +391,7 @@ static NTSTATUS builtin_query_user_list(struct winbindd_domain *domain, static NTSTATUS builtin_query_user(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, const DOM_SID *user_sid, - WINBIND_USERINFO *user_info) + struct wbint_userinfo *user_info) { return NT_STATUS_NO_SUCH_USER; } @@ -447,7 +447,7 @@ static NTSTATUS sam_enum_dom_groups(struct winbindd_domain *domain, static NTSTATUS sam_query_user_list(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, uint32 *num_entries, - WINBIND_USERINFO **info) + struct wbint_userinfo **info) { struct pdb_search *ps = pdb_search_users(talloc_tos(), ACB_NORMAL); struct samr_displayentry *entries = NULL; @@ -464,7 +464,7 @@ static NTSTATUS sam_query_user_list(struct winbindd_domain *domain, 1, 0xffffffff, &entries); - *info = TALLOC_ZERO_ARRAY(mem_ctx, WINBIND_USERINFO, *num_entries); + *info = TALLOC_ZERO_ARRAY(mem_ctx, struct wbint_userinfo, *num_entries); if (!(*info)) { TALLOC_FREE(ps); return NT_STATUS_NO_MEMORY; @@ -499,7 +499,7 @@ static NTSTATUS sam_query_user_list(struct winbindd_domain *domain, static NTSTATUS sam_query_user(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, const DOM_SID *user_sid, - WINBIND_USERINFO *user_info) + struct wbint_userinfo *user_info) { struct samu *sampass = NULL; diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h index a9a374a532..c9ef5e14ea 100644 --- a/source3/winbindd/winbindd_proto.h +++ b/source3/winbindd/winbindd_proto.h @@ -174,7 +174,7 @@ NTSTATUS wcache_name_to_sid(struct winbindd_domain *domain, NTSTATUS wcache_query_user(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, const struct dom_sid *user_sid, - struct winbind_userinfo *info); + struct wbint_userinfo *info); NTSTATUS wcache_lookup_useraliases(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, uint32 num_sids, const DOM_SID *sids, @@ -707,7 +707,7 @@ struct tevent_req *wb_queryuser_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, const struct dom_sid *user_sid); NTSTATUS wb_queryuser_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, - struct winbind_userinfo **pinfo); + struct wbint_userinfo **pinfo); struct tevent_req *wb_getpwsid_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, diff --git a/source3/winbindd/winbindd_reconnect.c b/source3/winbindd/winbindd_reconnect.c index 1d71a75458..aa2f6670f6 100644 --- a/source3/winbindd/winbindd_reconnect.c +++ b/source3/winbindd/winbindd_reconnect.c @@ -31,7 +31,7 @@ extern struct winbindd_methods msrpc_methods; static NTSTATUS query_user_list(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, uint32 *num_entries, - WINBIND_USERINFO **info) + struct wbint_userinfo **info) { NTSTATUS result; @@ -152,7 +152,7 @@ static NTSTATUS rids_to_names(struct winbindd_domain *domain, static NTSTATUS query_user(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, const DOM_SID *user_sid, - WINBIND_USERINFO *user_info) + struct wbint_userinfo *user_info) { NTSTATUS result; diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c index 3aa4231506..9d84612646 100644 --- a/source3/winbindd/winbindd_rpc.c +++ b/source3/winbindd/winbindd_rpc.c @@ -35,7 +35,7 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, uint32 *num_entries, - WINBIND_USERINFO **info) + struct wbint_userinfo **info) { NTSTATUS result; struct policy_handle dom_pol; @@ -88,7 +88,8 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain, *num_entries += num_dom_users; - *info = TALLOC_REALLOC_ARRAY(mem_ctx, *info, WINBIND_USERINFO, + *info = TALLOC_REALLOC_ARRAY(mem_ctx, *info, + struct wbint_userinfo, *num_entries); if (!(*info)) { @@ -493,7 +494,7 @@ static NTSTATUS msrpc_rids_to_names(struct winbindd_domain *domain, static NTSTATUS query_user(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, const DOM_SID *user_sid, - WINBIND_USERINFO *user_info) + struct wbint_userinfo *user_info) { NTSTATUS result = NT_STATUS_UNSUCCESSFUL; struct policy_handle dom_pol, user_pol; diff --git a/source3/winbindd/winbindd_user.c b/source3/winbindd/winbindd_user.c index 240b0f524f..10fb1671bd 100644 --- a/source3/winbindd/winbindd_user.c +++ b/source3/winbindd/winbindd_user.c @@ -156,7 +156,7 @@ enum winbindd_result winbindd_dual_userinfo(struct winbindd_domain *domain, struct winbindd_cli_state *state) { DOM_SID sid; - WINBIND_USERINFO user_info; + struct wbint_userinfo user_info; NTSTATUS status; /* Ensure null termination */ @@ -285,7 +285,7 @@ static bool get_sam_user_entries(struct getent_state *ent, TALLOC_CTX *mem_ctx) { NTSTATUS status; uint32 num_entries; - WINBIND_USERINFO *info; + struct wbint_userinfo *info; struct getpwent_user *name_list = NULL; struct winbindd_domain *domain; struct winbindd_methods *methods; -- cgit