Fix some nonempty lines
[samba.git] / source3 / winbindd / winbindd_passdb.c
index 101854ae943d56417771016bd2afca4e0b56b0b9..89eda3c820c74b0ae41f39843f7e58b18a543b1c 100644 (file)
@@ -7,17 +7,17 @@
    Copyright (C) Simo Sorce 2003
    Copyright (C) Volker Lendecke 2004
    Copyright (C) Jeremy Allison 2008
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -40,9 +40,9 @@ static NTSTATUS enum_groups_internal(struct winbindd_domain *domain,
        NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
 
        if (sidtype == SID_NAME_ALIAS) {
-               search = pdb_search_aliases(&domain->sid);
+               search = pdb_search_aliases(talloc_tos(), &domain->sid);
        } else {
-               search = pdb_search_groups();
+               search = pdb_search_groups(talloc_tos());
        }
 
        if (search == NULL) goto done;
@@ -68,7 +68,7 @@ static NTSTATUS enum_groups_internal(struct winbindd_domain *domain,
 
        result = NT_STATUS_OK;
  done:
-       pdb_search_destroy(search);
+       TALLOC_FREE(search);
        return result;
 }
 
@@ -107,7 +107,7 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
                DEBUG(10,("winbindd_passdb: limiting name_to_sid() to explicit mappings\n"));
                break;
        }
-       
+
        if (domain_name && domain_name[0] && strchr_m(name, '\\') == NULL) {
                fullname = talloc_asprintf(mem_ctx, "%s\\%s",
                                domain_name, name);
@@ -128,7 +128,7 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
                fullname,
                sid_string_dbg(sid),
                sid_type_lookup((uint32)*type)));
-               
+
        return NT_STATUS_OK;
 }
 
@@ -324,49 +324,45 @@ static NTSTATUS password_policy(struct winbindd_domain *domain,
                                TALLOC_CTX *mem_ctx,
                                struct samr_DomInfo1 *policy)
 {
-       uint32 min_pass_len,pass_hist,password_properties;
+       struct samr_DomInfo1 *p;
        time_t u_expire, u_min_age;
-       NTTIME nt_expire, nt_min_age;
        uint32 account_policy_temp;
 
-       if ((policy = TALLOC_ZERO_P(mem_ctx, struct samr_DomInfo1)) == NULL) {
+       if ((p = TALLOC_ZERO_P(mem_ctx, struct samr_DomInfo1)) == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
 
-       if (!pdb_get_account_policy(AP_MIN_PASSWORD_LEN, &account_policy_temp)) {
+       if (!pdb_get_account_policy(PDB_POLICY_MIN_PASSWORD_LEN,
+                                   &account_policy_temp)) {
                return NT_STATUS_ACCESS_DENIED;
        }
-       min_pass_len = account_policy_temp;
+       p->min_password_length = account_policy_temp;
 
-       if (!pdb_get_account_policy(AP_PASSWORD_HISTORY, &account_policy_temp)) {
+       if (!pdb_get_account_policy(PDB_POLICY_PASSWORD_HISTORY,
+                                   &account_policy_temp)) {
                return NT_STATUS_ACCESS_DENIED;
        }
-       pass_hist = account_policy_temp;
+       p->password_history_length = account_policy_temp;
 
-       if (!pdb_get_account_policy(AP_USER_MUST_LOGON_TO_CHG_PASS, &account_policy_temp)) {
+       if (!pdb_get_account_policy(PDB_POLICY_USER_MUST_LOGON_TO_CHG_PASS,
+                                   &p->password_properties)) {
                return NT_STATUS_ACCESS_DENIED;
        }
-       password_properties = account_policy_temp;
-       
-       if (!pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &account_policy_temp)) {
+
+       if (!pdb_get_account_policy(PDB_POLICY_MAX_PASSWORD_AGE, &account_policy_temp)) {
                return NT_STATUS_ACCESS_DENIED;
        }
        u_expire = account_policy_temp;
 
-       if (!pdb_get_account_policy(AP_MIN_PASSWORD_AGE, &account_policy_temp)) {
+       if (!pdb_get_account_policy(PDB_POLICY_MIN_PASSWORD_AGE, &account_policy_temp)) {
                return NT_STATUS_ACCESS_DENIED;
        }
        u_min_age = account_policy_temp;
 
-       unix_to_nt_time_abs(&nt_expire, u_expire);
-       unix_to_nt_time_abs(&nt_min_age, u_min_age);
+       unix_to_nt_time_abs((NTTIME *)&p->max_password_age, u_expire);
+       unix_to_nt_time_abs((NTTIME *)&p->min_password_age, u_min_age);
 
-       init_samr_DomInfo1(policy,
-                          (uint16)min_pass_len,
-                          (uint16)pass_hist,
-                          password_properties,
-                          nt_expire,
-                          nt_min_age);
+       policy = p;
 
        return NT_STATUS_OK;
 }
@@ -416,6 +412,9 @@ static NTSTATUS builtin_lookup_groupmem(struct winbindd_domain *domain,
                                DOM_SID **sid_mem, char ***names,
                                uint32 **name_types)
 {
+       DEBUG(10,("passdb: lookup_groupmem (builtin) %s sid=%s\n", domain->name,
+                 sid_string_dbg(group_sid)));
+
        *num_names = 0;
        *sid_mem = NULL;
        *names = NULL;
@@ -460,7 +459,7 @@ static NTSTATUS sam_query_user_list(struct winbindd_domain *domain,
                                uint32 *num_entries,
                                WINBIND_USERINFO **info)
 {
-       struct pdb_search *ps = pdb_search_users(ACB_NORMAL);
+       struct pdb_search *ps = pdb_search_users(talloc_tos(), ACB_NORMAL);
        struct samr_displayentry *entries = NULL;
        uint32 i;
 
@@ -477,7 +476,7 @@ static NTSTATUS sam_query_user_list(struct winbindd_domain *domain,
 
        *info = TALLOC_ZERO_ARRAY(mem_ctx, WINBIND_USERINFO, *num_entries);
        if (!(*info)) {
-               pdb_search_destroy(ps);
+               TALLOC_FREE(ps);
                return NT_STATUS_NO_MEMORY;
        }
 
@@ -502,7 +501,7 @@ static NTSTATUS sam_query_user_list(struct winbindd_domain *domain,
                                DOMAIN_GROUP_RID_USERS);
        }
 
-       pdb_search_destroy(ps);
+       TALLOC_FREE(ps);
        return NT_STATUS_OK;
 }
 
@@ -575,6 +574,9 @@ static NTSTATUS sam_lookup_groupmem(struct winbindd_domain *domain,
        struct lsa_name_info *lsa_names;
        TALLOC_CTX *tmp_ctx;
 
+       DEBUG(10,("passdb: lookup_groupmem (sam) %s sid=%s\n", domain->name,
+                 sid_string_dbg(group_sid)));
+
        if (!sid_check_is_in_our_domain(group_sid)) {
                /* There's no groups, only aliases in BUILTIN */
                return NT_STATUS_NO_SUCH_GROUP;