diff options
author | Gerald Carter <jerry@samba.org> | 2006-02-20 20:09:36 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:10:15 -0500 |
commit | 2203bed32c84c63737f402accf73452efb76b483 (patch) | |
tree | 76259a35b1137cfa89547b80b2b93eb0eedf5bcf /source3/auth/auth_util.c | |
parent | 69b2669b559c009d17f621cbc7c6937eafc56af6 (diff) | |
download | samba-2203bed32c84c63737f402accf73452efb76b483.tar.gz samba-2203bed32c84c63737f402accf73452efb76b483.tar.bz2 samba-2203bed32c84c63737f402accf73452efb76b483.zip |
r13576: This is the beginnings of moving the SAM_ACCOUNT data structure
to make full use of the new talloc() interface. Discussed with Volker
and Jeremy.
* remove the internal mem_ctx and simply use the talloc()
structure as the context.
* replace the internal free_fn() with a talloc_destructor() function
* remove the unnecessary private nested structure
* rename SAM_ACCOUNT to 'struct samu' to indicate the current an
upcoming changes. Groups will most likely be replaced with a
'struct samg' in the future.
Note that there are now passbd API changes. And for the most
part, the wrapper functions remain the same.
While this code has been tested on tdb and ldap based Samba PDC's
as well as Samba member servers, there are probably still
some bugs. The code also needs more testing under valgrind to
ensure it's not leaking memory.
But it's a start......
(This used to be commit 19b7593972480540283c5bf02c02e5ecd8d2c3f0)
Diffstat (limited to 'source3/auth/auth_util.c')
-rw-r--r-- | source3/auth/auth_util.c | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c index 3e7c520fc5..7e6ab021b4 100644 --- a/source3/auth/auth_util.c +++ b/source3/auth/auth_util.c @@ -514,7 +514,7 @@ static int server_info_dtor(void *p) talloc_get_type_abort(p, auth_serversupplied_info); if (server_info->sam_account != NULL) { - pdb_free_sam(&server_info->sam_account); + TALLOC_FREE(server_info->sam_account); } ZERO_STRUCTP(server_info); @@ -547,11 +547,11 @@ static auth_serversupplied_info *make_server_info(TALLOC_CTX *mem_ctx) } /*************************************************************************** - Make (and fill) a user_info struct from a SAM_ACCOUNT + Make (and fill) a user_info struct from a struct samu ***************************************************************************/ NTSTATUS make_server_info_sam(auth_serversupplied_info **server_info, - SAM_ACCOUNT *sampass) + struct samu *sampass) { NTSTATUS status; struct passwd *pwd; @@ -949,7 +949,7 @@ NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username, /* This is a passdb user, so ask passdb */ - SAM_ACCOUNT *sam_acct = NULL; + struct samu *sam_acct = NULL; result = pdb_init_sam_talloc(tmp_ctx, &sam_acct); if (!NT_STATUS_IS_OK(result)) { @@ -1086,7 +1086,7 @@ BOOL user_in_group(const char *username, const char *groupname) /*************************************************************************** Make (and fill) a user_info struct from a Kerberos PAC logon_info by - conversion to a SAM_ACCOUNT + conversion to a struct samu ***************************************************************************/ NTSTATUS make_server_info_pac(auth_serversupplied_info **server_info, @@ -1095,7 +1095,7 @@ NTSTATUS make_server_info_pac(auth_serversupplied_info **server_info, PAC_LOGON_INFO *logon_info) { NTSTATUS status; - SAM_ACCOUNT *sampass = NULL; + struct samu *sampass = NULL; DOM_SID user_sid, group_sid; fstring dom_name; auth_serversupplied_info *result; @@ -1108,7 +1108,7 @@ NTSTATUS make_server_info_pac(auth_serversupplied_info **server_info, result = make_server_info(NULL); if (result == NULL) { - pdb_free_sam(&sampass); + TALLOC_FREE(sampass); return NT_STATUS_NO_MEMORY; } @@ -1145,7 +1145,7 @@ NTSTATUS make_server_info_pac(auth_serversupplied_info **server_info, /*************************************************************************** Make (and fill) a user_info struct from a 'struct passwd' by conversion - to a SAM_ACCOUNT + to a struct samu ***************************************************************************/ NTSTATUS make_server_info_pw(auth_serversupplied_info **server_info, @@ -1153,7 +1153,7 @@ NTSTATUS make_server_info_pw(auth_serversupplied_info **server_info, struct passwd *pwd) { NTSTATUS status; - SAM_ACCOUNT *sampass = NULL; + struct samu *sampass = NULL; gid_t *gids; auth_serversupplied_info *result; @@ -1166,7 +1166,7 @@ NTSTATUS make_server_info_pw(auth_serversupplied_info **server_info, result = make_server_info(NULL); if (!NT_STATUS_IS_OK(status)) { - pdb_free_sam(&sampass); + TALLOC_FREE(sampass); return status; } @@ -1206,7 +1206,7 @@ NTSTATUS make_server_info_pw(auth_serversupplied_info **server_info, static NTSTATUS make_new_server_info_guest(auth_serversupplied_info **server_info) { NTSTATUS status; - SAM_ACCOUNT *sampass = NULL; + struct samu *sampass = NULL; DOM_SID guest_sid; BOOL ret; static const char zeros[16]; @@ -1225,13 +1225,13 @@ static NTSTATUS make_new_server_info_guest(auth_serversupplied_info **server_inf unbecome_root(); if (!ret) { - pdb_free_sam(&sampass); + TALLOC_FREE(sampass); return NT_STATUS_NO_SUCH_USER; } status = make_server_info_sam(server_info, sampass); if (!NT_STATUS_IS_OK(status)) { - pdb_free_sam(&sampass); + TALLOC_FREE(sampass); return status; } @@ -1311,7 +1311,7 @@ static NTSTATUS fill_sam_account(TALLOC_CTX *mem_ctx, const char *username, char **found_username, uid_t *uid, gid_t *gid, - SAM_ACCOUNT **sam_account) + struct samu **sam_account) { NTSTATUS nt_status; fstring dom_user, lower_username; @@ -1453,7 +1453,7 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, const char *nt_domain; const char *nt_username; - SAM_ACCOUNT *sam_account = NULL; + struct samu *sam_account = NULL; DOM_SID user_sid; DOM_SID group_sid; @@ -1532,74 +1532,74 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, } if (!pdb_set_nt_username(sam_account, nt_username, PDB_CHANGED)) { - pdb_free_sam(&sam_account); + TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; } if (!pdb_set_username(sam_account, nt_username, PDB_CHANGED)) { - pdb_free_sam(&sam_account); + TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; } if (!pdb_set_domain(sam_account, nt_domain, PDB_CHANGED)) { - pdb_free_sam(&sam_account); + TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; } if (!pdb_set_user_sid(sam_account, &user_sid, PDB_CHANGED)) { - pdb_free_sam(&sam_account); + TALLOC_FREE(sam_account); return NT_STATUS_UNSUCCESSFUL; } if (!pdb_set_group_sid(sam_account, &group_sid, PDB_CHANGED)) { - pdb_free_sam(&sam_account); + TALLOC_FREE(sam_account); return NT_STATUS_UNSUCCESSFUL; } if (!pdb_set_fullname(sam_account, unistr2_static(&(info3->uni_full_name)), PDB_CHANGED)) { - pdb_free_sam(&sam_account); + TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; } if (!pdb_set_logon_script(sam_account, unistr2_static(&(info3->uni_logon_script)), PDB_CHANGED)) { - pdb_free_sam(&sam_account); + TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; } if (!pdb_set_profile_path(sam_account, unistr2_static(&(info3->uni_profile_path)), PDB_CHANGED)) { - pdb_free_sam(&sam_account); + TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; } if (!pdb_set_homedir(sam_account, unistr2_static(&(info3->uni_home_dir)), PDB_CHANGED)) { - pdb_free_sam(&sam_account); + TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; } if (!pdb_set_dir_drive(sam_account, unistr2_static(&(info3->uni_dir_drive)), PDB_CHANGED)) { - pdb_free_sam(&sam_account); + TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; } result = make_server_info(NULL); if (result == NULL) { DEBUG(4, ("make_server_info failed!\n")); - pdb_free_sam(&sam_account); + TALLOC_FREE(sam_account); return NT_STATUS_NO_MEMORY; } /* save this here to _net_sam_logon() doesn't fail (it assumes a - valid SAM_ACCOUNT) */ + valid struct samu) */ result->sam_account = sam_account; result->unix_name = talloc_strdup(result, found_username); |