summaryrefslogtreecommitdiff
path: root/source3/auth
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2006-02-21 14:34:11 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:10:16 -0500
commitcd559192633d78a9f06e239c6a448955f6ea0842 (patch)
tree9b91416a493d3f9ca1d8c65666184539ce8919de /source3/auth
parent87ef96e6be75fb4988fac48b2e21892720c20426 (diff)
downloadsamba-cd559192633d78a9f06e239c6a448955f6ea0842.tar.gz
samba-cd559192633d78a9f06e239c6a448955f6ea0842.tar.bz2
samba-cd559192633d78a9f06e239c6a448955f6ea0842.zip
r13590: * replace all pdb_init_sam[_talloc]() calls with samu_new()
* replace all pdb_{init,fill}_sam_pw() calls with samu_set_unix() (This used to be commit 6f1afa4acc93a07d0ee9940822d7715acaae634f)
Diffstat (limited to 'source3/auth')
-rw-r--r--source3/auth/auth_rhosts.c19
-rw-r--r--source3/auth/auth_sam.c5
-rw-r--r--source3/auth/auth_unix.c6
-rw-r--r--source3/auth/auth_util.c55
4 files changed, 46 insertions, 39 deletions
diff --git a/source3/auth/auth_rhosts.c b/source3/auth/auth_rhosts.c
index 7068fa2e88..23e276bc84 100644
--- a/source3/auth/auth_rhosts.c
+++ b/source3/auth/auth_rhosts.c
@@ -31,7 +31,7 @@
static NTSTATUS auth_get_sam_account(const char *user, struct samu **account)
{
BOOL pdb_ret;
- NTSTATUS nt_status;
+ NTSTATUS nt_status = NT_STATUS_NO_SUCH_USER;
if ( !(*account = samu_new( NULL )) ) {
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);
unbecome_root();
- if (!pdb_ret) {
-
- struct passwd *pass = Get_Pwnam(user);
- if (!pass)
- return NT_STATUS_NO_SUCH_USER;
+ if (!pdb_ret)
+ {
+ struct passwd *pass;
- if (!NT_STATUS_IS_OK(nt_status = pdb_fill_sam_pw(*account, pass))) {
- return nt_status;
+ if ( !(pass = Get_Pwnam( user )) ) {
+ return NT_STATUS_NO_SUCH_USER;
}
+
+ nt_status = samu_set_unix( *account, pass );
}
- return NT_STATUS_OK;
+
+ return nt_status;
}
/****************************************************************************
diff --git a/source3/auth/auth_sam.c b/source3/auth/auth_sam.c
index 6f8ca387d2..f06eb83ba1 100644
--- a/source3/auth/auth_sam.c
+++ b/source3/auth/auth_sam.c
@@ -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
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 */
diff --git a/source3/auth/auth_unix.c b/source3/auth/auth_unix.c
index 1d29389716..efe5203b23 100644
--- a/source3/auth/auth_unix.c
+++ b/source3/auth/auth_unix.c
@@ -30,10 +30,12 @@
**/
static BOOL update_smbpassword_file(const char *user, const char *password)
{
- struct samu *sampass = NULL;
+ struct samu *sampass;
BOOL ret;
- pdb_init_sam(&sampass);
+ if ( !(sampass = samu_new( NULL )) ) {
+ return False;
+ }
become_root();
ret = pdb_getsampwnam(sampass, user);
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
index 7e6ab021b4..bc929fc81d 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -172,7 +172,7 @@ NTSTATUS make_user_info_map(auth_usersupplied_info **user_info,
and let the "passdb backend" handle unknown users. */
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 */
@@ -492,7 +492,7 @@ NT_USER_TOKEN *get_root_nt_token( void )
if ( token )
return token;
- if ( !(pw = getpwnam( "root" )) ) {
+ if ( !(pw = sys_getpwnam( "root" )) ) {
DEBUG(0,("get_root_nt_token: getpwnam\"root\") failed!\n"));
return NULL;
}
@@ -951,8 +951,7 @@ NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
struct samu *sam_acct = NULL;
- result = pdb_init_sam_talloc(tmp_ctx, &sam_acct);
- if (!NT_STATUS_IS_OK(result)) {
+ if ( !(sam_acct = samu_new( tmp_ctx )) ) {
goto done;
}
@@ -1100,9 +1099,12 @@ NTSTATUS make_server_info_pac(auth_serversupplied_info **server_info,
fstring dom_name;
auth_serversupplied_info *result;
- status = pdb_init_sam_pw(&sampass, pwd);
-
- if (!NT_STATUS_IS_OK(status)) {
+ if ( !(sampass = samu_new( NULL )) ) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = samu_set_unix( sampass, pwd );
+ if ( !NT_STATUS_IS_OK(status) ) {
return status;
}
@@ -1157,8 +1159,11 @@ NTSTATUS make_server_info_pw(auth_serversupplied_info **server_info,
gid_t *gids;
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)) {
return status;
}
@@ -1211,10 +1216,8 @@ static NTSTATUS make_new_server_info_guest(auth_serversupplied_info **server_inf
BOOL ret;
static const char zeros[16];
- status = pdb_init_sam(&sampass);
-
- if (!NT_STATUS_IS_OK(status)) {
- return status;
+ if ( !(sampass = samu_new( NULL )) ) {
+ return NT_STATUS_NO_MEMORY;
}
sid_copy(&guest_sid, get_global_sam_sid());
@@ -1311,7 +1314,7 @@ static NTSTATUS fill_sam_account(TALLOC_CTX *mem_ctx,
const char *username,
char **found_username,
uid_t *uid, gid_t *gid,
- struct samu **sam_account)
+ struct samu *account)
{
NTSTATUS nt_status;
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 );
- DEBUG(5,("fill_sam_account: located username was [%s]\n",
- *found_username));
+ DEBUG(5,("fill_sam_account: located username was [%s]\n", *found_username));
- nt_status = pdb_init_sam_pw(sam_account, passwd);
+ nt_status = samu_set_unix( account, passwd );
+
TALLOC_FREE(passwd);
+
return nt_status;
}
@@ -1452,7 +1456,6 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx,
char *found_username;
const char *nt_domain;
const char *nt_username;
-
struct samu *sam_account = NULL;
DOM_SID user_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
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,
- &found_username, &uid, &gid,
- &sam_account);
+ &found_username, &uid, &gid, sam_account);
if (NT_STATUS_EQUAL(nt_status, NT_STATUS_NO_SUCH_USER)) {
DEBUG(3,("User %s does not exist, trying to add it\n",
internal_username));
smb_create_user( nt_domain, sent_nt_username, NULL);
- nt_status = fill_sam_account( mem_ctx, nt_domain,
- sent_nt_username,
- &found_username, &uid, &gid,
- &sam_account );
+ nt_status = fill_sam_account( mem_ctx, nt_domain, sent_nt_username,
+ &found_username, &uid, &gid, sam_account );
}
/* if we still don't have a valid unix account check for
'map to gues = bad uid' */
if (!NT_STATUS_IS_OK(nt_status)) {
+ TALLOC_FREE( sam_account );
if ( lp_map_to_guest() == MAP_TO_GUEST_ON_BAD_UID ) {
make_server_info_guest(server_info);
return NT_STATUS_OK;
}
-
- DEBUG(0, ("make_server_info_info3: pdb_init_sam failed!\n"));
return nt_status;
}