summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2006-02-20 20:09:36 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:10:15 -0500
commit2203bed32c84c63737f402accf73452efb76b483 (patch)
tree76259a35b1137cfa89547b80b2b93eb0eedf5bcf /source3/utils
parent69b2669b559c009d17f621cbc7c6937eafc56af6 (diff)
downloadsamba-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/utils')
-rw-r--r--source3/utils/net_rpc_samsync.c18
-rw-r--r--source3/utils/net_sam.c16
-rw-r--r--source3/utils/pdbedit.c50
-rw-r--r--source3/utils/smbpasswd.c8
4 files changed, 46 insertions, 46 deletions
diff --git a/source3/utils/net_rpc_samsync.c b/source3/utils/net_rpc_samsync.c
index f8cd0e090d..d3b9a9a8a8 100644
--- a/source3/utils/net_rpc_samsync.c
+++ b/source3/utils/net_rpc_samsync.c
@@ -300,12 +300,12 @@ NTSTATUS rpc_samdump_internals(const DOM_SID *domain_sid,
return NT_STATUS_OK;
}
-/* Convert a SAM_ACCOUNT_DELTA to a SAM_ACCOUNT. */
+/* Convert a struct samu_DELTA to a struct samu. */
#define STRING_CHANGED (old_string && !new_string) ||\
(!old_string && new_string) ||\
(old_string && new_string && (strcmp(old_string, new_string) != 0))
-static NTSTATUS sam_account_from_delta(SAM_ACCOUNT *account, SAM_ACCOUNT_INFO *delta)
+static NTSTATUS sam_account_from_delta(struct samu *account, SAM_ACCOUNT_INFO *delta)
{
const char *old_string, *new_string;
time_t unix_time, stored_time;
@@ -497,7 +497,7 @@ static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta)
NTSTATUS nt_ret;
fstring account;
pstring add_script;
- SAM_ACCOUNT *sam_account=NULL;
+ struct samu *sam_account=NULL;
GROUP_MAP map;
struct group *grp;
DOM_SID user_sid;
@@ -562,7 +562,7 @@ static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta)
if (!NT_STATUS_IS_OK(pdb_update_sam_account(sam_account))) {
DEBUG(1, ("SAM Account for %s failed to be updated in the passdb!\n",
account));
- pdb_free_sam(&sam_account);
+ TALLOC_FREE(sam_account);
return NT_STATUS_ACCESS_DENIED;
}
}
@@ -589,7 +589,7 @@ static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta)
}
done:
- pdb_free_sam(&sam_account);
+ TALLOC_FREE(sam_account);
return nt_ret;
}
@@ -691,7 +691,7 @@ static NTSTATUS fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta)
for (i=0; i<delta->num_members; i++) {
NTSTATUS nt_status;
- SAM_ACCOUNT *member = NULL;
+ struct samu *member = NULL;
DOM_SID member_sid;
if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam_talloc(t, &member))) {
@@ -705,19 +705,19 @@ static NTSTATUS fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta)
if (!pdb_getsampwsid(member, &member_sid)) {
DEBUG(1, ("Found bogus group member: %d (member_sid=%s group=%s)\n",
delta->rids[i], sid_string_static(&member_sid), grp->gr_name));
- pdb_free_sam(&member);
+ TALLOC_FREE(member);
continue;
}
if (pdb_get_group_rid(member) == rid) {
d_printf("%s(primary),", pdb_get_username(member));
- pdb_free_sam(&member);
+ TALLOC_FREE(member);
continue;
}
d_printf("%s,", pdb_get_username(member));
nt_members[i] = talloc_strdup(t, pdb_get_username(member));
- pdb_free_sam(&member);
+ TALLOC_FREE(member);
}
d_printf("\n");
diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c
index ba3ec5c57f..ae0aef5960 100644
--- a/source3/utils/net_sam.c
+++ b/source3/utils/net_sam.c
@@ -27,10 +27,10 @@
*/
static int net_sam_userset(int argc, const char **argv, const char *field,
- BOOL (*fn)(SAM_ACCOUNT *, const char *,
+ BOOL (*fn)(struct samu *, const char *,
enum pdb_value_state))
{
- SAM_ACCOUNT *sam_acct = NULL;
+ struct samu *sam_acct = NULL;
DOM_SID sid;
enum SID_NAME_USE type;
const char *dom, *name;
@@ -76,7 +76,7 @@ static int net_sam_userset(int argc, const char **argv, const char *field,
return -1;
}
- pdb_free_sam(&sam_acct);
+ TALLOC_FREE(sam_acct);
d_printf("Updated %s for %s\\%s to %s\n", field, dom, name, argv[1]);
return 0;
@@ -125,7 +125,7 @@ static int net_sam_set_workstations(int argc, const char **argv)
static int net_sam_set_userflag(int argc, const char **argv, const char *field,
uint16 flag)
{
- SAM_ACCOUNT *sam_acct = NULL;
+ struct samu *sam_acct = NULL;
DOM_SID sid;
enum SID_NAME_USE type;
const char *dom, *name;
@@ -178,7 +178,7 @@ static int net_sam_set_userflag(int argc, const char **argv, const char *field,
return -1;
}
- pdb_free_sam(&sam_acct);
+ TALLOC_FREE(sam_acct);
d_fprintf(stderr, "Updated flag %s for %s\\%s to %s\n", field, dom,
name, argv[1]);
@@ -210,10 +210,10 @@ static int net_sam_set_pwnoexp(int argc, const char **argv)
*/
static int net_sam_set_time(int argc, const char **argv, const char *field,
- BOOL (*fn)(SAM_ACCOUNT *, time_t,
+ BOOL (*fn)(struct samu *, time_t,
enum pdb_value_state))
{
- SAM_ACCOUNT *sam_acct = NULL;
+ struct samu *sam_acct = NULL;
DOM_SID sid;
enum SID_NAME_USE type;
const char *dom, *name;
@@ -276,7 +276,7 @@ static int net_sam_set_time(int argc, const char **argv, const char *field,
return -1;
}
- pdb_free_sam(&sam_acct);
+ TALLOC_FREE(sam_acct);
d_printf("Updated %s for %s\\%s to %s\n", field, dom, name, argv[1]);
return 0;
diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c
index 2e7fbc1812..d517783e85 100644
--- a/source3/utils/pdbedit.c
+++ b/source3/utils/pdbedit.c
@@ -86,7 +86,7 @@ static int reinit_account_policies (void)
Print info from sam structure
**********************************************************/
-static int print_sam_info (SAM_ACCOUNT *sam_pwent, BOOL verbosity, BOOL smbpwdstyle)
+static int print_sam_info (struct samu *sam_pwent, BOOL verbosity, BOOL smbpwdstyle)
{
uid_t uid;
time_t tmp;
@@ -172,7 +172,7 @@ static int print_sam_info (SAM_ACCOUNT *sam_pwent, BOOL verbosity, BOOL smbpwdst
static int print_user_info (struct pdb_methods *in, const char *username, BOOL verbosity, BOOL smbpwdstyle)
{
- SAM_ACCOUNT *sam_pwent=NULL;
+ struct samu *sam_pwent=NULL;
BOOL ret;
if (!NT_STATUS_IS_OK(pdb_init_sam (&sam_pwent))) {
@@ -183,12 +183,12 @@ static int print_user_info (struct pdb_methods *in, const char *username, BOOL v
if (ret==False) {
fprintf (stderr, "Username not found!\n");
- pdb_free_sam(&sam_pwent);
+ TALLOC_FREE(sam_pwent);
return -1;
}
ret=print_sam_info (sam_pwent, verbosity, smbpwdstyle);
- pdb_free_sam(&sam_pwent);
+ TALLOC_FREE(sam_pwent);
return ret;
}
@@ -198,7 +198,7 @@ static int print_user_info (struct pdb_methods *in, const char *username, BOOL v
**********************************************************/
static int print_users_list (struct pdb_methods *in, BOOL verbosity, BOOL smbpwdstyle)
{
- SAM_ACCOUNT *sam_pwent=NULL;
+ struct samu *sam_pwent=NULL;
BOOL check;
check = NT_STATUS_IS_OK(in->setsampwent(in, False, 0));
@@ -213,10 +213,10 @@ static int print_users_list (struct pdb_methods *in, BOOL verbosity, BOOL smbpwd
if (verbosity)
printf ("---------------\n");
print_sam_info (sam_pwent, verbosity, smbpwdstyle);
- pdb_free_sam(&sam_pwent);
+ TALLOC_FREE(sam_pwent);
check = NT_STATUS_IS_OK(pdb_init_sam(&sam_pwent));
}
- if (check) pdb_free_sam(&sam_pwent);
+ if (check) TALLOC_FREE(sam_pwent);
in->endsampwent(in);
return 0;
@@ -227,7 +227,7 @@ static int print_users_list (struct pdb_methods *in, BOOL verbosity, BOOL smbpwd
**********************************************************/
static int fix_users_list (struct pdb_methods *in)
{
- SAM_ACCOUNT *sam_pwent=NULL;
+ struct samu *sam_pwent=NULL;
BOOL check;
check = NT_STATUS_IS_OK(in->setsampwent(in, False, 0));
@@ -244,14 +244,14 @@ static int fix_users_list (struct pdb_methods *in)
if (!NT_STATUS_IS_OK(pdb_update_sam_account(sam_pwent))) {
printf("Update of user %s failed!\n", pdb_get_username(sam_pwent));
}
- pdb_free_sam(&sam_pwent);
+ TALLOC_FREE(sam_pwent);
check = NT_STATUS_IS_OK(pdb_init_sam(&sam_pwent));
if (!check) {
- fprintf(stderr, "Failed to initialise new SAM_ACCOUNT structure (out of memory?)\n");
+ fprintf(stderr, "Failed to initialise new struct samu structure (out of memory?)\n");
}
}
- if (check) pdb_free_sam(&sam_pwent);
+ if (check) TALLOC_FREE(sam_pwent);
in->endsampwent(in);
return 0;
@@ -272,7 +272,7 @@ static int set_user_info (struct pdb_methods *in, const char *username,
time_t pwd_can_change, time_t pwd_must_change)
{
BOOL updated_autolock = False, updated_badpw = False;
- SAM_ACCOUNT *sam_pwent=NULL;
+ struct samu *sam_pwent=NULL;
BOOL ret;
pdb_init_sam(&sam_pwent);
@@ -280,7 +280,7 @@ static int set_user_info (struct pdb_methods *in, const char *username,
ret = NT_STATUS_IS_OK(in->getsampwnam (in, sam_pwent, username));
if (ret==False) {
fprintf (stderr, "Username not found!\n");
- pdb_free_sam(&sam_pwent);
+ TALLOC_FREE(sam_pwent);
return -1;
}
@@ -333,7 +333,7 @@ static int set_user_info (struct pdb_methods *in, const char *username,
if (newflag & not_settable) {
fprintf(stderr, "Can only set [NDHLX] flags\n");
- pdb_free_sam(&sam_pwent);
+ TALLOC_FREE(sam_pwent);
return -1;
}
@@ -381,10 +381,10 @@ static int set_user_info (struct pdb_methods *in, const char *username,
print_user_info (in, username, True, False);
else {
fprintf (stderr, "Unable to modify entry!\n");
- pdb_free_sam(&sam_pwent);
+ TALLOC_FREE(sam_pwent);
return -1;
}
- pdb_free_sam(&sam_pwent);
+ TALLOC_FREE(sam_pwent);
return 0;
}
@@ -397,7 +397,7 @@ static int new_user (struct pdb_methods *in, const char *username,
const char *profile, char *user_sid, char *group_sid,
BOOL stdin_get)
{
- SAM_ACCOUNT *sam_pwent=NULL;
+ struct samu *sam_pwent=NULL;
char *password1, *password2;
int rc_pwd_cmp;
@@ -413,7 +413,7 @@ static int new_user (struct pdb_methods *in, const char *username,
password2 = get_pass( "retype new password:", stdin_get);
if ((rc_pwd_cmp = strcmp (password1, password2))) {
fprintf (stderr, "Passwords do not match!\n");
- pdb_free_sam (&sam_pwent);
+ TALLOC_FREE(sam_pwent);
} else {
pdb_set_plaintext_passwd(sam_pwent, password1);
}
@@ -474,10 +474,10 @@ static int new_user (struct pdb_methods *in, const char *username,
print_user_info (in, username, True, False);
} else {
fprintf (stderr, "Unable to add user! (does it already exist?)\n");
- pdb_free_sam (&sam_pwent);
+ TALLOC_FREE(sam_pwent);
return -1;
}
- pdb_free_sam (&sam_pwent);
+ TALLOC_FREE(sam_pwent);
return 0;
}
@@ -487,7 +487,7 @@ static int new_user (struct pdb_methods *in, const char *username,
static int new_machine (struct pdb_methods *in, const char *machine_in)
{
- SAM_ACCOUNT *sam_pwent=NULL;
+ struct samu *sam_pwent=NULL;
fstring machinename;
fstring machineaccount;
struct passwd *pwd = NULL;
@@ -531,10 +531,10 @@ static int new_machine (struct pdb_methods *in, const char *machine_in)
print_user_info (in, machineaccount, True, False);
} else {
fprintf (stderr, "Unable to add machine! (does it already exist?)\n");
- pdb_free_sam (&sam_pwent);
+ TALLOC_FREE(sam_pwent);
return -1;
}
- pdb_free_sam (&sam_pwent);
+ TALLOC_FREE(sam_pwent);
return 0;
}
@@ -544,7 +544,7 @@ static int new_machine (struct pdb_methods *in, const char *machine_in)
static int delete_user_entry (struct pdb_methods *in, const char *username)
{
- SAM_ACCOUNT *samaccount = NULL;
+ struct samu *samaccount = NULL;
if (!NT_STATUS_IS_OK(pdb_init_sam (&samaccount))) {
return -1;
@@ -569,7 +569,7 @@ static int delete_user_entry (struct pdb_methods *in, const char *username)
static int delete_machine_entry (struct pdb_methods *in, const char *machinename)
{
fstring name;
- SAM_ACCOUNT *samaccount = NULL;
+ struct samu *samaccount = NULL;
fstrcpy(name, machinename);
name[15] = '\0';
diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
index a42361780e..61e97fd692 100644
--- a/source3/utils/smbpasswd.c
+++ b/source3/utils/smbpasswd.c
@@ -401,7 +401,7 @@ static int process_root(int local_flags)
*/
if(local_flags & LOCAL_ENABLE_USER) {
- SAM_ACCOUNT *sampass = NULL;
+ struct samu *sampass = NULL;
BOOL ret;
pdb_init_sam(&sampass);
@@ -410,7 +410,7 @@ static int process_root(int local_flags)
(pdb_get_lanman_passwd(sampass) == NULL)) {
local_flags |= LOCAL_SET_PASSWORD;
}
- pdb_free_sam(&sampass);
+ TALLOC_FREE(sampass);
}
}
@@ -435,7 +435,7 @@ static int process_root(int local_flags)
if(remote_machine) {
printf("Password changed for user %s on %s.\n", user_name, remote_machine );
} else if(!(local_flags & (LOCAL_ADD_USER|LOCAL_DISABLE_USER|LOCAL_ENABLE_USER|LOCAL_DELETE_USER|LOCAL_SET_NO_PASSWORD|LOCAL_SET_PASSWORD))) {
- SAM_ACCOUNT *sampass = NULL;
+ struct samu *sampass = NULL;
BOOL ret;
pdb_init_sam(&sampass);
@@ -447,7 +447,7 @@ static int process_root(int local_flags)
if((ret != False) && (pdb_get_acct_ctrl(sampass) & ACB_PWNOTREQ) )
printf(" User has no password flag set.");
printf("\n");
- pdb_free_sam(&sampass);
+ TALLOC_FREE(sampass);
}
done: