summaryrefslogtreecommitdiff
path: root/source3/passdb/pdb_interface.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2006-02-24 21:36:40 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:10:23 -0500
commitd95e13e68f3c7ac517a45877b351849ef4a99b93 (patch)
tree392a8d4445623c60746e444e148b2a4e12ebeaba /source3/passdb/pdb_interface.c
parent2b0277a1d6df176a90f895b9d0582db384fcc6a8 (diff)
downloadsamba-d95e13e68f3c7ac517a45877b351849ef4a99b93.tar.gz
samba-d95e13e68f3c7ac517a45877b351849ef4a99b93.tar.bz2
samba-d95e13e68f3c7ac517a45877b351849ef4a99b93.zip
r13679: Commiting the rm_primary_group.patch posted on samba-technical
* ignore the primary group SID attribute from struct samu* * generate the primary group SID strictlky from the Unix primary group when dealing with passdb users * Fix memory leak in original patch caused by failing to free a talloc * * add wrapper around samu_set_unix() to prevent exposing the create BOOL to callers. Wrappers are samu_set_unix() and samu-allic_rid_unix() (This used to be commit bcf269e2ec6630b78d909010fabd3b69dd6dda84)
Diffstat (limited to 'source3/passdb/pdb_interface.c')
-rw-r--r--source3/passdb/pdb_interface.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index 294cd51348..2fa02cafd9 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -274,7 +274,9 @@ BOOL pdb_getsampwnam(struct samu *sam_acct, const char *username)
}
pdb_force_pw_initialization( sam_acct );
- pdb_copy_sam_account(sam_acct, &csamuser);
+
+ if ( (csamuser = samu_new( NULL )) != NULL )
+ pdb_copy_sam_account(csamuser, sam_acct);
return True;
}
@@ -294,12 +296,11 @@ BOOL guest_user_info( struct samu *user )
return False;
}
- result = samu_set_unix(user, pwd);
+ result = samu_set_unix(user, pwd );
TALLOC_FREE( pwd );
return NT_STATUS_IS_OK( result );
-
}
/**********************************************************************
@@ -327,7 +328,7 @@ BOOL pdb_getsampwsid(struct samu *sam_acct, const DOM_SID *sid)
/* check the cache first */
if ( csamuser && sid_equal(sid, pdb_get_user_sid(csamuser) ) )
- return pdb_copy_sam_account(csamuser, &sam_acct);
+ return pdb_copy_sam_account(sam_acct, csamuser);
return NT_STATUS_IS_OK(pdb->getsampwsid(pdb, sam_acct, sid));
}
@@ -338,8 +339,9 @@ static NTSTATUS pdb_default_create_user(struct pdb_methods *methods,
{
struct samu *sam_pass = NULL;
NTSTATUS status;
+ struct passwd *pwd;
- if (Get_Pwnam_alloc(tmp_ctx, name) == NULL) {
+ if ( !(pwd = Get_Pwnam_alloc(tmp_ctx, name)) ) {
pstring add_script;
int add_ret;
@@ -357,19 +359,21 @@ static NTSTATUS pdb_default_create_user(struct pdb_methods *methods,
all_string_sub(add_script, "%u", name, sizeof(add_script));
add_ret = smbrun(add_script,NULL);
- DEBUG(add_ret ? 0 : 3, ("_samr_create_user: Running the "
- "command `%s' gave %d\n",
+ DEBUG(add_ret ? 0 : 3, ("_samr_create_user: Running the command `%s' gave %d\n",
add_script, add_ret));
+ flush_pwnam_cache();
+
+ pwd = Get_Pwnam_alloc(tmp_ctx, name);
}
- /* implicit call to getpwnam() next. we have a valid SID coming out
- * of this call */
+ /* we have a valid SID coming out of this call */
- flush_pwnam_cache();
- status = pdb_init_sam_new(&sam_pass, name);
+ status = samu_alloc_rid_unix( sam_pass, pwd );
+
+ TALLOC_FREE( pwd );
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(3, ("pdb_init_sam_new failed: %s\n", nt_errstr(status)));
+ DEBUG(3, ("pdb_default_create_user: failed to create a new user structure: %s\n", nt_errstr(status)));
return status;
}
@@ -379,8 +383,7 @@ static NTSTATUS pdb_default_create_user(struct pdb_methods *methods,
return NT_STATUS_INTERNAL_ERROR;
}
- /* Disable the account on creation, it does not have a reasonable
- * password yet. */
+ /* Disable the account on creation, it does not have a reasonable password yet. */
acb_info |= ACB_DISABLED;