1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-04 08:23:50 +03:00

r13590: * replace all pdb_init_sam[_talloc]() calls with samu_new()

* replace all pdb_{init,fill}_sam_pw() calls with samu_set_unix()
This commit is contained in:
Gerald Carter
2006-02-21 14:34:11 +00:00
committed by Gerald (Jerry) Carter
parent 77332f0738
commit 6f1afa4acc
19 changed files with 198 additions and 237 deletions

View File

@@ -31,7 +31,7 @@
static NTSTATUS auth_get_sam_account(const char *user, struct samu **account) static NTSTATUS auth_get_sam_account(const char *user, struct samu **account)
{ {
BOOL pdb_ret; BOOL pdb_ret;
NTSTATUS nt_status; NTSTATUS nt_status = NT_STATUS_NO_SUCH_USER;
if ( !(*account = samu_new( NULL )) ) { if ( !(*account = samu_new( NULL )) ) {
return NT_STATUS_NO_MEMORY; return NT_STATUS_NO_MEMORY;
@@ -41,17 +41,18 @@ static NTSTATUS auth_get_sam_account(const char *user, struct samu **account)
pdb_ret = pdb_getsampwnam(*account, user); pdb_ret = pdb_getsampwnam(*account, user);
unbecome_root(); unbecome_root();
if (!pdb_ret) { if (!pdb_ret)
{
struct passwd *pass = Get_Pwnam(user); struct passwd *pass;
if (!pass)
return NT_STATUS_NO_SUCH_USER;
if (!NT_STATUS_IS_OK(nt_status = pdb_fill_sam_pw(*account, pass))) { if ( !(pass = Get_Pwnam( user )) ) {
return nt_status; return NT_STATUS_NO_SUCH_USER;
} }
nt_status = samu_set_unix( *account, pass );
} }
return NT_STATUS_OK;
return nt_status;
} }
/**************************************************************************** /****************************************************************************

View File

@@ -250,8 +250,9 @@ static NTSTATUS check_sam_security(const struct auth_context *auth_context,
/* Can't use the talloc version here, because the returned struct gets /* Can't use the talloc version here, because the returned struct gets
kept on the server_info */ kept on the server_info */
if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&sampass))) {
return nt_status; if ( !(sampass = samu_new( NULL )) ) {
return NT_STATUS_NO_MEMORY;
} }
/* get the account information */ /* get the account information */

View File

