s3:libsmb: Convert (state->received) to (state->received != 0)
[ira/wip.git] / source3 / passdb / pdb_wbc_sam.c
index 33dc03fe4cd787a2620abce7cd2970f849a984de..df80411a7a284c190538497efaf3364f2056a18b 100644 (file)
@@ -81,22 +81,6 @@ static bool pdb_wbc_sam_gid_to_sid(struct pdb_methods *methods, gid_t gid,
        return winbind_gid_to_sid(sid, gid);
 }
 
-static bool pdb_wbc_sam_sid_to_id(struct pdb_methods *methods,
-                                 const DOM_SID *sid,
-                                 union unid_t *id, enum lsa_SidType *type)
-{
-       if (winbind_sid_to_uid(&id->uid, sid)) {
-               *type = SID_NAME_USER;
-       } else if (winbind_sid_to_gid(&id->gid, sid)) {
-               /* We assume all gids are groups, not aliases */
-               *type = SID_NAME_DOM_GRP;
-       } else {
-               return false;
-       }
-
-       return true;
-}
-
 static NTSTATUS pdb_wbc_sam_enum_group_members(struct pdb_methods *methods,
                                               TALLOC_CTX *mem_ctx,
                                               const DOM_SID *group,
@@ -115,10 +99,12 @@ static NTSTATUS pdb_wbc_sam_enum_group_memberships(struct pdb_methods *methods,
 {
        size_t i;
        const char *username = pdb_get_username(user);
+       uint32_t num_groups;
 
-       if (!winbind_get_groups(mem_ctx, username, p_num_groups, pp_gids)) {
+       if (!winbind_get_groups(mem_ctx, username, &num_groups, pp_gids)) {
                return NT_STATUS_NO_SUCH_USER;
        }
+       *p_num_groups = num_groups;
 
        if (*p_num_groups == 0) {
                smb_panic("primary group missing");
@@ -148,7 +134,6 @@ static NTSTATUS pdb_wbc_sam_lookup_rids(struct pdb_methods *methods,
        NTSTATUS result = NT_STATUS_OK;
        char *domain = NULL;
        char **account_names = NULL;
-       char name[256];
        enum lsa_SidType *attr_list = NULL;
        int i;
 
@@ -166,25 +151,28 @@ static NTSTATUS pdb_wbc_sam_lookup_rids(struct pdb_methods *methods,
                if (attrs[i] == SID_NAME_UNKNOWN) {
                        names[i] = NULL;
                } else {
-                       snprintf(name, sizeof(name), "%s%c%s", domain,
-                                *lp_winbind_separator(), account_names[i]);
-                       names[i] = talloc_strdup(names, name);
+                       names[i] = talloc_strdup(names, account_names[i]);
+                       if (names[i] == NULL) {
+                               result = NT_STATUS_NO_MEMORY;
+                               goto done;
+                       }
+
                }
        }
 
 done:
        TALLOC_FREE(account_names);
        TALLOC_FREE(domain);
-       TALLOC_FREE(attrs);
+       TALLOC_FREE(attr_list);
        return result;
 }
 
-static NTSTATUS pdb_wbc_sam_get_account_policy(struct pdb_methods *methods, int policy_index, uint32 *value)
+static NTSTATUS pdb_wbc_sam_get_account_policy(struct pdb_methods *methods, enum pdb_policy_type type, uint32_t *value)
 {
        return NT_STATUS_UNSUCCESSFUL;
 }
 
-static NTSTATUS pdb_wbc_sam_set_account_policy(struct pdb_methods *methods, int policy_index, uint32 value)
+static NTSTATUS pdb_wbc_sam_set_account_policy(struct pdb_methods *methods, enum pdb_policy_type type, uint32_t value)
 {
        return NT_STATUS_UNSUCCESSFUL;
 }
@@ -328,13 +316,12 @@ static NTSTATUS pdb_wbc_sam_getgrnam(struct pdb_methods *methods, GROUP_MAP *map
                                 const char *name)
 {
        NTSTATUS result = NT_STATUS_OK;
-       char *user_name = NULL;
-       char *domain = NULL;
+       const char *domain = "";
        DOM_SID sid;
        gid_t gid;
        enum lsa_SidType name_type;
 
-       if (!winbind_lookup_name(domain, user_name, &sid, &name_type)) {
+       if (!winbind_lookup_name(domain, name, &sid, &name_type)) {
                result = NT_STATUS_NO_SUCH_GROUP;
                goto done;
        }
@@ -352,7 +339,7 @@ static NTSTATUS pdb_wbc_sam_getgrnam(struct pdb_methods *methods, GROUP_MAP *map
                goto done;
        }
 
-       if (!_make_group_map(methods, domain, user_name, name_type, gid, &sid, map)) {
+       if (!_make_group_map(methods, domain, name, name_type, gid, &sid, map)) {
                result = NT_STATUS_NO_SUCH_GROUP;
                goto done;
        }
@@ -378,8 +365,10 @@ static NTSTATUS pdb_wbc_sam_get_aliasinfo(struct pdb_methods *methods,
 }
 
 static NTSTATUS pdb_wbc_sam_enum_aliasmem(struct pdb_methods *methods,
-                                  const DOM_SID *alias, DOM_SID **pp_members,
-                                  size_t *p_num_members)
+                                         const DOM_SID *alias,
+                                         TALLOC_CTX *mem_ctx,
+                                         DOM_SID **pp_members,
+                                         size_t *p_num_members)
 {
        return NT_STATUS_NOT_IMPLEMENTED;
 }
@@ -426,7 +415,6 @@ static NTSTATUS pdb_init_wbc_sam(struct pdb_methods **pdb_method, const char *lo
        (*pdb_method)->set_account_policy = pdb_wbc_sam_set_account_policy;
        (*pdb_method)->uid_to_sid = pdb_wbc_sam_uid_to_sid;
        (*pdb_method)->gid_to_sid = pdb_wbc_sam_gid_to_sid;
-       (*pdb_method)->sid_to_id = pdb_wbc_sam_sid_to_id;
 
        (*pdb_method)->search_groups = pdb_wbc_sam_search_groups;
        (*pdb_method)->search_aliases = pdb_wbc_sam_search_aliases;