summaryrefslogtreecommitdiff
path: root/source3/utils
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/utils
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/utils')
-rw-r--r--source3/utils/net_rpc_samsync.c10
-rw-r--r--source3/utils/net_sam.c6
-rw-r--r--source3/utils/pdbedit.c45
-rw-r--r--source3/utils/smbpasswd.c4
4 files changed, 43 insertions, 22 deletions
diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c
index d3b9a9a8a8..05ff28ad65 100644
--- a/source3/utils/net_rpc_samsync.c
+++ b/source3/utils/net_rpc_samsync.c
@@ -508,8 +508,9 @@ static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta)
fstrcpy(account, unistr2_static(&delta->uni_acct_name));
d_printf("Creating account: %s\n", account);
- if (!NT_STATUS_IS_OK(nt_ret = pdb_init_sam(&sam_account)))
- return nt_ret;
+ if ( !(sam_account = samu_new( NULL )) ) {
+ return NT_STATUS_NO_MEMORY;
+ }
if (!(passwd = Get_Pwnam(account))) {
/* 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);
for (i=0; i<delta->num_members; i++) {
- NTSTATUS nt_status;
struct samu *member = NULL;
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);
- return nt_status;
+ return NT_STATUS_NO_MEMORY;
}
sid_copy(&member_sid, get_global_sam_sid());
diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c
index ae0aef5960..ea0544abf3 100644
--- a/source3/utils/net_sam.c
+++ b/source3/utils/net_sam.c
@@ -54,7 +54,7 @@ static int net_sam_userset(int argc, const char **argv, const char *field,
return -1;
}
- if (!NT_STATUS_IS_OK(pdb_init_sam(&sam_acct))) {
+ if ( !(sam_acct = samu_new( NULL )) ) {
d_fprintf(stderr, "Internal error\n");
return -1;
}
@@ -151,7 +151,7 @@ static int net_sam_set_userflag(int argc, const char **argv, const char *field,
return -1;
}
- if (!NT_STATUS_IS_OK(pdb_init_sam(&sam_acct))) {
+ if ( !(sam_acct = samu_new( NULL )) ) {
d_fprintf(stderr, "Internal error\n");
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");
return -1;
}
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c
index d517783e85..f1e4fb6542 100644
--- a/source3/utils/pdbedit.c
+++ b/source3/utils/pdbedit.c
@@ -175,7 +175,7 @@ static int print_user_info (struct pdb_methods *in, const char *username, BOOL v
struct samu *sam_pwent=NULL;
BOOL ret;
- if (!NT_STATUS_IS_OK(pdb_init_sam (&sam_pwent))) {
+ if ( !(sam_pwent = samu_new( NULL )) ) {
return -1;
}
@@ -207,16 +207,22 @@ static int print_users_list (struct pdb_methods *in, BOOL verbosity, BOOL smbpwd
}
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))) {
if (verbosity)
printf ("---------------\n");
print_sam_info (sam_pwent, verbosity, smbpwdstyle);
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);
return 0;
@@ -236,7 +242,9 @@ static int fix_users_list (struct pdb_methods *in)
}
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))) {
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));
}
TALLOC_FREE(sam_pwent);
- check = NT_STATUS_IS_OK(pdb_init_sam(&sam_pwent));
+ if ( !(sam_pwent = samu_new( NULL )) ) {
+ check = False;
+ }
if (!check) {
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);
return 0;
@@ -275,7 +286,9 @@ static int set_user_info (struct pdb_methods *in, const char *username,
struct samu *sam_pwent=NULL;
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));
if (ret==False) {
@@ -506,14 +519,22 @@ static int new_machine (struct pdb_methods *in, const char *machine_in)
fstrcat(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");
TALLOC_FREE(pwd);
return -1;
}
+
TALLOC_FREE(pwd);
} 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");
return -1;
}
@@ -546,7 +567,7 @@ static int delete_user_entry (struct pdb_methods *in, const char *username)
{
struct samu *samaccount = NULL;
- if (!NT_STATUS_IS_OK(pdb_init_sam (&samaccount))) {
+ if ( !(samaccount = samu_new( NULL )) ) {
return -1;
}
@@ -576,7 +597,7 @@ static int delete_machine_entry (struct pdb_methods *in, const char *machinename
if (name[strlen(name)-1] != '$')
fstrcat (name, "$");
- if (!NT_STATUS_IS_OK(pdb_init_sam (&samaccount))) {
+ if ( !(samaccount = samu_new( NULL )) ) {
return -1;
}
diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
index 61e97fd692..d66001e441 100644
--- a/source3/utils/smbpasswd.c
+++ b/source3/utils/smbpasswd.c
@@ -404,7 +404,7 @@ static int process_root(int local_flags)
struct samu *sampass = NULL;
BOOL ret;
- pdb_init_sam(&sampass);
+ sampass = samu_new( NULL );
ret = pdb_getsampwnam(sampass, user_name);
if((ret) &&
(pdb_get_lanman_passwd(sampass) == NULL)) {
@@ -438,7 +438,7 @@ static int process_root(int local_flags)
struct samu *sampass = NULL;
BOOL ret;
- pdb_init_sam(&sampass);
+ sampass = samu_new( NULL );
ret = pdb_getsampwnam(sampass, user_name);
printf("Password changed for user %s.", user_name );