s3:winbind: WINBIND_USERINFO -> wbint_userinfo
authorVolker Lendecke <vl@samba.org>
Sun, 9 Aug 2009 11:31:31 +0000 (07:31 -0400)
committerVolker Lendecke <vl@samba.org>
Sun, 16 Aug 2009 08:38:24 +0000 (10:38 +0200)
12 files changed:
source3/winbindd/wb_getpwsid.c
source3/winbindd/wb_queryuser.c
source3/winbindd/winbindd.h
source3/winbindd/winbindd_ads.c
source3/winbindd/winbindd_async.c
source3/winbindd/winbindd_cache.c
source3/winbindd/winbindd_dual_srv.c
source3/winbindd/winbindd_passdb.c
source3/winbindd/winbindd_proto.h
source3/winbindd/winbindd_reconnect.c
source3/winbindd/winbindd_rpc.c
source3/winbindd/winbindd_user.c

index fc696cb9a1884069547ab1e526f4116fa26e6484..1295d5bcbc6355bdf3fdbe951eda29c44fe34bc9 100644 (file)
@@ -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;
 };
 
index 27b8d299512fda88d5589b91500dfe0bd620beee..1af44000fe387f63ef09fb09e66eb09bb87d73db 100644 (file)
@@ -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;
 }
index baab7fd11a37a741d8da3ddce727b9cebd670767..44ac0227207f64fe36c7d01647abb08cf5a3597f 100644 (file)
@@ -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 <libnscd.h>
@@ -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
index 665dd53df1bfdf53c4e3af18669ec6d0a5ef68c2..a9df61d5f442c52a81c95e5e15c465c3ff860a01 100644 (file)
@@ -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");
index 094602160d96bc5cf9d9c4ab01fc478fa0a6482e..58080a8800eade0cdbe34194ab46876034497bae 100644 (file)
@@ -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;
index 5dfdc5ae29cbbbca768142419da173221e2eb4a2..3def0159a59f69c3a71571cf1f4071cd31a1e088 100644 (file)
@@ -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;
 
index 23d3de13a7850e6816a3408b72add41538d3160b..4771f424b7037ed13bc9ef3270843aaf33142f2c 100644 (file)
@@ -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,
index b6e572d19714844f08f4f45aeec40875c6ad641a..4b3095ac83ed838b2bd5b31d0da5bf98a940a45e 100644 (file)
@@ -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;
 
index a9a374a53288eeb2f4130cce6abe926b21e00231..c9ef5e14ead97d428593b9520723390d0e0cbedf 100644 (file)
@@ -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,
index 1d71a754586e4e3c9a48a567f9ee03715a53fc1f..aa2f6670f641b2f56917d170c90c021717541b12 100644 (file)
@@ -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;
 
index 3aa4231506334f75485002002cdb86ec6d712d72..9d84612646d5286ddf766d403168125d908e3782 100644 (file)
@@ -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;
index 240b0f524f619f1b7849f1b9b4915176a4acda01..10fb1671bdaf9fc844c17d1985154570cfc738bf 100644 (file)
@@ -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;