@@ -30,10 +30,12 @@
**/ **/
static BOOL update_smbpassword_file(const char *user, const char *password) static BOOL update_smbpassword_file(const char *user, const char *password)
{ {
struct samu *sampass = NULL; struct samu *sampass;
BOOL ret; BOOL ret;
pdb_init_sam(&sampass); if ( !(sampass = samu_new( NULL )) ) {
return False;
}
become_root(); become_root();
ret = pdb_getsampwnam(sampass, user); ret = pdb_getsampwnam(sampass, user);

View File

@@ -172,7 +172,7 @@ NTSTATUS make_user_info_map(auth_usersupplied_info **user_info,
and let the "passdb backend" handle unknown users. */ and let the "passdb backend" handle unknown users. */
if ( !is_trusted_domain(domain) && !strequal(domain, get_global_sam_name()) ) if ( !is_trusted_domain(domain) && !strequal(domain, get_global_sam_name()) )
domain = get_default_sam_name(); domain = my_sam_name();
/* we know that it is a trusted domain (and we are allowing them) or it is our domain */ /* we know that it is a trusted domain (and we are allowing them) or it is our domain */
@@ -492,7 +492,7 @@ NT_USER_TOKEN *get_root_nt_token( void )
if ( token ) if ( token )
return token; return token;
if ( !(pw = getpwnam( "root" )) ) { if ( !(pw = sys_getpwnam( "root" )) ) {
DEBUG(0,("get_root_nt_token: getpwnam\"root\") failed!\n")); DEBUG(0,("get_root_nt_token: getpwnam\"root\") failed!\n"));
return NULL; return NULL;
} }
@@ -951,8 +951,7 @@ NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
struct samu *sam_acct = NULL; struct samu *sam_acct = NULL;
result = pdb_init_sam_talloc(tmp_ctx, &sam_acct); if ( !(sam_acct = samu_new( tmp_ctx )) ) {
if (!NT_STATUS_IS_OK(result)) {
goto done; goto done;
} }
@@ -1100,9 +1099,12 @@ NTSTATUS make_server_info_pac(auth_serversupplied_info **server_info,
fstring dom_name; fstring dom_name;
auth_serversupplied_info *result; auth_serversupplied_info *result;
status = pdb_init_sam_pw(&sampass, pwd); if ( !(sampass = samu_new( NULL )) ) {
return NT_STATUS_NO_MEMORY;
if (!NT_STATUS_IS_OK(status)) { }
status = samu_set_unix( sampass, pwd );
if ( !NT_STATUS_IS_OK(status) ) {
return status; return status;
} }
@@ -1157,8 +1159,11 @@ NTSTATUS make_server_info_pw(auth_serversupplied_info **server_info,
gid_t *gids; gid_t *gids;
auth_serversupplied_info *result; auth_serversupplied_info *result;
status = pdb_init_sam_pw(&sampass, pwd); if ( !(sampass = samu_new( NULL )) ) {
return NT_STATUS_NO_MEMORY;
}
status = samu_set_unix( sampass, pwd );
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {
return status; return status;
} }
@@ -1211,10 +1216,8 @@ static NTSTATUS make_new_server_info_guest(auth_serversupplied_info **server_inf
BOOL ret; BOOL ret;
static const char zeros[16]; static const char zeros[16];
status = pdb_init_sam(&sampass); if ( !(sampass = samu_new( NULL )) ) {
return NT_STATUS_NO_MEMORY;
if (!NT_STATUS_IS_OK(status)) {
return status;
} }
sid_copy(&guest_sid, get_global_sam_sid()); sid_copy(&guest_sid, get_global_sam_sid());
@@ -1311,7 +1314,7 @@ static NTSTATUS fill_sam_account(TALLOC_CTX *mem_ctx,
const char *username, const char *username,
char **found_username, char **found_username,
uid_t *uid, gid_t *gid, uid_t *uid, gid_t *gid,
struct samu **sam_account) struct samu *account)
{ {
NTSTATUS nt_status; NTSTATUS nt_status;
fstring dom_user, lower_username; fstring dom_user, lower_username;
@@ -1345,11 +1348,12 @@ static NTSTATUS fill_sam_account(TALLOC_CTX *mem_ctx,
*found_username = talloc_strdup( mem_ctx, real_username ); *found_username = talloc_strdup( mem_ctx, real_username );
DEBUG(5,("fill_sam_account: located username was [%s]\n", DEBUG(5,("fill_sam_account: located username was [%s]\n", *found_username));
*found_username));
nt_status = pdb_init_sam_pw(sam_account, passwd); nt_status = samu_set_unix( account, passwd );
TALLOC_FREE(passwd); TALLOC_FREE(passwd);
return nt_status; return nt_status;
} }
@@ -1452,7 +1456,6 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx,
char *found_username; char *found_username;
const char *nt_domain; const char *nt_domain;
const char *nt_username; const char *nt_username;
struct samu *sam_account = NULL; struct samu *sam_account = NULL;
DOM_SID user_sid; DOM_SID user_sid;
DOM_SID group_sid; DOM_SID group_sid;
@@ -1504,30 +1507,30 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx,
that is how the current code is designed. Making the change here that is how the current code is designed. Making the change here
is the least disruptive place. -- jerry */ is the least disruptive place. -- jerry */
if ( !(sam_account = samu_new( NULL )) ) {
return NT_STATUS_NO_MEMORY;
}
nt_status = fill_sam_account(mem_ctx, nt_domain, sent_nt_username, nt_status = fill_sam_account(mem_ctx, nt_domain, sent_nt_username,
&found_username, &uid, &gid, &found_username, &uid, &gid, sam_account);
&sam_account);
if (NT_STATUS_EQUAL(nt_status, NT_STATUS_NO_SUCH_USER)) { if (NT_STATUS_EQUAL(nt_status, NT_STATUS_NO_SUCH_USER)) {
DEBUG(3,("User %s does not exist, trying to add it\n", DEBUG(3,("User %s does not exist, trying to add it\n",
internal_username)); internal_username));
smb_create_user( nt_domain, sent_nt_username, NULL); smb_create_user( nt_domain, sent_nt_username, NULL);
nt_status = fill_sam_account( mem_ctx, nt_domain, nt_status = fill_sam_account( mem_ctx, nt_domain, sent_nt_username,
sent_nt_username, &found_username, &uid, &gid, sam_account );
&found_username, &uid, &gid,
&sam_account );
} }
/* if we still don't have a valid unix account check for /* if we still don't have a valid unix account check for
'map to gues = bad uid' */ 'map to gues = bad uid' */
if (!NT_STATUS_IS_OK(nt_status)) { if (!NT_STATUS_IS_OK(nt_status)) {
TALLOC_FREE( sam_account );
if ( lp_map_to_guest() == MAP_TO_GUEST_ON_BAD_UID ) { if ( lp_map_to_guest() == MAP_TO_GUEST_ON_BAD_UID ) {
make_server_info_guest(server_info); make_server_info_guest(server_info);
return NT_STATUS_OK; return NT_STATUS_OK;
} }
DEBUG(0, ("make_server_info_info3: pdb_init_sam failed!\n"));
return nt_status; return nt_status;
} }

View File

@@ -79,10 +79,13 @@ int pam_sm_acct_mgmt( pam_handle_t *pamh, int flags,
} }
/* Get the user's record. */ /* Get the user's record. */
pdb_init_sam(&sampass);
pdb_getsampwnam(sampass, name );
if (!sampass) { if ( (sampass = samu_new( NULL )) != NULL ) {
pdb_getsampwnam(sampass, name );
}
/* check for lookup failure */
if ( !sampass || !strlen(pdb_get_username(sampass)) ) {
CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler); CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
return PAM_USER_UNKNOWN; return PAM_USER_UNKNOWN;
} }

View File

@@ -107,7 +107,7 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags,
AUTH_RETURN; AUTH_RETURN;
} }
pdb_init_sam(&sampass); sampass = samu_new( NULL );
found = pdb_getsampwnam( sampass, name ); found = pdb_getsampwnam( sampass, name );

View File

@@ -102,8 +102,6 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
char *pass_old; char *pass_old;
char *pass_new; char *pass_new;
NTSTATUS nt_status;
/* Samba initialization. */ /* Samba initialization. */
setup_logging( "pam_smbpass", False ); setup_logging( "pam_smbpass", False );
in_client = True; in_client = True;
@@ -137,9 +135,9 @@ int pam_sm_chauthtok(pam_handle_t *pamh, int flags,
} }
/* obtain user record */ /* obtain user record */
if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(&sampass))) { if ( !(sampass = samu_new( NULL )) ) {
CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler); CatchSignal(SIGPIPE, SIGNAL_CAST oldsig_handler);
return nt_status_to_pam(nt_status); return nt_status_to_pam(NT_STATUS_NO_MEMORY);
} }
if (!pdb_getsampwnam(sampass,user)) { if (!pdb_getsampwnam(sampass,user)) {

View File

@@ -3,7 +3,7 @@
Password and authentication handling Password and authentication handling
Copyright (C) Jeremy Allison 1996-2001 Copyright (C) Jeremy Allison 1996-2001
Copyright (C) Luke Kenneth Casson Leighton 1996-1998 Copyright (C) Luke Kenneth Casson Leighton 1996-1998
Copyright (C) Gerald (Jerry) Carter 2000-2001 Copyright (C) Gerald (Jerry) Carter 2000-2006
Copyright (C) Andrew Bartlett 2001-2002 Copyright (C) Andrew Bartlett 2001-2002
Copyright (C) Simo Sorce 2003 Copyright (C) Simo Sorce 2003
Copyright (C) Volker Lendecke 2006 Copyright (C) Volker Lendecke 2006
@@ -36,7 +36,7 @@
standalone box will map to WKS\user. standalone box will map to WKS\user.
******************************************************************/ ******************************************************************/
const char *get_default_sam_name(void) const char *my_sam_name(void)
{ {
/* standalone servers can only use the local netbios name */ /* standalone servers can only use the local netbios name */
if ( lp_server_role() == ROLE_STANDALONE ) if ( lp_server_role() == ROLE_STANDALONE )
@@ -51,7 +51,7 @@ const char *get_default_sam_name(void)
Fill the struct samu with default values. Fill the struct samu with default values.
***********************************************************/ ***********************************************************/
void pdb_fill_default_sam(struct samu *user) static void samu_init( struct samu *user )
{ {
/* no initial methods */ /* no initial methods */
user->methods = NULL; user->methods = NULL;
@@ -62,8 +62,8 @@ void pdb_fill_default_sam(struct samu *user)
user->logon_time = (time_t)0; user->logon_time = (time_t)0;
user->pass_last_set_time = (time_t)0; user->pass_last_set_time = (time_t)0;
user->pass_can_change_time = (time_t)0; user->pass_can_change_time = (time_t)0;
user->logoff_time = user->logoff_time = get_time_t_max();
user->kickoff_time = user->kickoff_time = get_time_t_max();
user->pass_must_change_time = get_time_t_max(); user->pass_must_change_time = get_time_t_max();
user->fields_present = 0x00ffffff; user->fields_present = 0x00ffffff;
user->logon_divs = 168; /* hours per week */ user->logon_divs = 168; /* hours per week */
@@ -115,16 +115,6 @@ static int samu_destroy(void *p)
return 0; return 0;
} }
/**********************************************************************
***********************************************************************/
BOOL samu_init( struct samu *user )
{
pdb_fill_default_sam( user );
return True;
}
/********************************************************************** /**********************************************************************
generate a new struct samuser generate a new struct samuser
***********************************************************************/ ***********************************************************************/
@@ -138,41 +128,13 @@ struct samu* samu_new( TALLOC_CTX *ctx )
return NULL; return NULL;
} }
if ( !samu_init( user ) ) { samu_init( user );
DEBUG(0,("samuser_new: initialization failed!\n"));
TALLOC_FREE( user );
return NULL;
}
talloc_set_destructor( user, samu_destroy ); talloc_set_destructor( user, samu_destroy );
return user; return user;
} }
/**********************************************************************
Allocates memory and initialises a struct sam_passwd on supplied mem_ctx.
***********************************************************************/
NTSTATUS pdb_init_sam_talloc(TALLOC_CTX *mem_ctx, struct samu **user)
{
if ( !*user )
return NT_STATUS_UNSUCCESSFUL;
*user = samu_new( mem_ctx );
return *user ? NT_STATUS_OK : NT_STATUS_NO_MEMORY;
}
/*************************************************************
Allocates memory and initialises a struct sam_passwd.
************************************************************/
NTSTATUS pdb_init_sam(struct samu **user)
{
*user = samu_new( NULL );
return *user ? NT_STATUS_OK : NT_STATUS_NO_MEMORY;
}
/************************************************************************** /**************************************************************************
* This function will take care of all the steps needed to correctly * This function will take care of all the steps needed to correctly
* allocate and set the user SID, please do use this function to create new * allocate and set the user SID, please do use this function to create new
@@ -252,21 +214,17 @@ static NTSTATUS pdb_set_sam_sids(struct samu *account_data, const struct passwd
Initialises a struct sam_passwd with sane values. Initialises a struct sam_passwd with sane values.
************************************************************/ ************************************************************/
NTSTATUS pdb_fill_sam_pw(struct samu *sam_account, const struct passwd *pwd) NTSTATUS samu_set_unix(struct samu *sam_account, const struct passwd *pwd)
{ {
NTSTATUS ret; NTSTATUS ret;
if (!pwd) { if ( !pwd ) {
return NT_STATUS_UNSUCCESSFUL; return NT_STATUS_NO_SUCH_USER;
} }
pdb_fill_default_sam(sam_account);
pdb_set_username(sam_account, pwd->pw_name, PDB_SET); pdb_set_username(sam_account, pwd->pw_name, PDB_SET);
pdb_set_fullname(sam_account, pwd->pw_gecos, PDB_SET); pdb_set_fullname(sam_account, pwd->pw_gecos, PDB_SET);
pdb_set_unix_homedir(sam_account, pwd->pw_dir, PDB_SET); pdb_set_unix_homedir(sam_account, pwd->pw_dir, PDB_SET);
pdb_set_domain (sam_account, get_global_sam_name(), PDB_DEFAULT); pdb_set_domain (sam_account, get_global_sam_name(), PDB_DEFAULT);
/* When we get a proper uid -> SID and SID -> uid allocation /* When we get a proper uid -> SID and SID -> uid allocation
@@ -280,7 +238,8 @@ NTSTATUS pdb_fill_sam_pw(struct samu *sam_account, const struct passwd *pwd)
*/ */
ret = pdb_set_sam_sids(sam_account, pwd); ret = pdb_set_sam_sids(sam_account, pwd);
if (!NT_STATUS_IS_OK(ret)) return ret; if (!NT_STATUS_IS_OK(ret))
return ret;
/* check if this is a user account or a machine account */ /* check if this is a user account or a machine account */
if (pwd->pw_name[strlen(pwd->pw_name)-1] != '$') if (pwd->pw_name[strlen(pwd->pw_name)-1] != '$')
@@ -325,38 +284,9 @@ NTSTATUS pdb_fill_sam_pw(struct samu *sam_account, const struct passwd *pwd)
return NT_STATUS_OK; return NT_STATUS_OK;
} }
/*************************************************************
Initialises a struct sam_passwd with sane values.
************************************************************/
NTSTATUS pdb_init_sam_pw(struct samu **new_sam_acct, const struct passwd *pwd)
{
NTSTATUS nt_status;
if (!pwd) {
new_sam_acct = NULL;
return NT_STATUS_INVALID_PARAMETER;
}
if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam(new_sam_acct))) {
new_sam_acct = NULL;
return nt_status;
}
if (!NT_STATUS_IS_OK(nt_status = pdb_fill_sam_pw(*new_sam_acct, pwd))) {
TALLOC_FREE(new_sam_acct);
new_sam_acct = NULL;
return nt_status;
}
return NT_STATUS_OK;
}
/************************************************************* /*************************************************************
Initialises a struct samu ready to add a new account, based Initialises a struct samu ready to add a new account, based
on the UNIX user. Pass in a RID if you have one on the UNIX user.
************************************************************/ ************************************************************/
NTSTATUS pdb_init_sam_new(struct samu **new_sam_acct, const char *username) NTSTATUS pdb_init_sam_new(struct samu **new_sam_acct, const char *username)
@@ -374,17 +304,21 @@ NTSTATUS pdb_init_sam_new(struct samu **new_sam_acct, const char *username)
return NT_STATUS_NO_MEMORY; return NT_STATUS_NO_MEMORY;
} }
pwd = Get_Pwnam_alloc(mem_ctx, username); if ( !(pwd = Get_Pwnam_alloc(mem_ctx, username)) ) {
if (pwd == NULL) {
DEBUG(10, ("Could not find user %s\n", username)); DEBUG(10, ("Could not find user %s\n", username));
result = NT_STATUS_NO_SUCH_USER; result = NT_STATUS_NO_SUCH_USER;
goto done; goto done;
} }
result = pdb_init_sam_pw(new_sam_acct, pwd); if ( !(*new_sam_acct = samu_new( NULL )) ) {
result = NT_STATUS_NO_MEMORY;
goto done;
}
result = samu_set_unix( *new_sam_acct, pwd );
if (!NT_STATUS_IS_OK(result)) { if (!NT_STATUS_IS_OK(result)) {
DEBUG(10, ("pdb_init_sam_pw failed: %s\n", nt_errstr(result))); DEBUG(10, ("samu_set_unix failed: %s\n", nt_errstr(result)));
goto done; goto done;
} }
@@ -792,7 +726,7 @@ BOOL lookup_global_sam_name(const char *user, int flags, uint32_t *rid,
struct samu *sam_account = NULL; struct samu *sam_account = NULL;
DOM_SID user_sid; DOM_SID user_sid;
if (!NT_STATUS_IS_OK(pdb_init_sam(&sam_account))) { if ( !(sam_account = samu_new( NULL )) ) {
return False; return False;
} }
@@ -862,7 +796,10 @@ NTSTATUS local_password_change(const char *user_name, int local_flags,
*msg_str = '\0'; *msg_str = '\0';
/* Get the smb passwd entry for this user */ /* Get the smb passwd entry for this user */
pdb_init_sam(&sam_pass);
if ( !(sam_pass = samu_new( NULL )) ) {
return NT_STATUS_NO_MEMORY;
}
become_root(); become_root();
if(!pdb_getsampwnam(sam_pass, user_name)) { if(!pdb_getsampwnam(sam_pass, user_name)) {
@@ -880,8 +817,7 @@ NTSTATUS local_password_change(const char *user_name, int local_flags,
result = pdb_init_sam_new(&sam_pass, user_name); result = pdb_init_sam_new(&sam_pass, user_name);
DEBUGLEVEL = tmp_debug; DEBUGLEVEL = tmp_debug;
if (NT_STATUS_EQUAL(result, if (NT_STATUS_EQUAL(result, NT_STATUS_INVALID_PRIMARY_GROUP)) {
NT_STATUS_INVALID_PRIMARY_GROUP)) {
return result; return result;
} }
@@ -1912,7 +1848,7 @@ BOOL pdb_copy_sam_account(const struct samu *src, struct samu **dst)
uint8 *buf; uint8 *buf;
int len; int len;
if ((*dst == NULL) && (!NT_STATUS_IS_OK(pdb_init_sam(dst)))) if ( !*dst && !(*dst = samu_new(NULL)) )
return False; return False;
len = init_buffer_from_sam_v2(&buf, src, False); len = init_buffer_from_sam_v2(&buf, src, False);

View File

@@ -285,7 +285,7 @@ BOOL pdb_getsampwnam(struct samu *sam_acct, const char *username)
BOOL guest_user_info( struct samu *user ) BOOL guest_user_info( struct samu *user )
{ {
struct passwd *pwd; struct passwd *pwd;
NTSTATUS ntstatus; NTSTATUS result;
const char *guestname = lp_guestaccount(); const char *guestname = lp_guestaccount();
if ( !(pwd = getpwnam_alloc( NULL, guestname ) ) ) { if ( !(pwd = getpwnam_alloc( NULL, guestname ) ) ) {
@@ -294,11 +294,11 @@ BOOL guest_user_info( struct samu *user )
return False; return False;
} }
/* fill in from the users information */ result = samu_set_unix(user, pwd);
ntstatus = pdb_fill_sam_pw( user, pwd ); TALLOC_FREE( pwd );
return NT_STATUS_IS_OK(ntstatus); return NT_STATUS_IS_OK( result );
} }
@@ -816,7 +816,6 @@ static NTSTATUS pdb_default_add_groupmem(struct pdb_methods *methods,
struct passwd *pwd; struct passwd *pwd;
const char *group_name; const char *group_name;
uid_t uid; uid_t uid;
NTSTATUS status;
sid_compose(&group_sid, get_global_sam_sid(), group_rid); sid_compose(&group_sid, get_global_sam_sid(), group_rid);
sid_compose(&member_sid, get_global_sam_sid(), member_rid); sid_compose(&member_sid, get_global_sam_sid(), member_rid);
@@ -832,8 +831,8 @@ static NTSTATUS pdb_default_add_groupmem(struct pdb_methods *methods,
return NT_STATUS_NO_MEMORY; return NT_STATUS_NO_MEMORY;
} }
if (!NT_STATUS_IS_OK(status = pdb_init_sam(&account))) { if ( !(account = samu_new( NULL )) ) {
return status; return NT_STATUS_NO_MEMORY;
} }
if (!pdb_getsampwsid(account, &member_sid) || if (!pdb_getsampwsid(account, &member_sid) ||
@@ -884,7 +883,6 @@ static NTSTATUS pdb_default_del_groupmem(struct pdb_methods *methods,
struct passwd *pwd; struct passwd *pwd;
const char *group_name; const char *group_name;
uid_t uid; uid_t uid;
NTSTATUS status;
sid_compose(&group_sid, get_global_sam_sid(), group_rid); sid_compose(&group_sid, get_global_sam_sid(), group_rid);
sid_compose(&member_sid, get_global_sam_sid(), member_rid); sid_compose(&member_sid, get_global_sam_sid(), member_rid);
@@ -900,8 +898,8 @@ static NTSTATUS pdb_default_del_groupmem(struct pdb_methods *methods,
return NT_STATUS_NO_MEMORY; return NT_STATUS_NO_MEMORY;
} }
if (!NT_STATUS_IS_OK(status = pdb_init_sam(&account))) { if ( !(account = samu_new( NULL )) ) {
return status; return NT_STATUS_NO_MEMORY;
} }
if (!pdb_getsampwsid(account, &member_sid) || if (!pdb_getsampwsid(account, &member_sid) ||
@@ -1288,12 +1286,11 @@ static BOOL pdb_default_uid_to_rid(struct pdb_methods *methods, uid_t uid,
return False; return False;
} }
if ( !NT_STATUS_IS_OK(pdb_init_sam(&sampw)) ) { if ( !(sampw = samu_new( NULL )) ) {
DEBUG(0,("pdb_default_uid_to_rid: failed to allocate " DEBUG(0,("pdb_default_uid_to_rid: samu_new() failed!\n"));
"struct samu object\n"));
return False; return False;
} }
become_root(); become_root();
ret = NT_STATUS_IS_OK( ret = NT_STATUS_IS_OK(
methods->getsampwnam(methods, sampw, unix_pw->pw_name )); methods->getsampwnam(methods, sampw, unix_pw->pw_name ));
@@ -1565,7 +1562,8 @@ static BOOL lookup_global_sam_rid(TALLOC_CTX *mem_ctx, uint32 rid,
sid_append_rid(&sid, rid); sid_append_rid(&sid, rid);
/* see if the passdb can help us with the name of the user */ /* see if the passdb can help us with the name of the user */
if (!NT_STATUS_IS_OK(pdb_init_sam(&sam_account))) {
if ( !(sam_account = samu_new( NULL )) ) {
return False; return False;
} }
@@ -1813,12 +1811,10 @@ static BOOL next_entry_users(struct pdb_search *s,
{ {
struct user_search *state = s->private_data; struct user_search *state = s->private_data;
struct samu *user = NULL; struct samu *user = NULL;
NTSTATUS status;
next: next:
status = pdb_init_sam(&user); if ( !(user = samu_new( NULL )) ) {
if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("next_entry_users: samu_new() failed!\n"));
DEBUG(0, ("Could not pdb_init_sam\n"));
return False; return False;
} }

View File

@@ -1190,7 +1190,7 @@ static BOOL build_sam_account(struct smbpasswd_privates *smbpasswd_state,
{ {
struct passwd *pwfile; struct passwd *pwfile;
if (sam_pass==NULL) { if ( !sam_pass ) {
DEBUG(5,("build_sam_account: struct samu is NULL\n")); DEBUG(5,("build_sam_account: struct samu is NULL\n"));
return False; return False;
} }
@@ -1203,7 +1203,7 @@ static BOOL build_sam_account(struct smbpasswd_privates *smbpasswd_state,
return False; return False;
} }
if (!NT_STATUS_IS_OK(pdb_fill_sam_pw(sam_pass, pwfile))) if ( !NT_STATUS_IS_OK( samu_set_unix(sam_pass, pwfile)) )
return False; return False;
TALLOC_FREE(pwfile); TALLOC_FREE(pwfile);
@@ -1269,13 +1269,11 @@ static NTSTATUS smbpasswd_getsampwent(struct pdb_methods *my_methods, struct sam
struct smbpasswd_privates *smbpasswd_state = (struct smbpasswd_privates*)my_methods->private_data; struct smbpasswd_privates *smbpasswd_state = (struct smbpasswd_privates*)my_methods->private_data;
struct smb_passwd *pw_buf=NULL; struct smb_passwd *pw_buf=NULL;
BOOL done = False; BOOL done = False;
DEBUG(5,("pdb_getsampwent\n")); DEBUG(5,("pdb_getsampwent\n"));
if (user==NULL) { if ( !user ) {
DEBUG(5,("pdb_getsampwent (smbpasswd): user is NULL\n")); DEBUG(5,("pdb_getsampwent (smbpasswd): user is NULL\n"));
#if 0
smb_panic("NULL pointer passed to getsampwent (smbpasswd)\n");
#endif
return nt_status; return nt_status;
} }
@@ -1338,9 +1336,6 @@ static NTSTATUS smbpasswd_getsampwnam(struct pdb_methods *my_methods,
if (!sam_acct) { if (!sam_acct) {
DEBUG(10,("getsampwnam (smbpasswd): struct samu is NULL\n")); DEBUG(10,("getsampwnam (smbpasswd): struct samu is NULL\n"));
#if 0
smb_panic("NULL pointer passed to pdb_getsampwnam\n");
#endif
return nt_status; return nt_status;
} }
@@ -1398,9 +1393,6 @@ static NTSTATUS smbpasswd_getsampwsid(struct pdb_methods *my_methods, struct sam
if (!sam_acct) { if (!sam_acct) {
DEBUG(10,("getsampwrid: (smbpasswd) struct samu is NULL\n")); DEBUG(10,("getsampwrid: (smbpasswd) struct samu is NULL\n"));
#if 0
smb_panic("NULL pointer passed to pdb_getsampwrid\n");
#endif
return nt_status; return nt_status;
} }

View File

@@ -101,7 +101,11 @@ static BOOL tdbsam_convert(int32 from)
} }
/* unpack the buffer from the former format */ /* unpack the buffer from the former format */
pdb_init_sam( &user ); if ( !(user = samu_new( NULL )) ) {
DEBUG(0,("tdbsam_convert: samu_new() failed!\n"));
SAFE_FREE( data.dptr );
return False;
}
DEBUG(10,("tdbsam_convert: Try unpacking a record with (key:%s) (version:%d)\n", key.dptr, from)); DEBUG(10,("tdbsam_convert: Try unpacking a record with (key:%s) (version:%d)\n", key.dptr, from));
switch (from) { switch (from) {
case 0: case 0:

View File

@@ -229,8 +229,9 @@ static BOOL get_md4pw(char *md4pw, char *mach_acct)
} }
#endif /* 0 */ #endif /* 0 */
if(!NT_STATUS_IS_OK(pdb_init_sam(&sampass))) if ( !(sampass = samu_new( NULL )) ) {
return False; return False;
}
/* JRA. This is ok as it is only used for generating the challenge. */ /* JRA. This is ok as it is only used for generating the challenge. */
become_root(); become_root();
@@ -517,10 +518,14 @@ NTSTATUS _net_srv_pwset(pipes_struct *p, NET_Q_SRV_PWSET *q_u, NET_R_SRV_PWSET *
secrets_store_schannel_session_info(p->pipe_state_mem_ctx, secrets_store_schannel_session_info(p->pipe_state_mem_ctx,
remote_machine, remote_machine,
p->dc); p->dc);
pdb_init_sam(&sampass); if ( (sampass = samu_new( NULL )) != NULL ) {
ret=pdb_getsampwnam(sampass, p->dc->mach_acct); ret = pdb_getsampwnam(sampass, p->dc->mach_acct);
}
unbecome_root(); unbecome_root();
if ( !sampass )
return NT_STATUS_NO_MEMORY;
/* Ensure the account exists and is a machine account. */ /* Ensure the account exists and is a machine account. */
acct_ctrl = pdb_get_acct_ctrl(sampass); acct_ctrl = pdb_get_acct_ctrl(sampass);

View File

@@ -1693,10 +1693,9 @@ NTSTATUS _samr_open_user(pipes_struct *p, SAMR_Q_OPEN_USER *q_u, SAMR_R_OPEN_USE
if ( !NT_STATUS_IS_OK(nt_status) ) if ( !NT_STATUS_IS_OK(nt_status) )
return nt_status; return nt_status;
nt_status = pdb_init_sam_talloc(p->mem_ctx, &sampass); if ( !(sampass = samu_new( p->mem_ctx )) ) {
return NT_STATUS_NO_MEMORY;
if (!NT_STATUS_IS_OK(nt_status)) }
return nt_status;
/* append the user's RID to it */ /* append the user's RID to it */
@@ -1749,19 +1748,16 @@ static NTSTATUS get_user_info_7(TALLOC_CTX *mem_ctx, SAM_USER_INFO_7 *id7, DOM_S
{ {
struct samu *smbpass=NULL; struct samu *smbpass=NULL;
BOOL ret; BOOL ret;
NTSTATUS nt_status;
nt_status = pdb_init_sam_talloc(mem_ctx, &smbpass); if ( !(smbpass = samu_new( mem_ctx )) ) {
return NT_STATUS_NO_MEMORY;
if (!NT_STATUS_IS_OK(nt_status)) {
return nt_status;
} }
become_root(); become_root();
ret = pdb_getsampwsid(smbpass, user_sid); ret = pdb_getsampwsid(smbpass, user_sid);
unbecome_root(); unbecome_root();
if (ret==False) { if ( !ret ) {
DEBUG(4,("User %s not found\n", sid_string_static(user_sid))); DEBUG(4,("User %s not found\n", sid_string_static(user_sid)));
return NT_STATUS_NO_SUCH_USER; return NT_STATUS_NO_SUCH_USER;
} }
@@ -1783,12 +1779,9 @@ static NTSTATUS get_user_info_9(TALLOC_CTX *mem_ctx, SAM_USER_INFO_9 * id9, DOM_
{ {
struct samu *smbpass=NULL; struct samu *smbpass=NULL;
BOOL ret; BOOL ret;
NTSTATUS nt_status;
nt_status = pdb_init_sam_talloc(mem_ctx, &smbpass); if ( !(smbpass = samu_new( mem_ctx )) ) {
return NT_STATUS_NO_MEMORY;
if (!NT_STATUS_IS_OK(nt_status)) {
return nt_status;
} }
become_root(); become_root();
@@ -1818,12 +1811,9 @@ static NTSTATUS get_user_info_16(TALLOC_CTX *mem_ctx, SAM_USER_INFO_16 *id16, DO
{ {
struct samu *smbpass=NULL; struct samu *smbpass=NULL;
BOOL ret; BOOL ret;
NTSTATUS nt_status;
nt_status = pdb_init_sam_talloc(mem_ctx, &smbpass); if ( !(smbpass = samu_new( mem_ctx )) ) {
return NT_STATUS_NO_MEMORY;
if (!NT_STATUS_IS_OK(nt_status)) {
return nt_status;
} }
become_root(); become_root();
@@ -1855,7 +1845,6 @@ static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_
{ {
struct samu *smbpass=NULL; struct samu *smbpass=NULL;
BOOL ret; BOOL ret;
NTSTATUS nt_status;
if (p->auth.auth_type != PIPE_AUTH_TYPE_NTLMSSP || p->auth.auth_type != PIPE_AUTH_TYPE_SPNEGO_NTLMSSP) { if (p->auth.auth_type != PIPE_AUTH_TYPE_NTLMSSP || p->auth.auth_type != PIPE_AUTH_TYPE_SPNEGO_NTLMSSP) {
return NT_STATUS_ACCESS_DENIED; return NT_STATUS_ACCESS_DENIED;
@@ -1869,10 +1858,8 @@ static NTSTATUS get_user_info_18(pipes_struct *p, TALLOC_CTX *mem_ctx, SAM_USER_
* Do *NOT* do become_root()/unbecome_root() here ! JRA. * Do *NOT* do become_root()/unbecome_root() here ! JRA.
*/ */
nt_status = pdb_init_sam_talloc(mem_ctx, &smbpass); if ( !(smbpass = samu_new( mem_ctx )) ) {
return NT_STATUS_NO_MEMORY;
if (!NT_STATUS_IS_OK(nt_status)) {
return nt_status;
} }
ret = pdb_getsampwsid(smbpass, user_sid); ret = pdb_getsampwsid(smbpass, user_sid);
@@ -1907,7 +1894,9 @@ static NTSTATUS get_user_info_20(TALLOC_CTX *mem_ctx, SAM_USER_INFO_20 *id20, DO
struct samu *sampass=NULL; struct samu *sampass=NULL;
BOOL ret; BOOL ret;
pdb_init_sam_talloc(mem_ctx, &sampass); if ( !(sampass = samu_new( mem_ctx )) ) {
return NT_STATUS_NO_MEMORY;
}
become_root(); become_root();
ret = pdb_getsampwsid(sampass, user_sid); ret = pdb_getsampwsid(sampass, user_sid);
@@ -1941,9 +1930,8 @@ static NTSTATUS get_user_info_21(TALLOC_CTX *mem_ctx, SAM_USER_INFO_21 *id21,
BOOL ret; BOOL ret;
NTSTATUS nt_status; NTSTATUS nt_status;
nt_status = pdb_init_sam_talloc(mem_ctx, &sampass); if ( !(sampass = samu_new( mem_ctx )) ) {
if (!NT_STATUS_IS_OK(nt_status)) { return NT_STATUS_NO_MEMORY;
return nt_status;
} }
become_root(); become_root();
@@ -2113,8 +2101,10 @@ NTSTATUS _samr_query_usergroups(pipes_struct *p, SAMR_Q_QUERY_USERGROUPS *q_u, S
if (!sid_check_is_in_our_domain(&sid)) if (!sid_check_is_in_our_domain(&sid))
return NT_STATUS_OBJECT_TYPE_MISMATCH; return NT_STATUS_OBJECT_TYPE_MISMATCH;
pdb_init_sam_talloc(p->mem_ctx, &sam_pass); if ( !(sam_pass = samu_new( p->mem_ctx )) ) {
return NT_STATUS_NO_MEMORY;
}
become_root(); become_root();
ret = pdb_getsampwsid(sam_pass, &sid); ret = pdb_getsampwsid(sam_pass, &sid);
unbecome_root(); unbecome_root();
@@ -3290,7 +3280,9 @@ NTSTATUS _samr_set_userinfo(pipes_struct *p, SAMR_Q_SET_USERINFO *q_u, SAMR_R_SE
return NT_STATUS_INVALID_INFO_CLASS; return NT_STATUS_INVALID_INFO_CLASS;
} }
pdb_init_sam(&pwd); if ( !(pwd = samu_new( NULL )) ) {
return NT_STATUS_NO_MEMORY;
}
become_root(); become_root();
ret = pdb_getsampwsid(pwd, &sid); ret = pdb_getsampwsid(pwd, &sid);
@@ -3438,8 +3430,10 @@ NTSTATUS _samr_set_userinfo2(pipes_struct *p, SAMR_Q_SET_USERINFO2 *q_u, SAMR_R_
switch_value=ctr->switch_value; switch_value=ctr->switch_value;
pdb_init_sam(&pwd); if ( !(pwd = samu_new( NULL )) ) {
return NT_STATUS_NO_MEMORY;
}
become_root(); become_root();
ret = pdb_getsampwsid(pwd, &sid); ret = pdb_getsampwsid(pwd, &sid);
unbecome_root(); unbecome_root();
@@ -3916,7 +3910,10 @@ NTSTATUS _samr_delete_dom_user(pipes_struct *p, SAMR_Q_DELETE_DOM_USER *q_u, SAM
return NT_STATUS_CANNOT_DELETE; return NT_STATUS_CANNOT_DELETE;
/* check if the user exists before trying to delete */ /* check if the user exists before trying to delete */
pdb_init_sam(&sam_pass); if ( !(sam_pass = samu_new( NULL )) ) {
return NT_STATUS_NO_MEMORY;
}
if(!pdb_getsampwsid(sam_pass, &user_sid)) { if(!pdb_getsampwsid(sam_pass, &user_sid)) {
DEBUG(5,("_samr_delete_dom_user:User %s doesn't exist.\n", DEBUG(5,("_samr_delete_dom_user:User %s doesn't exist.\n",
sid_string_static(&user_sid))); sid_string_static(&user_sid)));

View File

@@ -768,7 +768,9 @@ static NTSTATUS check_oem_password(const char *user,
*hnd = NULL; *hnd = NULL;
pdb_init_sam(&sampass); if ( !(sampass = samu_new( NULL )) ) {
return NT_STATUS_NO_MEMORY;
}
become_root(); become_root();
ret = pdb_getsampwnam(sampass, user); ret = pdb_getsampwnam(sampass, user);

View File

@@ -1981,8 +1981,8 @@ static BOOL api_NetUserGetGroups(connection_struct *conn,uint16 vuid, char *para
goto done; goto done;
} }
if (!NT_STATUS_IS_OK(pdb_init_sam_talloc(mem_ctx, &sampw))) { if ( !(sampw = samu_new(mem_ctx)) ) {
DEBUG(10, ("pdb_init_sam_talloc failed\n")); DEBUG(0, ("samu_new() failed!\n"));
goto done; goto done;
} }

View File

@@ -508,8 +508,9 @@ static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta)
fstrcpy(account, unistr2_static(&delta->uni_acct_name)); fstrcpy(account, unistr2_static(&delta->uni_acct_name));
d_printf("Creating account: %s\n", account); d_printf("Creating account: %s\n", account);
if (!NT_STATUS_IS_OK(nt_ret = pdb_init_sam(&sam_account))) if ( !(sam_account = samu_new( NULL )) ) {
return nt_ret; return NT_STATUS_NO_MEMORY;
}
if (!(passwd = Get_Pwnam(account))) { if (!(passwd = Get_Pwnam(account))) {
/* Create appropriate user */ /* Create appropriate user */
@@ -690,13 +691,12 @@ static NTSTATUS fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta)
nt_members = TALLOC_ZERO_ARRAY(t, char *, delta->num_members); nt_members = TALLOC_ZERO_ARRAY(t, char *, delta->num_members);
for (i=0; i<delta->num_members; i++) { for (i=0; i<delta->num_members; i++) {
NTSTATUS nt_status;
struct samu *member = NULL; struct samu *member = NULL;
DOM_SID member_sid; DOM_SID member_sid;
if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam_talloc(t, &member))) { if ( !(member = samu_new(t)) ) {
talloc_destroy(t); talloc_destroy(t);
return nt_status; return NT_STATUS_NO_MEMORY;
} }
sid_copy(&member_sid, get_global_sam_sid()); sid_copy(&member_sid, get_global_sam_sid());

View File

@@ -54,7 +54,7 @@ static int net_sam_userset(int argc, const char **argv, const char *field,
return -1; return -1;
} }
if (!NT_STATUS_IS_OK(pdb_init_sam(&sam_acct))) { if ( !(sam_acct = samu_new( NULL )) ) {
d_fprintf(stderr, "Internal error\n"); d_fprintf(stderr, "Internal error\n");
return -1; return -1;
} }
@@ -151,7 +151,7 @@ static int net_sam_set_userflag(int argc, const char **argv, const char *field,
return -1; return -1;
} }
if (!NT_STATUS_IS_OK(pdb_init_sam(&sam_acct))) { if ( !(sam_acct = samu_new( NULL )) ) {
d_fprintf(stderr, "Internal error\n"); d_fprintf(stderr, "Internal error\n");
return -1; return -1;
} }
@@ -254,7 +254,7 @@ static int net_sam_set_time(int argc, const char **argv, const char *field,
} }
if (!NT_STATUS_IS_OK(pdb_init_sam(&sam_acct))) { if ( !(sam_acct = samu_new( NULL )) ) {
d_fprintf(stderr, "Internal error\n"); d_fprintf(stderr, "Internal error\n");
return -1; return -1;
} }

View File

@@ -175,7 +175,7 @@ static int print_user_info (struct pdb_methods *in, const char *username, BOOL v
struct samu *sam_pwent=NULL; struct samu *sam_pwent=NULL;
BOOL ret; BOOL ret;
if (!NT_STATUS_IS_OK(pdb_init_sam (&sam_pwent))) { if ( !(sam_pwent = samu_new( NULL )) ) {
return -1; return -1;
} }
@@ -207,16 +207,22 @@ static int print_users_list (struct pdb_methods *in, BOOL verbosity, BOOL smbpwd
} }
check = True; check = True;
if (!(NT_STATUS_IS_OK(pdb_init_sam(&sam_pwent)))) return 1; if ( !(sam_pwent = samu_new( NULL )) ) {
return 1;
}
while (check && NT_STATUS_IS_OK(in->getsampwent (in, sam_pwent))) { while (check && NT_STATUS_IS_OK(in->getsampwent (in, sam_pwent))) {
if (verbosity) if (verbosity)
printf ("---------------\n"); printf ("---------------\n");
print_sam_info (sam_pwent, verbosity, smbpwdstyle); print_sam_info (sam_pwent, verbosity, smbpwdstyle);
TALLOC_FREE(sam_pwent); TALLOC_FREE(sam_pwent);
check = NT_STATUS_IS_OK(pdb_init_sam(&sam_pwent));
if ( !(sam_pwent = samu_new( NULL )) ) {
check = False;
}
} }
if (check) TALLOC_FREE(sam_pwent); if (check)
TALLOC_FREE(sam_pwent);
in->endsampwent(in); in->endsampwent(in);
return 0; return 0;
@@ -236,7 +242,9 @@ static int fix_users_list (struct pdb_methods *in)
} }
check = True; check = True;
if (!(NT_STATUS_IS_OK(pdb_init_sam(&sam_pwent)))) return 1; if ( !(sam_pwent = samu_new( NULL )) ) {
return 1;
}
while (check && NT_STATUS_IS_OK(in->getsampwent (in, sam_pwent))) { while (check && NT_STATUS_IS_OK(in->getsampwent (in, sam_pwent))) {
printf("Updating record for user %s\n", pdb_get_username(sam_pwent)); printf("Updating record for user %s\n", pdb_get_username(sam_pwent));
@@ -245,13 +253,16 @@ static int fix_users_list (struct pdb_methods *in)
printf("Update of user %s failed!\n", pdb_get_username(sam_pwent)); printf("Update of user %s failed!\n", pdb_get_username(sam_pwent));
} }
TALLOC_FREE(sam_pwent); TALLOC_FREE(sam_pwent);
check = NT_STATUS_IS_OK(pdb_init_sam(&sam_pwent)); if ( !(sam_pwent = samu_new( NULL )) ) {
check = False;
}
if (!check) { if (!check) {
fprintf(stderr, "Failed to initialise new struct samu structure (out of memory?)\n"); fprintf(stderr, "Failed to initialise new struct samu structure (out of memory?)\n");
} }
} }
if (check) TALLOC_FREE(sam_pwent); if (check)
TALLOC_FREE(sam_pwent);
in->endsampwent(in); in->endsampwent(in);
return 0; return 0;
@@ -275,7 +286,9 @@ static int set_user_info (struct pdb_methods *in, const char *username,
struct samu *sam_pwent=NULL; struct samu *sam_pwent=NULL;
BOOL ret; BOOL ret;
pdb_init_sam(&sam_pwent); if ( !(sam_pwent = samu_new( NULL )) ) {
return 1;
}
ret = NT_STATUS_IS_OK(in->getsampwnam (in, sam_pwent, username)); ret = NT_STATUS_IS_OK(in->getsampwnam (in, sam_pwent, username));
if (ret==False) { if (ret==False) {
@@ -506,14 +519,22 @@ static int new_machine (struct pdb_methods *in, const char *machine_in)
fstrcat(machineaccount, "$"); fstrcat(machineaccount, "$");
if ((pwd = getpwnam_alloc(NULL, machineaccount))) { if ((pwd = getpwnam_alloc(NULL, machineaccount))) {
if (!NT_STATUS_IS_OK(pdb_init_sam_pw( &sam_pwent, pwd))) {
if ( !(sam_pwent = samu_new( NULL )) ) {
fprintf(stderr, "Memory allocation error!\n");
TALLOC_FREE(pwd);
return -1;
}
if ( !NT_STATUS_IS_OK(samu_set_unix(sam_pwent, pwd)) ) {
fprintf(stderr, "Could not init sam from pw\n"); fprintf(stderr, "Could not init sam from pw\n");
TALLOC_FREE(pwd); TALLOC_FREE(pwd);
return -1; return -1;
} }
TALLOC_FREE(pwd); TALLOC_FREE(pwd);
} else { } else {
if (!NT_STATUS_IS_OK(pdb_init_sam (&sam_pwent))) { if ( !(sam_pwent = samu_new( NULL )) ) {
fprintf(stderr, "Could not init sam from pw\n"); fprintf(stderr, "Could not init sam from pw\n");
return -1; return -1;
} }
@@ -546,7 +567,7 @@ static int delete_user_entry (struct pdb_methods *in, const char *username)
{ {
struct samu *samaccount = NULL; struct samu *samaccount = NULL;
if (!NT_STATUS_IS_OK(pdb_init_sam (&samaccount))) { if ( !(samaccount = samu_new( NULL )) ) {
return -1; return -1;
} }
@@ -576,7 +597,7 @@ static int delete_machine_entry (struct pdb_methods *in, const char *machinename
if (name[strlen(name)-1] != '$') if (name[strlen(name)-1] != '$')
fstrcat (name, "$"); fstrcat (name, "$");
if (!NT_STATUS_IS_OK(pdb_init_sam (&samaccount))) { if ( !(samaccount = samu_new( NULL )) ) {
return -1; return -1;
} }

View File

@@ -404,7 +404,7 @@ static int process_root(int local_flags)
struct samu *sampass = NULL; struct samu *sampass = NULL;
BOOL ret; BOOL ret;
pdb_init_sam(&sampass); sampass = samu_new( NULL );
ret = pdb_getsampwnam(sampass, user_name); ret = pdb_getsampwnam(sampass, user_name);
if((ret) && if((ret) &&
(pdb_get_lanman_passwd(sampass) == NULL)) { (pdb_get_lanman_passwd(sampass) == NULL)) {
@@ -438,7 +438,7 @@ static int process_root(int local_flags)
struct samu *sampass = NULL; struct samu *sampass = NULL;
BOOL ret; BOOL ret;
pdb_init_sam(&sampass); sampass = samu_new( NULL );
ret = pdb_getsampwnam(sampass, user_name); ret = pdb_getsampwnam(sampass, user_name);
printf("Password changed for user %s.", user_name ); printf("Password changed for user %s.", user_name );