summaryrefslogtreecommitdiff
path: root/source3/passdb
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/passdb
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/passdb')
-rw-r--r--source3/passdb/login_cache.c8
-rw-r--r--source3/passdb/passdb.c343
-rw-r--r--source3/passdb/pdb_compat.c10
-rw-r--r--source3/passdb/pdb_get_set.c476
-rw-r--r--source3/passdb/pdb_interface.c90
-rw-r--r--source3/passdb/pdb_ldap.c72
-rw-r--r--source3/passdb/pdb_nds.c4
-rw-r--r--source3/passdb/pdb_smbpasswd.c44
-rw-r--r--source3/passdb/pdb_tdb.c102
9 files changed, 535 insertions, 614 deletions
diff --git a/source3/passdb/login_cache.c b/source3/passdb/login_cache.c
index d82cfcc560..fba5990d81 100644
--- a/source3/passdb/login_cache.c
+++ b/source3/passdb/login_cache.c
@@ -1,6 +1,6 @@
/*
Unix SMB/CIFS implementation.
- SAM_ACCOUNT local cache for
+ struct samu local cache for
Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2004.
This program is free software; you can redistribute it and/or modify
@@ -64,7 +64,7 @@ BOOL login_cache_shutdown(void)
}
/* if we can't read the cache, oh well, no need to return anything */
-LOGIN_CACHE * login_cache_read(SAM_ACCOUNT *sampass)
+LOGIN_CACHE * login_cache_read(struct samu *sampass)
{
TDB_DATA keybuf, databuf;
LOGIN_CACHE *entry;
@@ -108,7 +108,7 @@ LOGIN_CACHE * login_cache_read(SAM_ACCOUNT *sampass)
return entry;
}
-BOOL login_cache_write(const SAM_ACCOUNT *sampass, LOGIN_CACHE entry)
+BOOL login_cache_write(const struct samu *sampass, LOGIN_CACHE entry)
{
TDB_DATA keybuf, databuf;
@@ -155,7 +155,7 @@ BOOL login_cache_write(const SAM_ACCOUNT *sampass, LOGIN_CACHE entry)
return ret == 0;
}
-BOOL login_cache_delentry(const SAM_ACCOUNT *sampass)
+BOOL login_cache_delentry(const struct samu *sampass)
{
int ret;
TDB_DATA keybuf;
diff --git a/source3/passdb/passdb.c b/source3/passdb/passdb.c
index 97cccbf2a5..1632d222d4 100644
--- a/source3/passdb/passdb.c
+++ b/source3/passdb/passdb.c
@@ -48,49 +48,47 @@ const char *get_default_sam_name(void)
}
/************************************************************
- Fill the SAM_ACCOUNT with default values.
+ Fill the struct samu with default values.
***********************************************************/
-void pdb_fill_default_sam(SAM_ACCOUNT *user)
+void pdb_fill_default_sam(struct samu *user)
{
- ZERO_STRUCT(user->private_u); /* Don't touch the talloc context */
-
/* no initial methods */
user->methods = NULL;
/* Don't change these timestamp settings without a good reason.
They are important for NT member server compatibility. */
- user->private_u.logon_time = (time_t)0;
- user->private_u.pass_last_set_time = (time_t)0;
- user->private_u.pass_can_change_time = (time_t)0;
- user->private_u.logoff_time =
- user->private_u.kickoff_time =
- user->private_u.pass_must_change_time = get_time_t_max();
- user->private_u.fields_present = 0x00ffffff;
- user->private_u.logon_divs = 168; /* hours per week */
- user->private_u.hours_len = 21; /* 21 times 8 bits = 168 */
- memset(user->private_u.hours, 0xff, user->private_u.hours_len); /* available at all hours */
- user->private_u.bad_password_count = 0;
- user->private_u.logon_count = 0;
- user->private_u.unknown_6 = 0x000004ec; /* don't know */
+ user->logon_time = (time_t)0;
+ user->pass_last_set_time = (time_t)0;
+ user->pass_can_change_time = (time_t)0;
+ user->logoff_time =
+ user->kickoff_time =
+ user->pass_must_change_time = get_time_t_max();
+ user->fields_present = 0x00ffffff;
+ user->logon_divs = 168; /* hours per week */
+ user->hours_len = 21; /* 21 times 8 bits = 168 */
+ memset(user->hours, 0xff, user->hours_len); /* available at all hours */
+ user->bad_password_count = 0;
+ user->logon_count = 0;
+ user->unknown_6 = 0x000004ec; /* don't know */
/* Some parts of samba strlen their pdb_get...() returns,
so this keeps the interface unchanged for now. */
- user->private_u.username = "";
- user->private_u.domain = "";
- user->private_u.nt_username = "";
- user->private_u.full_name = "";
- user->private_u.home_dir = "";
- user->private_u.logon_script = "";
- user->private_u.profile_path = "";
- user->private_u.acct_desc = "";
- user->private_u.workstations = "";
- user->private_u.unknown_str = "";
- user->private_u.munged_dial = "";
-
- user->private_u.plaintext_pw = NULL;
+ user->username = "";
+ user->domain = "";
+ user->nt_username = "";
+ user->full_name = "";
+ user->home_dir = "";
+ user->logon_script = "";
+ user->profile_path = "";
+ user->acct_desc = "";
+ user->workstations = "";
+ user->unknown_str = "";
+ user->munged_dial = "";
+
+ user->plaintext_pw = NULL;
/*
Unless we know otherwise have a Account Control Bit
@@ -98,56 +96,70 @@ void pdb_fill_default_sam(SAM_ACCOUNT *user)
asks for a filtered list of users.
*/
- user->private_u.acct_ctrl = ACB_NORMAL;
+ user->acct_ctrl = ACB_NORMAL;
}
-static void destroy_pdb_talloc(SAM_ACCOUNT **user)
+/**********************************************************************
+***********************************************************************/
+
+static int samu_destroy(void *p)
{
- if (*user) {
- data_blob_clear_free(&((*user)->private_u.lm_pw));
- data_blob_clear_free(&((*user)->private_u.nt_pw));
+ struct samu *user = p;
- if((*user)->private_u.plaintext_pw!=NULL)
- memset((*user)->private_u.plaintext_pw,'\0',strlen((*user)->private_u.plaintext_pw));
- talloc_destroy((*user)->mem_ctx);
- *user = NULL;
- }
-}
+ data_blob_clear_free( &user->lm_pw );
+ data_blob_clear_free( &user->nt_pw );
+ if ( user->plaintext_pw )
+ memset( user->plaintext_pw, 0x0, strlen(user->plaintext_pw) );
+
+ return 0;
+}
/**********************************************************************
- Allocates memory and initialises a struct sam_passwd on supplied mem_ctx.
***********************************************************************/
-NTSTATUS pdb_init_sam_talloc(TALLOC_CTX *mem_ctx, SAM_ACCOUNT **user)
+BOOL samu_init( struct samu *user )
{
- if (*user != NULL) {
- DEBUG(0,("pdb_init_sam_talloc: SAM_ACCOUNT was non NULL\n"));
-#if 0
- smb_panic("non-NULL pointer passed to pdb_init_sam\n");
-#endif
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- if (!mem_ctx) {
- DEBUG(0,("pdb_init_sam_talloc: mem_ctx was NULL!\n"));
- return NT_STATUS_UNSUCCESSFUL;
- }
+ pdb_fill_default_sam( user );
+
+ return True;
+}
- *user=TALLOC_P(mem_ctx, SAM_ACCOUNT);
+/**********************************************************************
+ generate a new struct samuser
+***********************************************************************/
- if (*user==NULL) {
- DEBUG(0,("pdb_init_sam_talloc: error while allocating memory\n"));
- return NT_STATUS_NO_MEMORY;
+struct samu* samu_new( TALLOC_CTX *ctx )
+{
+ struct samu *user;
+
+ if ( !(user = TALLOC_ZERO_P( ctx, struct samu )) ) {
+ DEBUG(0,("samuser_new: Talloc failed!\n"));
+ return NULL;
}
+
+ if ( !samu_init( user ) ) {
+ DEBUG(0,("samuser_new: initialization failed!\n"));
+ TALLOC_FREE( user );
+ return NULL;
+ }
+
+ talloc_set_destructor( user, samu_destroy );
+
+ return user;
+}
- (*user)->mem_ctx = mem_ctx;
-
- (*user)->free_fn = NULL;
+/**********************************************************************
+ Allocates memory and initialises a struct sam_passwd on supplied mem_ctx.
+***********************************************************************/
- pdb_fill_default_sam(*user);
+NTSTATUS pdb_init_sam_talloc(TALLOC_CTX *mem_ctx, struct samu **user)
+{
+ if ( !*user )
+ return NT_STATUS_UNSUCCESSFUL;
- return NT_STATUS_OK;
+ *user = samu_new( mem_ctx );
+ return *user ? NT_STATUS_OK : NT_STATUS_NO_MEMORY;
}
@@ -155,26 +167,10 @@ NTSTATUS pdb_init_sam_talloc(TALLOC_CTX *mem_ctx, SAM_ACCOUNT **user)
Allocates memory and initialises a struct sam_passwd.
************************************************************/
-NTSTATUS pdb_init_sam(SAM_ACCOUNT **user)
+NTSTATUS pdb_init_sam(struct samu **user)
{
- TALLOC_CTX *mem_ctx;
- NTSTATUS nt_status;
-
- mem_ctx = talloc_init("passdb internal SAM_ACCOUNT allocation");
-
- if (!mem_ctx) {
- DEBUG(0,("pdb_init_sam: error while doing talloc_init()\n"));
- return NT_STATUS_NO_MEMORY;
- }
-
- if (!NT_STATUS_IS_OK(nt_status = pdb_init_sam_talloc(mem_ctx, user))) {
- talloc_destroy(mem_ctx);
- return nt_status;
- }
-
- (*user)->free_fn = destroy_pdb_talloc;
-
- return NT_STATUS_OK;
+ *user = samu_new( NULL );
+ return *user ? NT_STATUS_OK : NT_STATUS_NO_MEMORY;
}
/**************************************************************************
@@ -186,7 +182,7 @@ NTSTATUS pdb_init_sam(SAM_ACCOUNT **user)
* SSS
***************************************************************************/
-static NTSTATUS pdb_set_sam_sids(SAM_ACCOUNT *account_data, const struct passwd *pwd)
+static NTSTATUS pdb_set_sam_sids(struct samu *account_data, const struct passwd *pwd)
{
const char *guest_account = lp_guestaccount();
GROUP_MAP map;
@@ -256,7 +252,7 @@ static NTSTATUS pdb_set_sam_sids(SAM_ACCOUNT *account_data, const struct passwd
Initialises a struct sam_passwd with sane values.
************************************************************/
-NTSTATUS pdb_fill_sam_pw(SAM_ACCOUNT *sam_account, const struct passwd *pwd)
+NTSTATUS pdb_fill_sam_pw(struct samu *sam_account, const struct passwd *pwd)
{
NTSTATUS ret;
@@ -290,28 +286,28 @@ NTSTATUS pdb_fill_sam_pw(SAM_ACCOUNT *sam_account, const struct passwd *pwd)
if (pwd->pw_name[strlen(pwd->pw_name)-1] != '$')
{
pdb_set_profile_path(sam_account,
- talloc_sub_specified((sam_account)->mem_ctx,
+ talloc_sub_specified(sam_account,
lp_logon_path(),
pwd->pw_name, global_myname(),
pwd->pw_uid, pwd->pw_gid),
PDB_DEFAULT);
pdb_set_homedir(sam_account,
- talloc_sub_specified((sam_account)->mem_ctx,
+ talloc_sub_specified(sam_account,
lp_logon_home(),
pwd->pw_name, global_myname(),
pwd->pw_uid, pwd->pw_gid),
PDB_DEFAULT);
pdb_set_dir_drive(sam_account,
- talloc_sub_specified((sam_account)->mem_ctx,
+ talloc_sub_specified(sam_account,
lp_logon_drive(),
pwd->pw_name, global_myname(),
pwd->pw_uid, pwd->pw_gid),
PDB_DEFAULT);
pdb_set_logon_script(sam_account,
- talloc_sub_specified((sam_account)->mem_ctx,
+ talloc_sub_specified(sam_account,
lp_logon_script(),
pwd->pw_name, global_myname(),
pwd->pw_uid, pwd->pw_gid),
@@ -334,7 +330,7 @@ NTSTATUS pdb_fill_sam_pw(SAM_ACCOUNT *sam_account, const struct passwd *pwd)
Initialises a struct sam_passwd with sane values.
************************************************************/
-NTSTATUS pdb_init_sam_pw(SAM_ACCOUNT **new_sam_acct, const struct passwd *pwd)
+NTSTATUS pdb_init_sam_pw(struct samu **new_sam_acct, const struct passwd *pwd)
{
NTSTATUS nt_status;
@@ -349,7 +345,7 @@ NTSTATUS pdb_init_sam_pw(SAM_ACCOUNT **new_sam_acct, const struct passwd *pwd)
}
if (!NT_STATUS_IS_OK(nt_status = pdb_fill_sam_pw(*new_sam_acct, pwd))) {
- pdb_free_sam(new_sam_acct);
+ TALLOC_FREE(new_sam_acct);
new_sam_acct = NULL;
return nt_status;
}
@@ -359,11 +355,11 @@ NTSTATUS pdb_init_sam_pw(SAM_ACCOUNT **new_sam_acct, const struct passwd *pwd)
/*************************************************************
- Initialises a SAM_ACCOUNT 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
************************************************************/
-NTSTATUS pdb_init_sam_new(SAM_ACCOUNT **new_sam_acct, const char *username)
+NTSTATUS pdb_init_sam_new(struct samu **new_sam_acct, const char *username)
{
NTSTATUS result;
struct passwd *pwd;
@@ -481,7 +477,7 @@ NTSTATUS pdb_init_sam_new(SAM_ACCOUNT **new_sam_acct, const char *username)
done:
if (!NT_STATUS_IS_OK(result) && (*new_sam_acct != NULL)) {
- pdb_free_sam(new_sam_acct);
+ TALLOC_FREE(new_sam_acct);
}
TALLOC_FREE(mem_ctx);
@@ -489,77 +485,6 @@ NTSTATUS pdb_init_sam_new(SAM_ACCOUNT **new_sam_acct, const char *username)
}
-/**
- * Free the contets of the SAM_ACCOUNT, but not the structure.
- *
- * Also wipes the LM and NT hashes and plaintext password from
- * memory.
- *
- * @param user SAM_ACCOUNT to free members of.
- **/
-
-static void pdb_free_sam_contents(SAM_ACCOUNT *user)
-{
-
- /* Kill off sensitive data. Free()ed by the
- talloc mechinism */
-
- data_blob_clear_free(&(user->private_u.lm_pw));
- data_blob_clear_free(&(user->private_u.nt_pw));
- if (user->private_u.plaintext_pw!=NULL)
- memset(user->private_u.plaintext_pw,'\0',strlen(user->private_u.plaintext_pw));
-
- if (user->private_u.backend_private_data && user->private_u.backend_private_data_free_fn) {
- user->private_u.backend_private_data_free_fn(&user->private_u.backend_private_data);
- }
-}
-
-
-/************************************************************
- Reset the SAM_ACCOUNT and free the NT/LM hashes.
- ***********************************************************/
-
-NTSTATUS pdb_reset_sam(SAM_ACCOUNT *user)
-{
- if (user == NULL) {
- DEBUG(0,("pdb_reset_sam: SAM_ACCOUNT was NULL\n"));
-#if 0
- smb_panic("NULL pointer passed to pdb_free_sam\n");
-#endif
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- pdb_free_sam_contents(user);
-
- pdb_fill_default_sam(user);
-
- return NT_STATUS_OK;
-}
-
-
-/************************************************************
- Free the SAM_ACCOUNT and the member pointers.
- ***********************************************************/
-
-NTSTATUS pdb_free_sam(SAM_ACCOUNT **user)
-{
- if (*user == NULL) {
- DEBUG(0,("pdb_free_sam: SAM_ACCOUNT was NULL\n"));
-#if 0
- smb_panic("NULL pointer passed to pdb_free_sam\n");
-#endif
- return NT_STATUS_UNSUCCESSFUL;
- }
-
- pdb_free_sam_contents(*user);
-
- if ((*user)->free_fn) {
- (*user)->free_fn(user);
- }
-
- return NT_STATUS_OK;
-}
-
/**********************************************************
Encode the account control bits into a string.
length = length of string to encode into (including terminating
@@ -864,7 +789,7 @@ BOOL lookup_global_sam_name(const char *user, int flags, uint32_t *rid,
* is set, don't look for users at all. */
if ((flags & LOOKUP_NAME_GROUP) == 0) {
- SAM_ACCOUNT *sam_account = NULL;
+ struct samu *sam_account = NULL;
DOM_SID user_sid;
if (!NT_STATUS_IS_OK(pdb_init_sam(&sam_account))) {
@@ -879,7 +804,7 @@ BOOL lookup_global_sam_name(const char *user, int flags, uint32_t *rid,
sid_copy(&user_sid, pdb_get_user_sid(sam_account));
}
- pdb_free_sam(&sam_account);
+ TALLOC_FREE(sam_account);
if (ret) {
if (!sid_check_is_in_our_domain(&user_sid)) {
@@ -929,7 +854,7 @@ NTSTATUS local_password_change(const char *user_name, int local_flags,
char *err_str, size_t err_str_len,
char *msg_str, size_t msg_str_len)
{
- SAM_ACCOUNT *sam_pass=NULL;
+ struct samu *sam_pass=NULL;
uint16 other_acb;
NTSTATUS result;
@@ -942,7 +867,7 @@ NTSTATUS local_password_change(const char *user_name, int local_flags,
become_root();
if(!pdb_getsampwnam(sam_pass, user_name)) {
unbecome_root();
- pdb_free_sam(&sam_pass);
+ TALLOC_FREE(sam_pass);
if ((local_flags & LOCAL_ADD_USER) || (local_flags & LOCAL_DELETE_USER)) {
int tmp_debug = DEBUGLEVEL;
@@ -981,19 +906,19 @@ NTSTATUS local_password_change(const char *user_name, int local_flags,
if (local_flags & LOCAL_TRUST_ACCOUNT) {
if (!pdb_set_acct_ctrl(sam_pass, ACB_WSTRUST | other_acb, PDB_CHANGED) ) {
slprintf(err_str, err_str_len - 1, "Failed to set 'trusted workstation account' flags for user %s.\n", user_name);
- pdb_free_sam(&sam_pass);
+ TALLOC_FREE(sam_pass);
return NT_STATUS_UNSUCCESSFUL;
}
} else if (local_flags & LOCAL_INTERDOM_ACCOUNT) {
if (!pdb_set_acct_ctrl(sam_pass, ACB_DOMTRUST | other_acb, PDB_CHANGED)) {
slprintf(err_str, err_str_len - 1, "Failed to set 'domain trust account' flags for user %s.\n", user_name);
- pdb_free_sam(&sam_pass);
+ TALLOC_FREE(sam_pass);
return NT_STATUS_UNSUCCESSFUL;
}
} else {
if (!pdb_set_acct_ctrl(sam_pass, ACB_NORMAL | other_acb, PDB_CHANGED)) {
slprintf(err_str, err_str_len - 1, "Failed to set 'normal account' flags for user %s.\n", user_name);
- pdb_free_sam(&sam_pass);
+ TALLOC_FREE(sam_pass);
return NT_STATUS_UNSUCCESSFUL;
}
}
@@ -1006,13 +931,13 @@ NTSTATUS local_password_change(const char *user_name, int local_flags,
if (local_flags & LOCAL_DISABLE_USER) {
if (!pdb_set_acct_ctrl (sam_pass, pdb_get_acct_ctrl(sam_pass)|ACB_DISABLED, PDB_CHANGED)) {
slprintf(err_str, err_str_len-1, "Failed to set 'disabled' flag for user %s.\n", user_name);
- pdb_free_sam(&sam_pass);
+ TALLOC_FREE(sam_pass);
return NT_STATUS_UNSUCCESSFUL;
}
} else if (local_flags & LOCAL_ENABLE_USER) {
if (!pdb_set_acct_ctrl (sam_pass, pdb_get_acct_ctrl(sam_pass)&(~ACB_DISABLED), PDB_CHANGED)) {
slprintf(err_str, err_str_len-1, "Failed to unset 'disabled' flag for user %s.\n", user_name);
- pdb_free_sam(&sam_pass);
+ TALLOC_FREE(sam_pass);
return NT_STATUS_UNSUCCESSFUL;
}
}
@@ -1020,7 +945,7 @@ NTSTATUS local_password_change(const char *user_name, int local_flags,
if (local_flags & LOCAL_SET_NO_PASSWORD) {
if (!pdb_set_acct_ctrl (sam_pass, pdb_get_acct_ctrl(sam_pass)|ACB_PWNOTREQ, PDB_CHANGED)) {
slprintf(err_str, err_str_len-1, "Failed to set 'no password required' flag for user %s.\n", user_name);
- pdb_free_sam(&sam_pass);
+ TALLOC_FREE(sam_pass);
return NT_STATUS_UNSUCCESSFUL;
}
} else if (local_flags & LOCAL_SET_PASSWORD) {
@@ -1036,19 +961,19 @@ NTSTATUS local_password_change(const char *user_name, int local_flags,
if ((pdb_get_lanman_passwd(sam_pass)==NULL) && (pdb_get_acct_ctrl(sam_pass)&ACB_DISABLED)) {
if (!pdb_set_acct_ctrl (sam_pass, pdb_get_acct_ctrl(sam_pass)&(~ACB_DISABLED), PDB_CHANGED)) {
slprintf(err_str, err_str_len-1, "Failed to unset 'disabled' flag for user %s.\n", user_name);
- pdb_free_sam(&sam_pass);
+ TALLOC_FREE(sam_pass);
return NT_STATUS_UNSUCCESSFUL;
}
}
if (!pdb_set_acct_ctrl (sam_pass, pdb_get_acct_ctrl(sam_pass)&(~ACB_PWNOTREQ), PDB_CHANGED)) {
slprintf(err_str, err_str_len-1, "Failed to unset 'no password required' flag for user %s.\n", user_name);
- pdb_free_sam(&sam_pass);
+ TALLOC_FREE(sam_pass);
return NT_STATUS_UNSUCCESSFUL;
}
if (!pdb_set_plaintext_passwd (sam_pass, new_passwd)) {
slprintf(err_str, err_str_len-1, "Failed to set password for user %s.\n", user_name);
- pdb_free_sam(&sam_pass);
+ TALLOC_FREE(sam_pass);
return NT_STATUS_UNSUCCESSFUL;
}
}
@@ -1056,17 +981,17 @@ NTSTATUS local_password_change(const char *user_name, int local_flags,
if (local_flags & LOCAL_ADD_USER) {
if (NT_STATUS_IS_OK(pdb_add_sam_account(sam_pass))) {
slprintf(msg_str, msg_str_len-1, "Added user %s.\n", user_name);
- pdb_free_sam(&sam_pass);
+ TALLOC_FREE(sam_pass);
return NT_STATUS_OK;
} else {
slprintf(err_str, err_str_len-1, "Failed to add entry for user %s.\n", user_name);
- pdb_free_sam(&sam_pass);
+ TALLOC_FREE(sam_pass);
return NT_STATUS_UNSUCCESSFUL;
}
} else if (local_flags & LOCAL_DELETE_USER) {
if (!NT_STATUS_IS_OK(pdb_delete_sam_account(sam_pass))) {
slprintf(err_str,err_str_len-1, "Failed to delete entry for user %s.\n", user_name);
- pdb_free_sam(&sam_pass);
+ TALLOC_FREE(sam_pass);
return NT_STATUS_UNSUCCESSFUL;
}
slprintf(msg_str, msg_str_len-1, "Deleted user %s.\n", user_name);
@@ -1074,7 +999,7 @@ NTSTATUS local_password_change(const char *user_name, int local_flags,
result = pdb_update_sam_account(sam_pass);
if(!NT_STATUS_IS_OK(result)) {
slprintf(err_str, err_str_len-1, "Failed to modify entry for user %s.\n", user_name);
- pdb_free_sam(&sam_pass);
+ TALLOC_FREE(sam_pass);
return result;
}
if(local_flags & LOCAL_DISABLE_USER)
@@ -1085,12 +1010,12 @@ NTSTATUS local_password_change(const char *user_name, int local_flags,
slprintf(msg_str, msg_str_len-1, "User %s password set to none.\n", user_name);
}
- pdb_free_sam(&sam_pass);
+ TALLOC_FREE(sam_pass);
return NT_STATUS_OK;
}
/**********************************************************************
- Marshall/unmarshall SAM_ACCOUNT structs.
+ Marshall/unmarshall struct samu structs.
*********************************************************************/
#define TDB_FORMAT_STRING_V0 "ddddddBBBBBBBBBBBBddBBwdwdBwwd"
@@ -1098,25 +1023,25 @@ NTSTATUS local_password_change(const char *user_name, int local_flags,
#define TDB_FORMAT_STRING_V2 "dddddddBBBBBBBBBBBBddBBBwwdBwwd"
/**********************************************************************
- Intialize a SAM_ACCOUNT struct from a BYTE buffer of size len
+ Intialize a struct samu struct from a BYTE buffer of size len
*********************************************************************/
-BOOL init_sam_from_buffer(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
+BOOL init_sam_from_buffer(struct samu *sampass, uint8 *buf, uint32 buflen)
{
return(init_sam_from_buffer_v2(sampass, buf, buflen));
}
/**********************************************************************
- Intialize a BYTE buffer from a SAM_ACCOUNT struct
+ Intialize a BYTE buffer from a struct samu struct
*********************************************************************/
-uint32 init_buffer_from_sam (uint8 **buf, const SAM_ACCOUNT *sampass, BOOL size_only)
+uint32 init_buffer_from_sam (uint8 **buf, const struct samu *sampass, BOOL size_only)
{
return(init_buffer_from_sam_v2(buf, sampass, size_only));
}
-BOOL init_sam_from_buffer_v0(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
+BOOL init_sam_from_buffer_v0(struct samu *sampass, uint8 *buf, uint32 buflen)
{
/* times are stored as 32bit integer
@@ -1216,7 +1141,7 @@ BOOL init_sam_from_buffer_v0(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
}
else {
pdb_set_homedir(sampass,
- talloc_sub_basic(sampass->mem_ctx, username, lp_logon_home()),
+ talloc_sub_basic(sampass, username, lp_logon_home()),
PDB_DEFAULT);
}
@@ -1224,7 +1149,7 @@ BOOL init_sam_from_buffer_v0(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
pdb_set_dir_drive(sampass, dir_drive, PDB_SET);
else {
pdb_set_dir_drive(sampass,
- talloc_sub_basic(sampass->mem_ctx, username, lp_logon_drive()),
+ talloc_sub_basic(sampass, username, lp_logon_drive()),
PDB_DEFAULT);
}
@@ -1232,7 +1157,7 @@ BOOL init_sam_from_buffer_v0(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
pdb_set_logon_script(sampass, logon_script, PDB_SET);
else {
pdb_set_logon_script(sampass,
- talloc_sub_basic(sampass->mem_ctx, username, lp_logon_script()),
+ talloc_sub_basic(sampass, username, lp_logon_script()),
PDB_DEFAULT);
}
@@ -1240,7 +1165,7 @@ BOOL init_sam_from_buffer_v0(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
pdb_set_profile_path(sampass, profile_path, PDB_SET);
} else {
pdb_set_profile_path(sampass,
- talloc_sub_basic(sampass->mem_ctx, username, lp_logon_path()),
+ talloc_sub_basic(sampass, username, lp_logon_path()),
PDB_DEFAULT);
}
@@ -1294,7 +1219,7 @@ done:
return ret;
}
-BOOL init_sam_from_buffer_v1(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
+BOOL init_sam_from_buffer_v1(struct samu *sampass, uint8 *buf, uint32 buflen)
{
/* times are stored as 32bit integer
@@ -1400,7 +1325,7 @@ BOOL init_sam_from_buffer_v1(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
}
else {
pdb_set_homedir(sampass,
- talloc_sub_basic(sampass->mem_ctx, username, lp_logon_home()),
+ talloc_sub_basic(sampass, username, lp_logon_home()),
PDB_DEFAULT);
}
@@ -1408,7 +1333,7 @@ BOOL init_sam_from_buffer_v1(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
pdb_set_dir_drive(sampass, dir_drive, PDB_SET);
else {
pdb_set_dir_drive(sampass,
- talloc_sub_basic(sampass->mem_ctx, username, lp_logon_drive()),
+ talloc_sub_basic(sampass, username, lp_logon_drive()),
PDB_DEFAULT);
}
@@ -1416,7 +1341,7 @@ BOOL init_sam_from_buffer_v1(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
pdb_set_logon_script(sampass, logon_script, PDB_SET);
else {
pdb_set_logon_script(sampass,
- talloc_sub_basic(sampass->mem_ctx, username, lp_logon_script()),
+ talloc_sub_basic(sampass, username, lp_logon_script()),
PDB_DEFAULT);
}
@@ -1424,7 +1349,7 @@ BOOL init_sam_from_buffer_v1(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
pdb_set_profile_path(sampass, profile_path, PDB_SET);
} else {
pdb_set_profile_path(sampass,
- talloc_sub_basic(sampass->mem_ctx, username, lp_logon_path()),
+ talloc_sub_basic(sampass, username, lp_logon_path()),
PDB_DEFAULT);
}
@@ -1480,7 +1405,7 @@ done:
}
-BOOL init_sam_from_buffer_v2(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
+BOOL init_sam_from_buffer_v2(struct samu *sampass, uint8 *buf, uint32 buflen)
{
/* times are stored as 32bit integer
@@ -1593,7 +1518,7 @@ BOOL init_sam_from_buffer_v2(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
}
else {
pdb_set_homedir(sampass,
- talloc_sub_basic(sampass->mem_ctx, username, lp_logon_home()),
+ talloc_sub_basic(sampass, username, lp_logon_home()),
PDB_DEFAULT);
}
@@ -1612,7 +1537,7 @@ BOOL init_sam_from_buffer_v2(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
}
else {
pdb_set_logon_script(sampass,
- talloc_sub_basic(sampass->mem_ctx, username, lp_logon_script()),
+ talloc_sub_basic(sampass, username, lp_logon_script()),
PDB_DEFAULT);
}
@@ -1626,7 +1551,7 @@ BOOL init_sam_from_buffer_v2(SAM_ACCOUNT *sampass, uint8 *buf, uint32 buflen)
}
else {
pdb_set_profile_path(sampass,
- talloc_sub_basic(sampass->mem_ctx, username, lp_logon_path()),
+ talloc_sub_basic(sampass, username, lp_logon_path()),
PDB_DEFAULT);
}
@@ -1709,7 +1634,7 @@ done:
return ret;
}
-uint32 init_buffer_from_sam_v2 (uint8 **buf, const SAM_ACCOUNT *sampass, BOOL size_only)
+uint32 init_buffer_from_sam_v2 (uint8 **buf, const struct samu *sampass, BOOL size_only)
{
size_t len, buflen;
@@ -1751,9 +1676,9 @@ uint32 init_buffer_from_sam_v2 (uint8 **buf, const SAM_ACCOUNT *sampass, BOOL si
uint32 nt_pw_hist_len;
uint32 pwHistLen = 0;
- /* do we have a valid SAM_ACCOUNT pointer? */
+ /* do we have a valid struct samu pointer? */
if (sampass == NULL) {
- DEBUG(0, ("init_buffer_from_sam: SAM_ACCOUNT is NULL!\n"));
+ DEBUG(0, ("init_buffer_from_sam: struct samu is NULL!\n"));
return -1;
}
@@ -1981,7 +1906,7 @@ uint32 init_buffer_from_sam_v2 (uint8 **buf, const SAM_ACCOUNT *sampass, BOOL si
return (buflen);
}
-BOOL pdb_copy_sam_account(const SAM_ACCOUNT *src, SAM_ACCOUNT **dst)
+BOOL pdb_copy_sam_account(const struct samu *src, struct samu **dst)
{
BOOL result;
uint8 *buf;
@@ -2007,7 +1932,7 @@ BOOL pdb_copy_sam_account(const SAM_ACCOUNT *src, SAM_ACCOUNT **dst)
Update the bad password count checking the AP_RESET_COUNT_TIME
*********************************************************************/
-BOOL pdb_update_bad_password_count(SAM_ACCOUNT *sampass, BOOL *updated)
+BOOL pdb_update_bad_password_count(struct samu *sampass, BOOL *updated)
{
time_t LastBadPassword;
uint16 BadPasswordCount;
@@ -2050,7 +1975,7 @@ BOOL pdb_update_bad_password_count(SAM_ACCOUNT *sampass, BOOL *updated)
Update the ACB_AUTOLOCK flag checking the AP_LOCK_ACCOUNT_DURATION
*********************************************************************/
-BOOL pdb_update_autolock_flag(SAM_ACCOUNT *sampass, BOOL *updated)
+BOOL pdb_update_autolock_flag(struct samu *sampass, BOOL *updated)
{
uint32 duration;
time_t LastBadPassword;
@@ -2103,7 +2028,7 @@ bad password time. Leaving locked out.\n",
Increment the bad_password_count
*********************************************************************/
-BOOL pdb_increment_bad_password_count(SAM_ACCOUNT *sampass)
+BOOL pdb_increment_bad_password_count(struct samu *sampass)
{
uint32 account_policy_lockout;
BOOL autolock_updated = False, badpw_updated = False;
diff --git a/source3/passdb/pdb_compat.c b/source3/passdb/pdb_compat.c
index abd572a7c1..900fcc29fa 100644
--- a/source3/passdb/pdb_compat.c
+++ b/source3/passdb/pdb_compat.c
@@ -1,6 +1,6 @@
/*
Unix SMB/CIFS implementation.
- SAM_ACCOUNT access routines
+ struct samu access routines
Copyright (C) Jeremy Allison 1996-2001
Copyright (C) Luke Kenneth Casson Leighton 1996-1998
Copyright (C) Gerald (Jerry) Carter 2000-2001
@@ -27,7 +27,7 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_PASSDB
-uint32 pdb_get_user_rid (const SAM_ACCOUNT *sampass)
+uint32 pdb_get_user_rid (const struct samu *sampass)
{
uint32 u_rid;
@@ -38,7 +38,7 @@ uint32 pdb_get_user_rid (const SAM_ACCOUNT *sampass)
return (0);
}
-uint32 pdb_get_group_rid (const SAM_ACCOUNT *sampass)
+uint32 pdb_get_group_rid (const struct samu *sampass)
{
uint32 g_rid;
@@ -48,7 +48,7 @@ uint32 pdb_get_group_rid (const SAM_ACCOUNT *sampass)
return (0);
}
-BOOL pdb_set_user_sid_from_rid (SAM_ACCOUNT *sampass, uint32 rid, enum pdb_value_state flag)
+BOOL pdb_set_user_sid_from_rid (struct samu *sampass, uint32 rid, enum pdb_value_state flag)
{
DOM_SID u_sid;
const DOM_SID *global_sam_sid;
@@ -75,7 +75,7 @@ BOOL pdb_set_user_sid_from_rid (SAM_ACCOUNT *sampass, uint32 rid, enum pdb_value
return True;
}
-BOOL pdb_set_group_sid_from_rid (SAM_ACCOUNT *sampass, uint32 grid, enum pdb_value_state flag)
+BOOL pdb_set_group_sid_from_rid (struct samu *sampass, uint32 grid, enum pdb_value_state flag)
{
DOM_SID g_sid;
const DOM_SID *global_sam_sid;
diff --git a/source3/passdb/pdb_get_set.c b/source3/passdb/pdb_get_set.c
index 046e658d2b..c39eb71162 100644
--- a/source3/passdb/pdb_get_set.c
+++ b/source3/passdb/pdb_get_set.c
@@ -1,6 +1,6 @@
/*
Unix SMB/CIFS implementation.
- SAM_ACCOUNT access routines
+ struct samu access routines
Copyright (C) Jeremy Allison 1996-2001
Copyright (C) Luke Kenneth Casson Leighton 1996-1998
Copyright (C) Gerald (Jerry) Carter 2000-2001
@@ -37,126 +37,126 @@
#define PDB_NOT_QUITE_NULL ""
/*********************************************************************
- Collection of get...() functions for SAM_ACCOUNT.
+ Collection of get...() functions for struct samu.
********************************************************************/
-uint16 pdb_get_acct_ctrl (const SAM_ACCOUNT *sampass)
+uint16 pdb_get_acct_ctrl (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.acct_ctrl);
+ return (sampass->acct_ctrl);
else
return (ACB_DISABLED);
}
-time_t pdb_get_logon_time (const SAM_ACCOUNT *sampass)
+time_t pdb_get_logon_time (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.logon_time);
+ return (sampass->logon_time);
else
return (0);
}
-time_t pdb_get_logoff_time (const SAM_ACCOUNT *sampass)
+time_t pdb_get_logoff_time (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.logoff_time);
+ return (sampass->logoff_time);
else
return (-1);
}
-time_t pdb_get_kickoff_time (const SAM_ACCOUNT *sampass)
+time_t pdb_get_kickoff_time (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.kickoff_time);
+ return (sampass->kickoff_time);
else
return (-1);
}
-time_t pdb_get_bad_password_time (const SAM_ACCOUNT *sampass)
+time_t pdb_get_bad_password_time (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.bad_password_time);
+ return (sampass->bad_password_time);
else
return (-1);
}
-time_t pdb_get_pass_last_set_time (const SAM_ACCOUNT *sampass)
+time_t pdb_get_pass_last_set_time (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.pass_last_set_time);
+ return (sampass->pass_last_set_time);
else
return (-1);
}
-time_t pdb_get_pass_can_change_time (const SAM_ACCOUNT *sampass)
+time_t pdb_get_pass_can_change_time (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.pass_can_change_time);
+ return (sampass->pass_can_change_time);
else
return (-1);
}
-time_t pdb_get_pass_must_change_time (const SAM_ACCOUNT *sampass)
+time_t pdb_get_pass_must_change_time (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.pass_must_change_time);
+ return (sampass->pass_must_change_time);
else
return (-1);
}
-uint16 pdb_get_logon_divs (const SAM_ACCOUNT *sampass)
+uint16 pdb_get_logon_divs (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.logon_divs);
+ return (sampass->logon_divs);
else
return (-1);
}
-uint32 pdb_get_hours_len (const SAM_ACCOUNT *sampass)
+uint32 pdb_get_hours_len (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.hours_len);
+ return (sampass->hours_len);
else
return (-1);
}
-const uint8* pdb_get_hours (const SAM_ACCOUNT *sampass)
+const uint8* pdb_get_hours (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.hours);
+ return (sampass->hours);
else
return (NULL);
}
-const uint8* pdb_get_nt_passwd (const SAM_ACCOUNT *sampass)
+const uint8* pdb_get_nt_passwd (const struct samu *sampass)
{
if (sampass) {
- SMB_ASSERT((!sampass->private_u.nt_pw.data)
- || sampass->private_u.nt_pw.length == NT_HASH_LEN);
- return ((uint8*)sampass->private_u.nt_pw.data);
+ SMB_ASSERT((!sampass->nt_pw.data)
+ || sampass->nt_pw.length == NT_HASH_LEN);
+ return ((uint8*)sampass->nt_pw.data);
}
else
return (NULL);
}
-const uint8* pdb_get_lanman_passwd (const SAM_ACCOUNT *sampass)
+const uint8* pdb_get_lanman_passwd (const struct samu *sampass)
{
if (sampass) {
- SMB_ASSERT((!sampass->private_u.lm_pw.data)
- || sampass->private_u.lm_pw.length == LM_HASH_LEN);
- return ((uint8*)sampass->private_u.lm_pw.data);
+ SMB_ASSERT((!sampass->lm_pw.data)
+ || sampass->lm_pw.length == LM_HASH_LEN);
+ return ((uint8*)sampass->lm_pw.data);
}
else
return (NULL);
}
-const uint8* pdb_get_pw_history (const SAM_ACCOUNT *sampass, uint32 *current_hist_len)
+const uint8* pdb_get_pw_history (const struct samu *sampass, uint32 *current_hist_len)
{
if (sampass) {
- SMB_ASSERT((!sampass->private_u.nt_pw_his.data)
- || ((sampass->private_u.nt_pw_his.length % PW_HISTORY_ENTRY_LEN) == 0));
- *current_hist_len = sampass->private_u.nt_pw_his.length / PW_HISTORY_ENTRY_LEN;
- return ((uint8*)sampass->private_u.nt_pw_his.data);
+ SMB_ASSERT((!sampass->nt_pw_his.data)
+ || ((sampass->nt_pw_his.length % PW_HISTORY_ENTRY_LEN) == 0));
+ *current_hist_len = sampass->nt_pw_his.length / PW_HISTORY_ENTRY_LEN;
+ return ((uint8*)sampass->nt_pw_his.data);
} else {
*current_hist_len = 0;
return (NULL);
@@ -169,49 +169,49 @@ const uint8* pdb_get_pw_history (const SAM_ACCOUNT *sampass, uint32 *current_his
Used to pass the plaintext to passdb backends that might
want to store more than just the NTLM hashes.
*/
-const char* pdb_get_plaintext_passwd (const SAM_ACCOUNT *sampass)
+const char* pdb_get_plaintext_passwd (const struct samu *sampass)
{
if (sampass) {
- return (sampass->private_u.plaintext_pw);
+ return (sampass->plaintext_pw);
}
else
return (NULL);
}
-const DOM_SID *pdb_get_user_sid(const SAM_ACCOUNT *sampass)
+const DOM_SID *pdb_get_user_sid(const struct samu *sampass)
{
if (sampass)
- return &sampass->private_u.user_sid;
+ return &sampass->user_sid;
else
return (NULL);
}
-const DOM_SID *pdb_get_group_sid(const SAM_ACCOUNT *sampass)
+const DOM_SID *pdb_get_group_sid(const struct samu *sampass)
{
if (sampass)
- return &sampass->private_u.group_sid;
+ return &sampass->group_sid;
else
return (NULL);
}
/**
- * Get flags showing what is initalised in the SAM_ACCOUNT
- * @param sampass the SAM_ACCOUNT in question
+ * Get flags showing what is initalised in the struct samu
+ * @param sampass the struct samu in question
* @return the flags indicating the members initialised in the struct.
**/
-enum pdb_value_state pdb_get_init_flags (const SAM_ACCOUNT *sampass, enum pdb_elements element)
+enum pdb_value_state pdb_get_init_flags (const struct samu *sampass, enum pdb_elements element)
{
enum pdb_value_state ret = PDB_DEFAULT;
- if (!sampass || !sampass->private_u.change_flags || !sampass->private_u.set_flags)
+ if (!sampass || !sampass->change_flags || !sampass->set_flags)
return ret;
- if (bitmap_query(sampass->private_u.set_flags, element)) {
+ if (bitmap_query(sampass->set_flags, element)) {
DEBUG(11, ("element %d: SET\n", element));
ret = PDB_SET;
}
- if (bitmap_query(sampass->private_u.change_flags, element)) {
+ if (bitmap_query(sampass->change_flags, element)) {
DEBUG(11, ("element %d: CHANGED\n", element));
ret = PDB_CHANGED;
}
@@ -223,270 +223,270 @@ enum pdb_value_state pdb_get_init_flags (const SAM_ACCOUNT *sampass, enum pdb_el
return ret;
}
-const char* pdb_get_username (const SAM_ACCOUNT *sampass)
+const char* pdb_get_username (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.username);
+ return (sampass->username);
else
return (NULL);
}
-const char* pdb_get_domain (const SAM_ACCOUNT *sampass)
+const char* pdb_get_domain (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.domain);
+ return (sampass->domain);
else
return (NULL);
}
-const char* pdb_get_nt_username (const SAM_ACCOUNT *sampass)
+const char* pdb_get_nt_username (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.nt_username);
+ return (sampass->nt_username);
else
return (NULL);
}
-const char* pdb_get_fullname (const SAM_ACCOUNT *sampass)
+const char* pdb_get_fullname (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.full_name);
+ return (sampass->full_name);
else
return (NULL);
}
-const char* pdb_get_homedir (const SAM_ACCOUNT *sampass)
+const char* pdb_get_homedir (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.home_dir);
+ return (sampass->home_dir);
else
return (NULL);
}
-const char* pdb_get_unix_homedir (const SAM_ACCOUNT *sampass)
+const char* pdb_get_unix_homedir (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.unix_home_dir);
+ return (sampass->unix_home_dir);
else
return (NULL);
}
-const char* pdb_get_dir_drive (const SAM_ACCOUNT *sampass)
+const char* pdb_get_dir_drive (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.dir_drive);
+ return (sampass->dir_drive);
else
return (NULL);
}
-const char* pdb_get_logon_script (const SAM_ACCOUNT *sampass)
+const char* pdb_get_logon_script (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.logon_script);
+ return (sampass->logon_script);
else
return (NULL);
}
-const char* pdb_get_profile_path (const SAM_ACCOUNT *sampass)
+const char* pdb_get_profile_path (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.profile_path);
+ return (sampass->profile_path);
else
return (NULL);
}
-const char* pdb_get_acct_desc (const SAM_ACCOUNT *sampass)
+const char* pdb_get_acct_desc (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.acct_desc);
+ return (sampass->acct_desc);
else
return (NULL);
}
-const char* pdb_get_workstations (const SAM_ACCOUNT *sampass)
+const char* pdb_get_workstations (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.workstations);
+ return (sampass->workstations);
else
return (NULL);
}
-const char* pdb_get_unknown_str (const SAM_ACCOUNT *sampass)
+const char* pdb_get_unknown_str (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.unknown_str);
+ return (sampass->unknown_str);
else
return (NULL);
}
-const char* pdb_get_munged_dial (const SAM_ACCOUNT *sampass)
+const char* pdb_get_munged_dial (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.munged_dial);
+ return (sampass->munged_dial);
else
return (NULL);
}
-uint16 pdb_get_bad_password_count(const SAM_ACCOUNT *sampass)
+uint16 pdb_get_bad_password_count(const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.bad_password_count);
+ return (sampass->bad_password_count);
else
return 0;
}
-uint16 pdb_get_logon_count(const SAM_ACCOUNT *sampass)
+uint16 pdb_get_logon_count(const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.logon_count);
+ return (sampass->logon_count);
else
return 0;
}
-uint32 pdb_get_unknown_6 (const SAM_ACCOUNT *sampass)
+uint32 pdb_get_unknown_6 (const struct samu *sampass)
{
if (sampass)
- return (sampass->private_u.unknown_6);
+ return (sampass->unknown_6);
else
return (-1);
}
-void *pdb_get_backend_private_data (const SAM_ACCOUNT *sampass, const struct pdb_methods *my_methods)
+void *pdb_get_backend_private_data (const struct samu *sampass, const struct pdb_methods *my_methods)
{
- if (sampass && my_methods == sampass->private_u.backend_private_methods)
- return sampass->private_u.backend_private_data;
+ if (sampass && my_methods == sampass->backend_private_methods)
+ return sampass->backend_private_data;
else
return NULL;
}
/*********************************************************************
- Collection of set...() functions for SAM_ACCOUNT.
+ Collection of set...() functions for struct samu.
********************************************************************/
-BOOL pdb_set_acct_ctrl (SAM_ACCOUNT *sampass, uint16 acct_ctrl, enum pdb_value_state flag)
+BOOL pdb_set_acct_ctrl (struct samu *sampass, uint16 acct_ctrl, enum pdb_value_state flag)
{
if (!sampass)
return False;
- sampass->private_u.acct_ctrl = acct_ctrl;
+ sampass->acct_ctrl = acct_ctrl;
return pdb_set_init_flags(sampass, PDB_ACCTCTRL, flag);
}
-BOOL pdb_set_logon_time (SAM_ACCOUNT *sampass, time_t mytime, enum pdb_value_state flag)
+BOOL pdb_set_logon_time (struct samu *sampass, time_t mytime, enum pdb_value_state flag)
{
if (!sampass)
return False;
- sampass->private_u.logon_time = mytime;
+ sampass->logon_time = mytime;
return pdb_set_init_flags(sampass, PDB_LOGONTIME, flag);
}
-BOOL pdb_set_logoff_time (SAM_ACCOUNT *sampass, time_t mytime, enum pdb_value_state flag)
+BOOL pdb_set_logoff_time (struct samu *sampass, time_t mytime, enum pdb_value_state flag)
{
if (!sampass)
return False;
- sampass->private_u.logoff_time = mytime;
+ sampass->logoff_time = mytime;
return pdb_set_init_flags(sampass, PDB_LOGOFFTIME, flag);
}
-BOOL pdb_set_kickoff_time (SAM_ACCOUNT *sampass, time_t mytime, enum pdb_value_state flag)
+BOOL pdb_set_kickoff_time (struct samu *sampass, time_t mytime, enum pdb_value_state flag)
{
if (!sampass)
return False;
- sampass->private_u.kickoff_time = mytime;
+ sampass->kickoff_time = mytime;
return pdb_set_init_flags(sampass, PDB_KICKOFFTIME, flag);
}
-BOOL pdb_set_bad_password_time (SAM_ACCOUNT *sampass, time_t mytime,
+BOOL pdb_set_bad_password_time (struct samu *sampass, time_t mytime,
enum pdb_value_state flag)
{
if (!sampass)
return False;
- sampass->private_u.bad_password_time = mytime;
+ sampass->bad_password_time = mytime;
return pdb_set_init_flags(sampass, PDB_BAD_PASSWORD_TIME, flag);
}
-BOOL pdb_set_pass_can_change_time (SAM_ACCOUNT *sampass, time_t mytime, enum pdb_value_state flag)
+BOOL pdb_set_pass_can_change_time (struct samu *sampass, time_t mytime, enum pdb_value_state flag)
{
if (!sampass)
return False;
- sampass->private_u.pass_can_change_time = mytime;
+ sampass->pass_can_change_time = mytime;
return pdb_set_init_flags(sampass, PDB_CANCHANGETIME, flag);
}
-BOOL pdb_set_pass_must_change_time (SAM_ACCOUNT *sampass, time_t mytime, enum pdb_value_state flag)
+BOOL pdb_set_pass_must_change_time (struct samu *sampass, time_t mytime, enum pdb_value_state flag)
{
if (!sampass)
return False;
- sampass->private_u.pass_must_change_time = mytime;
+ sampass->pass_must_change_time = mytime;
return pdb_set_init_flags(sampass, PDB_MUSTCHANGETIME, flag);
}
-BOOL pdb_set_pass_last_set_time (SAM_ACCOUNT *sampass, time_t mytime, enum pdb_value_state flag)
+BOOL pdb_set_pass_last_set_time (struct samu *sampass, time_t mytime, enum pdb_value_state flag)
{
if (!sampass)
return False;
- sampass->private_u.pass_last_set_time = mytime;
+ sampass->pass_last_set_time = mytime;
return pdb_set_init_flags(sampass, PDB_PASSLASTSET, flag);
}
-BOOL pdb_set_hours_len (SAM_ACCOUNT *sampass, uint32 len, enum pdb_value_state flag)
+BOOL pdb_set_hours_len (struct samu *sampass, uint32 len, enum pdb_value_state flag)
{
if (!sampass)
return False;
- sampass->private_u.hours_len = len;
+ sampass->hours_len = len;
return pdb_set_init_flags(sampass, PDB_HOURSLEN, flag);
}
-BOOL pdb_set_logon_divs (SAM_ACCOUNT *sampass, uint16 hours, enum pdb_value_state flag)
+BOOL pdb_set_logon_divs (struct samu *sampass, uint16 hours, enum pdb_value_state flag)
{
if (!sampass)
return False;
- sampass->private_u.logon_divs = hours;
+ sampass->logon_divs = hours;
return pdb_set_init_flags(sampass, PDB_LOGONDIVS, flag);
}
/**
- * Set flags showing what is initalised in the SAM_ACCOUNT
- * @param sampass the SAM_ACCOUNT in question
+ * Set flags showing what is initalised in the struct samu
+ * @param sampass the struct samu in question
* @param flag The *new* flag to be set. Old flags preserved
* this flag is only added.
**/
-BOOL pdb_set_init_flags (SAM_ACCOUNT *sampass, enum pdb_elements element, enum pdb_value_state value_flag)
+BOOL pdb_set_init_flags (struct samu *sampass, enum pdb_elements element, enum pdb_value_state value_flag)
{
- if (!sampass || !sampass->mem_ctx)
+ if (!sampass || !sampass)
return False;
- if (!sampass->private_u.set_flags) {
- if ((sampass->private_u.set_flags =
- bitmap_talloc(sampass->mem_ctx,
+ if (!sampass->set_flags) {
+ if ((sampass->set_flags =
+ bitmap_talloc(sampass,
PDB_COUNT))==NULL) {
DEBUG(0,("bitmap_talloc failed\n"));
return False;
}
}
- if (!sampass->private_u.change_flags) {
- if ((sampass->private_u.change_flags =
- bitmap_talloc(sampass->mem_ctx,
+ if (!sampass->change_flags) {
+ if ((sampass->change_flags =
+ bitmap_talloc(sampass,
PDB_COUNT))==NULL) {
DEBUG(0,("bitmap_talloc failed\n"));
return False;
@@ -495,22 +495,22 @@ BOOL pdb_set_init_flags (SAM_ACCOUNT *sampass, enum pdb_elements element, enum p
switch(value_flag) {
case PDB_CHANGED:
- if (!bitmap_set(sampass->private_u.change_flags, element)) {
+ if (!bitmap_set(sampass->change_flags, element)) {
DEBUG(0,("Can't set flag: %d in change_flags.\n",element));
return False;
}
- if (!bitmap_set(sampass->private_u.set_flags, element)) {
+ if (!bitmap_set(sampass->set_flags, element)) {
DEBUG(0,("Can't set flag: %d in set_flags.\n",element));
return False;
}
DEBUG(11, ("element %d -> now CHANGED\n", element));
break;
case PDB_SET:
- if (!bitmap_clear(sampass->private_u.change_flags, element)) {
+ if (!bitmap_clear(sampass->change_flags, element)) {
DEBUG(0,("Can't set flag: %d in change_flags.\n",element));
return False;
}
- if (!bitmap_set(sampass->private_u.set_flags, element)) {
+ if (!bitmap_set(sampass->set_flags, element)) {
DEBUG(0,("Can't set flag: %d in set_flags.\n",element));
return False;
}
@@ -518,11 +518,11 @@ BOOL pdb_set_init_flags (SAM_ACCOUNT *sampass, enum pdb_elements element, enum p
break;
case PDB_DEFAULT:
default:
- if (!bitmap_clear(sampass->private_u.change_flags, element)) {
+ if (!bitmap_clear(sampass->change_flags, element)) {
DEBUG(0,("Can't set flag: %d in change_flags.\n",element));
return False;
}
- if (!bitmap_clear(sampass->private_u.set_flags, element)) {
+ if (!bitmap_clear(sampass->set_flags, element)) {
DEBUG(0,("Can't set flag: %d in set_flags.\n",element));
return False;
}
@@ -533,20 +533,20 @@ BOOL pdb_set_init_flags (SAM_ACCOUNT *sampass, enum pdb_elements element, enum p
return True;
}
-BOOL pdb_set_user_sid (SAM_ACCOUNT *sampass, const DOM_SID *u_sid, enum pdb_value_state flag)
+BOOL pdb_set_user_sid (struct samu *sampass, const DOM_SID *u_sid, enum pdb_value_state flag)
{
if (!sampass || !u_sid)
return False;
- sid_copy(&sampass->private_u.user_sid, u_sid);
+ sid_copy(&sampass->user_sid, u_sid);
DEBUG(10, ("pdb_set_user_sid: setting user sid %s\n",
- sid_string_static(&sampass->private_u.user_sid)));
+ sid_string_static(&sampass->user_sid)));
return pdb_set_init_flags(sampass, PDB_USERSID, flag);
}
-BOOL pdb_set_user_sid_from_string (SAM_ACCOUNT *sampass, fstring u_sid, enum pdb_value_state flag)
+BOOL pdb_set_user_sid_from_string (struct samu *sampass, fstring u_sid, enum pdb_value_state flag)
{
DOM_SID new_sid;
@@ -562,14 +562,14 @@ BOOL pdb_set_user_sid_from_string (SAM_ACCOUNT *sampass, fstring u_sid, enum pdb
}
if (!pdb_set_user_sid(sampass, &new_sid, flag)) {
- DEBUG(1, ("pdb_set_user_sid_from_string: could not set sid %s on SAM_ACCOUNT!\n", u_sid));
+ DEBUG(1, ("pdb_set_user_sid_from_string: could not set sid %s on struct samu!\n", u_sid));
return False;
}
return True;
}
-BOOL pdb_set_group_sid (SAM_ACCOUNT *sampass, const DOM_SID *g_sid, enum pdb_value_state flag)
+BOOL pdb_set_group_sid (struct samu *sampass, const DOM_SID *g_sid, enum pdb_value_state flag)
{
gid_t gid;
@@ -580,19 +580,19 @@ BOOL pdb_set_group_sid (SAM_ACCOUNT *sampass, const DOM_SID *g_sid, enum pdb_val
store DOMAIN_USERS as the primary groupSID */
if ( sid_to_gid( g_sid, &gid ) ) {
- sid_copy(&sampass->private_u.group_sid, g_sid);
+ sid_copy(&sampass->group_sid, g_sid);
} else {
- sid_copy( &sampass->private_u.group_sid, get_global_sam_sid() );
- sid_append_rid( &sampass->private_u.group_sid, DOMAIN_GROUP_RID_USERS );
+ sid_copy( &sampass->group_sid, get_global_sam_sid() );
+ sid_append_rid( &sampass->group_sid, DOMAIN_GROUP_RID_USERS );
}
DEBUG(10, ("pdb_set_group_sid: setting group sid %s\n",
- sid_string_static(&sampass->private_u.group_sid)));
+ sid_string_static(&sampass->group_sid)));
return pdb_set_init_flags(sampass, PDB_GROUPSID, flag);
}
-BOOL pdb_set_group_sid_from_string (SAM_ACCOUNT *sampass, fstring g_sid, enum pdb_value_state flag)
+BOOL pdb_set_group_sid_from_string (struct samu *sampass, fstring g_sid, enum pdb_value_state flag)
{
DOM_SID new_sid;
if (!sampass || !g_sid)
@@ -607,7 +607,7 @@ BOOL pdb_set_group_sid_from_string (SAM_ACCOUNT *sampass, fstring g_sid, enum pd
}
if (!pdb_set_group_sid(sampass, &new_sid, flag)) {
- DEBUG(1, ("pdb_set_group_sid_from_string: could not set sid %s on SAM_ACCOUNT!\n", g_sid));
+ DEBUG(1, ("pdb_set_group_sid_from_string: could not set sid %s on struct samu!\n", g_sid));
return False;
}
return True;
@@ -617,24 +617,24 @@ BOOL pdb_set_group_sid_from_string (SAM_ACCOUNT *sampass, fstring g_sid, enum pd
Set the user's UNIX name.
********************************************************************/
-BOOL pdb_set_username(SAM_ACCOUNT *sampass, const char *username, enum pdb_value_state flag)
+BOOL pdb_set_username(struct samu *sampass, const char *username, enum pdb_value_state flag)
{
if (!sampass)
return False;
if (username) {
DEBUG(10, ("pdb_set_username: setting username %s, was %s\n", username,
- (sampass->private_u.username)?(sampass->private_u.username):"NULL"));
+ (sampass->username)?(sampass->username):"NULL"));
- sampass->private_u.username = talloc_strdup(sampass->mem_ctx, username);
+ sampass->username = talloc_strdup(sampass, username);
- if (!sampass->private_u.username) {
+ if (!sampass->username) {
DEBUG(0, ("pdb_set_username: talloc_strdup() failed!\n"));
return False;
}
} else {
- sampass->private_u.username = PDB_NOT_QUITE_NULL;
+ sampass->username = PDB_NOT_QUITE_NULL;
}
return pdb_set_init_flags(sampass, PDB_USERNAME, flag);
@@ -644,24 +644,24 @@ BOOL pdb_set_username(SAM_ACCOUNT *sampass, const char *username, enum pdb_value
Set the domain name.
********************************************************************/
-BOOL pdb_set_domain(SAM_ACCOUNT *sampass, const char *domain, enum pdb_value_state flag)
+BOOL pdb_set_domain(struct samu *sampass, const char *domain, enum pdb_value_state flag)
{
if (!sampass)
return False;
if (domain) {
DEBUG(10, ("pdb_set_domain: setting domain %s, was %s\n", domain,
- (sampass->private_u.domain)?(sampass->private_u.domain):"NULL"));
+ (sampass->domain)?(sampass->domain):"NULL"));
- sampass->private_u.domain = talloc_strdup(sampass->mem_ctx, domain);
+ sampass->domain = talloc_strdup(sampass, domain);
- if (!sampass->private_u.domain) {
+ if (!sampass->domain) {
DEBUG(0, ("pdb_set_domain: talloc_strdup() failed!\n"));
return False;
}
} else {
- sampass->private_u.domain = PDB_NOT_QUITE_NULL;
+ sampass->domain = PDB_NOT_QUITE_NULL;
}
return pdb_set_init_flags(sampass, PDB_DOMAIN, flag);
@@ -671,24 +671,24 @@ BOOL pdb_set_domain(SAM_ACCOUNT *sampass, const char *domain, enum pdb_value_sta
Set the user's NT name.
********************************************************************/
-BOOL pdb_set_nt_username(SAM_ACCOUNT *sampass, const char *nt_username, enum pdb_value_state flag)
+BOOL pdb_set_nt_username(struct samu *sampass, const char *nt_username, enum pdb_value_state flag)
{
if (!sampass)
return False;
if (nt_username) {
DEBUG(10, ("pdb_set_nt_username: setting nt username %s, was %s\n", nt_username,
- (sampass->private_u.nt_username)?(sampass->private_u.nt_username):"NULL"));
+ (sampass->nt_username)?(sampass->nt_username):"NULL"));
- sampass->private_u.nt_username = talloc_strdup(sampass->mem_ctx, nt_username);
+ sampass->nt_username = talloc_strdup(sampass, nt_username);
- if (!sampass->private_u.nt_username) {
+ if (!sampass->nt_username) {
DEBUG(0, ("pdb_set_nt_username: talloc_strdup() failed!\n"));
return False;
}
} else {
- sampass->private_u.nt_username = PDB_NOT_QUITE_NULL;
+ sampass->nt_username = PDB_NOT_QUITE_NULL;
}
return pdb_set_init_flags(sampass, PDB_NTUSERNAME, flag);
@@ -698,24 +698,24 @@ BOOL pdb_set_nt_username(SAM_ACCOUNT *sampass, const char *nt_username, enum pdb
Set the user's full name.
********************************************************************/
-BOOL pdb_set_fullname(SAM_ACCOUNT *sampass, const char *full_name, enum pdb_value_state flag)
+BOOL pdb_set_fullname(struct samu *sampass, const char *full_name, enum pdb_value_state flag)
{
if (!sampass)
return False;
if (full_name) {
DEBUG(10, ("pdb_set_full_name: setting full name %s, was %s\n", full_name,
- (sampass->private_u.full_name)?(sampass->private_u.full_name):"NULL"));
+ (sampass->full_name)?(sampass->full_name):"NULL"));
- sampass->private_u.full_name = talloc_strdup(sampass->mem_ctx, full_name);
+ sampass->full_name = talloc_strdup(sampass, full_name);
- if (!sampass->private_u.full_name) {
+ if (!sampass->full_name) {
DEBUG(0, ("pdb_set_fullname: talloc_strdup() failed!\n"));
return False;
}
} else {
- sampass->private_u.full_name = PDB_NOT_QUITE_NULL;
+ sampass->full_name = PDB_NOT_QUITE_NULL;
}
return pdb_set_init_flags(sampass, PDB_FULLNAME, flag);
@@ -725,24 +725,24 @@ BOOL pdb_set_fullname(SAM_ACCOUNT *sampass, const char *full_name, enum pdb_valu
Set the user's logon script.
********************************************************************/
-BOOL pdb_set_logon_script(SAM_ACCOUNT *sampass, const char *logon_script, enum pdb_value_state flag)
+BOOL pdb_set_logon_script(struct samu *sampass, const char *logon_script, enum pdb_value_state flag)
{
if (!sampass)
return False;
if (logon_script) {
DEBUG(10, ("pdb_set_logon_script: setting logon script %s, was %s\n", logon_script,
- (sampass->private_u.logon_script)?(sampass->private_u.logon_script):"NULL"));
+ (sampass->logon_script)?(sampass->logon_script):"NULL"));
- sampass->private_u.logon_script = talloc_strdup(sampass->mem_ctx, logon_script);
+ sampass->logon_script = talloc_strdup(sampass, logon_script);
- if (!sampass->private_u.logon_script) {
+ if (!sampass->logon_script) {
DEBUG(0, ("pdb_set_logon_script: talloc_strdup() failed!\n"));
return False;
}
} else {
- sampass->private_u.logon_script = PDB_NOT_QUITE_NULL;
+ sampass->logon_script = PDB_NOT_QUITE_NULL;
}
return pdb_set_init_flags(sampass, PDB_LOGONSCRIPT, flag);
@@ -752,24 +752,24 @@ BOOL pdb_set_logon_script(SAM_ACCOUNT *sampass, const char *logon_script, enum p
Set the user's profile path.
********************************************************************/
-BOOL pdb_set_profile_path (SAM_ACCOUNT *sampass, const char *profile_path, enum pdb_value_state flag)
+BOOL pdb_set_profile_path (struct samu *sampass, const char *profile_path, enum pdb_value_state flag)
{
if (!sampass)
return False;
if (profile_path) {
DEBUG(10, ("pdb_set_profile_path: setting profile path %s, was %s\n", profile_path,
- (sampass->private_u.profile_path)?(sampass->private_u.profile_path):"NULL"));
+ (sampass->profile_path)?(sampass->profile_path):"NULL"));
- sampass->private_u.profile_path = talloc_strdup(sampass->mem_ctx, profile_path);
+ sampass->profile_path = talloc_strdup(sampass, profile_path);
- if (!sampass->private_u.profile_path) {
+ if (!sampass->profile_path) {
DEBUG(0, ("pdb_set_profile_path: talloc_strdup() failed!\n"));
return False;
}
} else {
- sampass->private_u.profile_path = PDB_NOT_QUITE_NULL;
+ sampass->profile_path = PDB_NOT_QUITE_NULL;
}
return pdb_set_init_flags(sampass, PDB_PROFILE, flag);
@@ -779,24 +779,24 @@ BOOL pdb_set_profile_path (SAM_ACCOUNT *sampass, const char *profile_path, enum
Set the user's directory drive.
********************************************************************/
-BOOL pdb_set_dir_drive (SAM_ACCOUNT *sampass, const char *dir_drive, enum pdb_value_state flag)
+BOOL pdb_set_dir_drive (struct samu *sampass, const char *dir_drive, enum pdb_value_state flag)
{
if (!sampass)
return False;
if (dir_drive) {
DEBUG(10, ("pdb_set_dir_drive: setting dir drive %s, was %s\n", dir_drive,
- (sampass->private_u.dir_drive)?(sampass->private_u.dir_drive):"NULL"));
+ (sampass->dir_drive)?(sampass->dir_drive):"NULL"));
- sampass->private_u.dir_drive = talloc_strdup(sampass->mem_ctx, dir_drive);
+ sampass->dir_drive = talloc_strdup(sampass, dir_drive);
- if (!sampass->private_u.dir_drive) {
+ if (!sampass->dir_drive) {
DEBUG(0, ("pdb_set_dir_drive: talloc_strdup() failed!\n"));
return False;
}
} else {
- sampass->private_u.dir_drive = PDB_NOT_QUITE_NULL;
+ sampass->dir_drive = PDB_NOT_QUITE_NULL;
}
return pdb_set_init_flags(sampass, PDB_DRIVE, flag);
@@ -806,24 +806,24 @@ BOOL pdb_set_dir_drive (SAM_ACCOUNT *sampass, const char *dir_drive, enum pdb_va
Set the user's home directory.
********************************************************************/
-BOOL pdb_set_homedir (SAM_ACCOUNT *sampass, const char *home_dir, enum pdb_value_state flag)
+BOOL pdb_set_homedir (struct samu *sampass, const char *home_dir, enum pdb_value_state flag)
{
if (!sampass)
return False;
if (home_dir) {
DEBUG(10, ("pdb_set_homedir: setting home dir %s, was %s\n", home_dir,
- (sampass->private_u.home_dir)?(sampass->private_u.home_dir):"NULL"));
+ (sampass->home_dir)?(sampass->home_dir):"NULL"));
- sampass->private_u.home_dir = talloc_strdup(sampass->mem_ctx, home_dir);
+ sampass->home_dir = talloc_strdup(sampass, home_dir);
- if (!sampass->private_u.home_dir) {
+ if (!sampass->home_dir) {
DEBUG(0, ("pdb_set_home_dir: talloc_strdup() failed!\n"));
return False;
}
} else {
- sampass->private_u.home_dir = PDB_NOT_QUITE_NULL;
+ sampass->home_dir = PDB_NOT_QUITE_NULL;
}
return pdb_set_init_flags(sampass, PDB_SMBHOME, flag);
@@ -833,25 +833,25 @@ BOOL pdb_set_homedir (SAM_ACCOUNT *sampass, const char *home_dir, enum pdb_value
Set the user's unix home directory.
********************************************************************/
-BOOL pdb_set_unix_homedir (SAM_ACCOUNT *sampass, const char *unix_home_dir, enum pdb_value_state flag)
+BOOL pdb_set_unix_homedir (struct samu *sampass, const char *unix_home_dir, enum pdb_value_state flag)
{
if (!sampass)
return False;
if (unix_home_dir) {
DEBUG(10, ("pdb_set_unix_homedir: setting home dir %s, was %s\n", unix_home_dir,
- (sampass->private_u.unix_home_dir)?(sampass->private_u.unix_home_dir):"NULL"));
+ (sampass->unix_home_dir)?(sampass->unix_home_dir):"NULL"));
- sampass->private_u.unix_home_dir = talloc_strdup(sampass->mem_ctx,
+ sampass->unix_home_dir = talloc_strdup(sampass,
unix_home_dir);
- if (!sampass->private_u.unix_home_dir) {
+ if (!sampass->unix_home_dir) {
DEBUG(0, ("pdb_set_unix_home_dir: talloc_strdup() failed!\n"));
return False;
}
} else {
- sampass->private_u.unix_home_dir = PDB_NOT_QUITE_NULL;
+ sampass->unix_home_dir = PDB_NOT_QUITE_NULL;
}
return pdb_set_init_flags(sampass, PDB_UNIXHOMEDIR, flag);
@@ -861,21 +861,21 @@ BOOL pdb_set_unix_homedir (SAM_ACCOUNT *sampass, const char *unix_home_dir, enum
Set the user's account description.
********************************************************************/
-BOOL pdb_set_acct_desc (SAM_ACCOUNT *sampass, const char *acct_desc, enum pdb_value_state flag)
+BOOL pdb_set_acct_desc (struct samu *sampass, const char *acct_desc, enum pdb_value_state flag)
{
if (!sampass)
return False;
if (acct_desc) {
- sampass->private_u.acct_desc = talloc_strdup(sampass->mem_ctx, acct_desc);
+ sampass->acct_desc = talloc_strdup(sampass, acct_desc);
- if (!sampass->private_u.acct_desc) {
+ if (!sampass->acct_desc) {
DEBUG(0, ("pdb_set_acct_desc: talloc_strdup() failed!\n"));
return False;
}
} else {
- sampass->private_u.acct_desc = PDB_NOT_QUITE_NULL;
+ sampass->acct_desc = PDB_NOT_QUITE_NULL;
}
return pdb_set_init_flags(sampass, PDB_ACCTDESC, flag);
@@ -885,24 +885,24 @@ BOOL pdb_set_acct_desc (SAM_ACCOUNT *sampass, const char *acct_desc, enum pdb_va
Set the user's workstation allowed list.
********************************************************************/
-BOOL pdb_set_workstations (SAM_ACCOUNT *sampass, const char *workstations, enum pdb_value_state flag)
+BOOL pdb_set_workstations (struct samu *sampass, const char *workstations, enum pdb_value_state flag)
{
if (!sampass)
return False;
if (workstations) {
DEBUG(10, ("pdb_set_workstations: setting workstations %s, was %s\n", workstations,
- (sampass->private_u.workstations)?(sampass->private_u.workstations):"NULL"));
+ (sampass->workstations)?(sampass->workstations):"NULL"));
- sampass->private_u.workstations = talloc_strdup(sampass->mem_ctx, workstations);
+ sampass->workstations = talloc_strdup(sampass, workstations);
- if (!sampass->private_u.workstations) {
+ if (!sampass->workstations) {
DEBUG(0, ("pdb_set_workstations: talloc_strdup() failed!\n"));
return False;
}
} else {
- sampass->private_u.workstations = PDB_NOT_QUITE_NULL;
+ sampass->workstations = PDB_NOT_QUITE_NULL;
}
return pdb_set_init_flags(sampass, PDB_WORKSTATIONS, flag);
@@ -912,21 +912,21 @@ BOOL pdb_set_workstations (SAM_ACCOUNT *sampass, const char *workstations, enum
Set the user's 'unknown_str', whatever the heck this actually is...
********************************************************************/
-BOOL pdb_set_unknown_str (SAM_ACCOUNT *sampass, const char *unknown_str, enum pdb_value_state flag)
+BOOL pdb_set_unknown_str (struct samu *sampass, const char *unknown_str, enum pdb_value_state flag)
{
if (!sampass)
return False;
if (unknown_str) {
- sampass->private_u.unknown_str = talloc_strdup(sampass->mem_ctx, unknown_str);
+ sampass->unknown_str = talloc_strdup(sampass, unknown_str);
- if (!sampass->private_u.unknown_str) {
+ if (!sampass->unknown_str) {
DEBUG(0, ("pdb_set_unknown_str: talloc_strdup() failed!\n"));
return False;
}
} else {
- sampass->private_u.unknown_str = PDB_NOT_QUITE_NULL;
+ sampass->unknown_str = PDB_NOT_QUITE_NULL;
}
return pdb_set_init_flags(sampass, PDB_UNKNOWNSTR, flag);
@@ -936,21 +936,21 @@ BOOL pdb_set_unknown_str (SAM_ACCOUNT *sampass, const char *unknown_str, enum pd
Set the user's dial string.
********************************************************************/
-BOOL pdb_set_munged_dial (SAM_ACCOUNT *sampass, const char *munged_dial, enum pdb_value_state flag)
+BOOL pdb_set_munged_dial (struct samu *sampass, const char *munged_dial, enum pdb_value_state flag)
{
if (!sampass)
return False;
if (munged_dial) {
- sampass->private_u.munged_dial = talloc_strdup(sampass->mem_ctx, munged_dial);
+ sampass->munged_dial = talloc_strdup(sampass, munged_dial);
- if (!sampass->private_u.munged_dial) {
+ if (!sampass->munged_dial) {
DEBUG(0, ("pdb_set_munged_dial: talloc_strdup() failed!\n"));
return False;
}
} else {
- sampass->private_u.munged_dial = PDB_NOT_QUITE_NULL;
+ sampass->munged_dial = PDB_NOT_QUITE_NULL;
}
return pdb_set_init_flags(sampass, PDB_MUNGEDDIAL, flag);
@@ -960,18 +960,18 @@ BOOL pdb_set_munged_dial (SAM_ACCOUNT *sampass, const char *munged_dial, enum pd
Set the user's NT hash.
********************************************************************/
-BOOL pdb_set_nt_passwd (SAM_ACCOUNT *sampass, const uint8 pwd[NT_HASH_LEN], enum pdb_value_state flag)
+BOOL pdb_set_nt_passwd (struct samu *sampass, const uint8 pwd[NT_HASH_LEN], enum pdb_value_state flag)
{
if (!sampass)
return False;
- data_blob_clear_free(&sampass->private_u.nt_pw);
+ data_blob_clear_free(&sampass->nt_pw);
if (pwd) {
- sampass->private_u.nt_pw =
- data_blob_talloc(sampass->mem_ctx, pwd, NT_HASH_LEN);
+ sampass->nt_pw =
+ data_blob_talloc(sampass, pwd, NT_HASH_LEN);
} else {
- sampass->private_u.nt_pw = data_blob(NULL, 0);
+ sampass->nt_pw = data_blob(NULL, 0);
}
return pdb_set_init_flags(sampass, PDB_NTPASSWD, flag);
@@ -981,18 +981,18 @@ BOOL pdb_set_nt_passwd (SAM_ACCOUNT *sampass, const uint8 pwd[NT_HASH_LEN], enum
Set the user's LM hash.
********************************************************************/
-BOOL pdb_set_lanman_passwd (SAM_ACCOUNT *sampass, const uint8 pwd[LM_HASH_LEN], enum pdb_value_state flag)
+BOOL pdb_set_lanman_passwd (struct samu *sampass, const uint8 pwd[LM_HASH_LEN], enum pdb_value_state flag)
{
if (!sampass)
return False;
- data_blob_clear_free(&sampass->private_u.lm_pw);
+ data_blob_clear_free(&sampass->lm_pw);
if (pwd) {
- sampass->private_u.lm_pw =
- data_blob_talloc(sampass->mem_ctx, pwd, LM_HASH_LEN);
+ sampass->lm_pw =
+ data_blob_talloc(sampass, pwd, LM_HASH_LEN);
} else {
- sampass->private_u.lm_pw = data_blob(NULL, 0);
+ sampass->lm_pw = data_blob(NULL, 0);
}
return pdb_set_init_flags(sampass, PDB_LMPASSWD, flag);
@@ -1005,20 +1005,20 @@ BOOL pdb_set_lanman_passwd (SAM_ACCOUNT *sampass, const uint8 pwd[LM_HASH_LEN],
in pwd.
********************************************************************/
-BOOL pdb_set_pw_history (SAM_ACCOUNT *sampass, const uint8 *pwd, uint32 historyLen, enum pdb_value_state flag)
+BOOL pdb_set_pw_history (struct samu *sampass, const uint8 *pwd, uint32 historyLen, enum pdb_value_state flag)
{
if (!sampass)
return False;
if (historyLen && pwd){
- sampass->private_u.nt_pw_his = data_blob_talloc(sampass->mem_ctx,
+ sampass->nt_pw_his = data_blob_talloc(sampass,
pwd, historyLen*PW_HISTORY_ENTRY_LEN);
- if (!sampass->private_u.nt_pw_his.length) {
+ if (!sampass->nt_pw_his.length) {
DEBUG(0, ("pdb_set_pw_history: data_blob_talloc() failed!\n"));
return False;
}
} else {
- sampass->private_u.nt_pw_his = data_blob_talloc(sampass->mem_ctx, NULL, 0);
+ sampass->nt_pw_his = data_blob_talloc(sampass, NULL, 0);
}
return pdb_set_init_flags(sampass, PDB_PWHISTORY, flag);
@@ -1029,75 +1029,75 @@ BOOL pdb_set_pw_history (SAM_ACCOUNT *sampass, const uint8 *pwd, uint32 historyL
below)
********************************************************************/
-BOOL pdb_set_plaintext_pw_only (SAM_ACCOUNT *sampass, const char *password, enum pdb_value_state flag)
+BOOL pdb_set_plaintext_pw_only (struct samu *sampass, const char *password, enum pdb_value_state flag)
{
if (!sampass)
return False;
if (password) {
- if (sampass->private_u.plaintext_pw!=NULL)
- memset(sampass->private_u.plaintext_pw,'\0',strlen(sampass->private_u.plaintext_pw)+1);
+ if (sampass->plaintext_pw!=NULL)
+ memset(sampass->plaintext_pw,'\0',strlen(sampass->plaintext_pw)+1);
- sampass->private_u.plaintext_pw = talloc_strdup(sampass->mem_ctx, password);
+ sampass->plaintext_pw = talloc_strdup(sampass, password);
- if (!sampass->private_u.plaintext_pw) {
+ if (!sampass->plaintext_pw) {
DEBUG(0, ("pdb_set_unknown_str: talloc_strdup() failed!\n"));
return False;
}
} else {
- sampass->private_u.plaintext_pw = NULL;
+ sampass->plaintext_pw = NULL;
}
return pdb_set_init_flags(sampass, PDB_PLAINTEXT_PW, flag);
}
-BOOL pdb_set_bad_password_count(SAM_ACCOUNT *sampass, uint16 bad_password_count, enum pdb_value_state flag)
+BOOL pdb_set_bad_password_count(struct samu *sampass, uint16 bad_password_count, enum pdb_value_state flag)
{
if (!sampass)
return False;
- sampass->private_u.bad_password_count = bad_password_count;
+ sampass->bad_password_count = bad_password_count;
return pdb_set_init_flags(sampass, PDB_BAD_PASSWORD_COUNT, flag);
}
-BOOL pdb_set_logon_count(SAM_ACCOUNT *sampass, uint16 logon_count, enum pdb_value_state flag)
+BOOL pdb_set_logon_count(struct samu *sampass, uint16 logon_count, enum pdb_value_state flag)
{
if (!sampass)
return False;
- sampass->private_u.logon_count = logon_count;
+ sampass->logon_count = logon_count;
return pdb_set_init_flags(sampass, PDB_LOGON_COUNT, flag);
}
-BOOL pdb_set_unknown_6 (SAM_ACCOUNT *sampass, uint32 unkn, enum pdb_value_state flag)
+BOOL pdb_set_unknown_6 (struct samu *sampass, uint32 unkn, enum pdb_value_state flag)
{
if (!sampass)
return False;
- sampass->private_u.unknown_6 = unkn;
+ sampass->unknown_6 = unkn;
return pdb_set_init_flags(sampass, PDB_UNKNOWN6, flag);
}
-BOOL pdb_set_hours (SAM_ACCOUNT *sampass, const uint8 *hours, enum pdb_value_state flag)
+BOOL pdb_set_hours (struct samu *sampass, const uint8 *hours, enum pdb_value_state flag)
{
if (!sampass)
return False;
if (!hours) {
- memset ((char *)sampass->private_u.hours, 0, MAX_HOURS_LEN);
+ memset ((char *)sampass->hours, 0, MAX_HOURS_LEN);
return True;
}
- memcpy (sampass->private_u.hours, hours, MAX_HOURS_LEN);
+ memcpy (sampass->hours, hours, MAX_HOURS_LEN);
return pdb_set_init_flags(sampass, PDB_HOURS, flag);
}
-BOOL pdb_set_backend_private_data (SAM_ACCOUNT *sampass, void *private_data,
+BOOL pdb_set_backend_private_data (struct samu *sampass, void *private_data,
void (*free_fn)(void **),
const struct pdb_methods *my_methods,
enum pdb_value_state flag)
@@ -1105,15 +1105,15 @@ BOOL pdb_set_backend_private_data (SAM_ACCOUNT *sampass, void *private_data,
if (!sampass)
return False;
- if (sampass->private_u.backend_private_data &&
- sampass->private_u.backend_private_data_free_fn) {
- sampass->private_u.backend_private_data_free_fn(
- &sampass->private_u.backend_private_data);
+ if (sampass->backend_private_data &&
+ sampass->backend_private_data_free_fn) {
+ sampass->backend_private_data_free_fn(
+ &sampass->backend_private_data);
}
- sampass->private_u.backend_private_data = private_data;
- sampass->private_u.backend_private_data_free_fn = free_fn;
- sampass->private_u.backend_private_methods = my_methods;
+ sampass->backend_private_data = private_data;
+ sampass->backend_private_data_free_fn = free_fn;
+ sampass->backend_private_methods = my_methods;
return pdb_set_init_flags(sampass, PDB_BACKEND_PRIVATE_DATA, flag);
}
@@ -1126,7 +1126,7 @@ BOOL pdb_set_backend_private_data (SAM_ACCOUNT *sampass, void *private_data,
password change.
********************************************************************/
-BOOL pdb_set_pass_changed_now (SAM_ACCOUNT *sampass)
+BOOL pdb_set_pass_changed_now (struct samu *sampass)
{
uint32 expire;
uint32 min_age;
@@ -1166,7 +1166,7 @@ BOOL pdb_set_pass_changed_now (SAM_ACCOUNT *sampass)
Also sets the last change time to NOW.
********************************************************************/
-BOOL pdb_set_plaintext_passwd (SAM_ACCOUNT *sampass, const char *plaintext)
+BOOL pdb_set_plaintext_passwd (struct samu *sampass, const char *plaintext)
{
uchar new_lanman_p16[LM_HASH_LEN];
uchar new_nt_p16[NT_HASH_LEN];
@@ -1208,11 +1208,11 @@ BOOL pdb_set_plaintext_passwd (SAM_ACCOUNT *sampass, const char *plaintext)
uint32 current_history_len;
/* We need to make sure we don't have a race condition here - the
account policy history length can change between when the pw_history
- was first loaded into the SAM_ACCOUNT struct and now.... JRA. */
+ was first loaded into the struct samu struct and now.... JRA. */
pwhistory = (uchar *)pdb_get_pw_history(sampass, &current_history_len);
if (current_history_len != pwHistLen) {
- /* After closing and reopening SAM_ACCOUNT the history
+ /* After closing and reopening struct samu the history
values will sync up. We can't do this here. */
/* current_history_len > pwHistLen is not a problem - we
@@ -1220,7 +1220,7 @@ BOOL pdb_set_plaintext_passwd (SAM_ACCOUNT *sampass, const char *plaintext)
if (current_history_len < pwHistLen) {
/* Ensure we have space for the needed history. */
- uchar *new_history = TALLOC(sampass->mem_ctx,
+ uchar *new_history = TALLOC(sampass,
pwHistLen*PW_HISTORY_ENTRY_LEN);
/* And copy it into the new buffer. */
if (current_history_len) {
@@ -1261,7 +1261,7 @@ BOOL pdb_set_plaintext_passwd (SAM_ACCOUNT *sampass, const char *plaintext)
}
/* check for any PDB_SET/CHANGED field and fill the appropriate mask bit */
-uint32 pdb_build_fields_present (SAM_ACCOUNT *sampass)
+uint32 pdb_build_fields_present (struct samu *sampass)
{
/* value set to all for testing */
return 0x00ffffff;
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index e2035296cc..7f85c4d7c4 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -28,7 +28,7 @@
/* Cache of latest SAM lookup query */
-static SAM_ACCOUNT *csamuser = NULL;
+static struct samu *csamuser = NULL;
static struct pdb_init_function_entry *backends = NULL;
@@ -54,7 +54,7 @@ static BOOL lookup_global_sam_rid(TALLOC_CTX *mem_ctx, uint32 rid,
time, such LDAP with a missing attribute would produce.
********************************************************************/
-static void pdb_force_pw_initialization(SAM_ACCOUNT *pass)
+static void pdb_force_pw_initialization(struct samu *pass)
{
const uint8 *lm_pwd, *nt_pwd;
@@ -239,7 +239,7 @@ void pdb_endsampwent(void)
pdb->endsampwent(pdb);
}
-BOOL pdb_getsampwent(SAM_ACCOUNT *user)
+BOOL pdb_getsampwent(struct samu *user)
{
struct pdb_methods *pdb = pdb_get_methods(False);
@@ -256,7 +256,7 @@ BOOL pdb_getsampwent(SAM_ACCOUNT *user)
return True;
}
-BOOL pdb_getsampwnam(SAM_ACCOUNT *sam_acct, const char *username)
+BOOL pdb_getsampwnam(struct samu *sam_acct, const char *username)
{
struct pdb_methods *pdb = pdb_get_methods(False);
@@ -269,7 +269,7 @@ BOOL pdb_getsampwnam(SAM_ACCOUNT *sam_acct, const char *username)
}
if (csamuser != NULL) {
- pdb_free_sam(&csamuser);
+ TALLOC_FREE(csamuser);
csamuser = NULL;
}
@@ -282,7 +282,7 @@ BOOL pdb_getsampwnam(SAM_ACCOUNT *sam_acct, const char *username)
/**********************************************************************
**********************************************************************/
-BOOL guest_user_info( SAM_ACCOUNT *user )
+BOOL guest_user_info( struct samu *user )
{
struct passwd *pwd;
NTSTATUS ntstatus;
@@ -305,7 +305,7 @@ BOOL guest_user_info( SAM_ACCOUNT *user )
/**********************************************************************
**********************************************************************/
-BOOL pdb_getsampwsid(SAM_ACCOUNT *sam_acct, const DOM_SID *sid)
+BOOL pdb_getsampwsid(struct samu *sam_acct, const DOM_SID *sid)
{
struct pdb_methods *pdb;
uint32 rid;
@@ -336,7 +336,7 @@ static NTSTATUS pdb_default_create_user(struct pdb_methods *methods,
TALLOC_CTX *tmp_ctx, const char *name,
uint32 acb_info, uint32 *rid)
{
- SAM_ACCOUNT *sam_pass = NULL;
+ struct samu *sam_pass = NULL;
NTSTATUS status;
if (Get_Pwnam_alloc(tmp_ctx, name) == NULL) {
@@ -388,7 +388,7 @@ static NTSTATUS pdb_default_create_user(struct pdb_methods *methods,
status = pdb_add_sam_account(sam_pass);
- pdb_free_sam(&sam_pass);
+ TALLOC_FREE(sam_pass);
return status;
}
@@ -427,7 +427,7 @@ static int smb_delete_user(const char *unix_user)
static NTSTATUS pdb_default_delete_user(struct pdb_methods *methods,
TALLOC_CTX *mem_ctx,
- SAM_ACCOUNT *sam_acct)
+ struct samu *sam_acct)
{
NTSTATUS status;
@@ -447,7 +447,7 @@ static NTSTATUS pdb_default_delete_user(struct pdb_methods *methods,
return status;
}
-NTSTATUS pdb_delete_user(TALLOC_CTX *mem_ctx, SAM_ACCOUNT *sam_acct)
+NTSTATUS pdb_delete_user(TALLOC_CTX *mem_ctx, struct samu *sam_acct)
{
struct pdb_methods *pdb = pdb_get_methods(False);
@@ -458,7 +458,7 @@ NTSTATUS pdb_delete_user(TALLOC_CTX *mem_ctx, SAM_ACCOUNT *sam_acct)
return pdb->delete_user(pdb, mem_ctx, sam_acct);
}
-NTSTATUS pdb_add_sam_account(SAM_ACCOUNT *sam_acct)
+NTSTATUS pdb_add_sam_account(struct samu *sam_acct)
{
struct pdb_methods *pdb = pdb_get_methods(False);
@@ -469,7 +469,7 @@ NTSTATUS pdb_add_sam_account(SAM_ACCOUNT *sam_acct)
return pdb->add_sam_account(pdb, sam_acct);
}
-NTSTATUS pdb_update_sam_account(SAM_ACCOUNT *sam_acct)
+NTSTATUS pdb_update_sam_account(struct samu *sam_acct)
{
struct pdb_methods *pdb = pdb_get_methods(False);
@@ -478,14 +478,14 @@ NTSTATUS pdb_update_sam_account(SAM_ACCOUNT *sam_acct)
}
if (csamuser != NULL) {
- pdb_free_sam(&csamuser);
+ TALLOC_FREE(csamuser);
csamuser = NULL;
}
return pdb->update_sam_account(pdb, sam_acct);
}
-NTSTATUS pdb_delete_sam_account(SAM_ACCOUNT *sam_acct)
+NTSTATUS pdb_delete_sam_account(struct samu *sam_acct)
{
struct pdb_methods *pdb = pdb_get_methods(False);
@@ -494,14 +494,14 @@ NTSTATUS pdb_delete_sam_account(SAM_ACCOUNT *sam_acct)
}
if (csamuser != NULL) {
- pdb_free_sam(&csamuser);
+ TALLOC_FREE(csamuser);
csamuser = NULL;
}
return pdb->delete_sam_account(pdb, sam_acct);
}
-NTSTATUS pdb_rename_sam_account(SAM_ACCOUNT *oldname, const char *newname)
+NTSTATUS pdb_rename_sam_account(struct samu *oldname, const char *newname)
{
struct pdb_methods *pdb = pdb_get_methods(False);
@@ -510,14 +510,14 @@ NTSTATUS pdb_rename_sam_account(SAM_ACCOUNT *oldname, const char *newname)
}
if (csamuser != NULL) {
- pdb_free_sam(&csamuser);
+ TALLOC_FREE(csamuser);
csamuser = NULL;
}
return pdb->rename_sam_account(pdb, oldname, newname);
}
-NTSTATUS pdb_update_login_attempts(SAM_ACCOUNT *sam_acct, BOOL success)
+NTSTATUS pdb_update_login_attempts(struct samu *sam_acct, BOOL success)
{
struct pdb_methods *pdb = pdb_get_methods(False);
@@ -731,7 +731,7 @@ NTSTATUS pdb_enum_group_members(TALLOC_CTX *mem_ctx,
pp_member_rids, p_num_members);
}
-NTSTATUS pdb_enum_group_memberships(TALLOC_CTX *mem_ctx, SAM_ACCOUNT *user,
+NTSTATUS pdb_enum_group_memberships(TALLOC_CTX *mem_ctx, struct samu *user,
DOM_SID **pp_sids, gid_t **pp_gids,
size_t *p_num_groups)
{
@@ -748,7 +748,7 @@ NTSTATUS pdb_enum_group_memberships(TALLOC_CTX *mem_ctx, SAM_ACCOUNT *user,
static NTSTATUS pdb_default_set_unix_primary_group(struct pdb_methods *methods,
TALLOC_CTX *mem_ctx,
- SAM_ACCOUNT *sampass)
+ struct samu *sampass)
{
struct group *grp;
gid_t gid;
@@ -766,7 +766,7 @@ static NTSTATUS pdb_default_set_unix_primary_group(struct pdb_methods *methods,
return NT_STATUS_OK;
}
-NTSTATUS pdb_set_unix_primary_group(TALLOC_CTX *mem_ctx, SAM_ACCOUNT *user)
+NTSTATUS pdb_set_unix_primary_group(TALLOC_CTX *mem_ctx, struct samu *user)
{
struct pdb_methods *pdb = pdb_get_methods(False);
@@ -783,7 +783,7 @@ NTSTATUS pdb_set_unix_primary_group(TALLOC_CTX *mem_ctx, SAM_ACCOUNT *user)
* fulfil.
*/
-static BOOL pdb_user_in_group(TALLOC_CTX *mem_ctx, SAM_ACCOUNT *account,
+static BOOL pdb_user_in_group(TALLOC_CTX *mem_ctx, struct samu *account,
const DOM_SID *group_sid)
{
DOM_SID *sids;
@@ -810,7 +810,7 @@ static NTSTATUS pdb_default_add_groupmem(struct pdb_methods *methods,
uint32 member_rid)
{
DOM_SID group_sid, member_sid;
- SAM_ACCOUNT *account = NULL;
+ struct samu *account = NULL;
GROUP_MAP map;
struct group *grp;
struct passwd *pwd;
@@ -878,7 +878,7 @@ static NTSTATUS pdb_default_del_groupmem(struct pdb_methods *methods,
uint32 member_rid)
{
DOM_SID group_sid, member_sid;
- SAM_ACCOUNT *account = NULL;
+ struct samu *account = NULL;
GROUP_MAP map;
struct group *grp;
struct passwd *pwd;
@@ -1206,38 +1206,38 @@ BOOL initialize_password_db(BOOL reload)
Default implementations of some functions.
****************************************************************************/
-static NTSTATUS pdb_default_getsampwnam (struct pdb_methods *methods, SAM_ACCOUNT *user, const char *sname)
+static NTSTATUS pdb_default_getsampwnam (struct pdb_methods *methods, struct samu *user, const char *sname)
{
return NT_STATUS_NO_SUCH_USER;
}
-static NTSTATUS pdb_default_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT * user, const DOM_SID *sid)
+static NTSTATUS pdb_default_getsampwsid(struct pdb_methods *my_methods, struct samu * user, const DOM_SID *sid)
{
return NT_STATUS_NO_SUCH_USER;
}
-static NTSTATUS pdb_default_add_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *newpwd)
+static NTSTATUS pdb_default_add_sam_account (struct pdb_methods *methods, struct samu *newpwd)
{
DEBUG(0,("this backend (%s) should not be listed as the first passdb backend! You can't add users to it.\n", methods->name));
return NT_STATUS_NOT_IMPLEMENTED;
}
-static NTSTATUS pdb_default_update_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *newpwd)
+static NTSTATUS pdb_default_update_sam_account (struct pdb_methods *methods, struct samu *newpwd)
{
return NT_STATUS_NOT_IMPLEMENTED;
}
-static NTSTATUS pdb_default_delete_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *pwd)
+static NTSTATUS pdb_default_delete_sam_account (struct pdb_methods *methods, struct samu *pwd)
{
return NT_STATUS_NOT_IMPLEMENTED;
}
-static NTSTATUS pdb_default_rename_sam_account (struct pdb_methods *methods, SAM_ACCOUNT *pwd, const char *newname)
+static NTSTATUS pdb_default_rename_sam_account (struct pdb_methods *methods, struct samu *pwd, const char *newname)
{
return NT_STATUS_NOT_IMPLEMENTED;
}
-static NTSTATUS pdb_default_update_login_attempts (struct pdb_methods *methods, SAM_ACCOUNT *newpwd, BOOL success)
+static NTSTATUS pdb_default_update_login_attempts (struct pdb_methods *methods, struct samu *newpwd, BOOL success)
{
return NT_STATUS_OK;
}
@@ -1247,7 +1247,7 @@ static NTSTATUS pdb_default_setsampwent(struct pdb_methods *methods, BOOL update
return NT_STATUS_NOT_IMPLEMENTED;
}
-static NTSTATUS pdb_default_getsampwent(struct pdb_methods *methods, SAM_ACCOUNT *user)
+static NTSTATUS pdb_default_getsampwent(struct pdb_methods *methods, struct samu *user)
{
return NT_STATUS_NOT_IMPLEMENTED;
}
@@ -1276,7 +1276,7 @@ static NTSTATUS pdb_default_get_seq_num(struct pdb_methods *methods, time_t *seq
static BOOL pdb_default_uid_to_rid(struct pdb_methods *methods, uid_t uid,
uint32 *rid)
{
- SAM_ACCOUNT *sampw = NULL;
+ struct samu *sampw = NULL;
struct passwd *unix_pw;
BOOL ret;
@@ -1290,7 +1290,7 @@ static BOOL pdb_default_uid_to_rid(struct pdb_methods *methods, uid_t uid,
if ( !NT_STATUS_IS_OK(pdb_init_sam(&sampw)) ) {
DEBUG(0,("pdb_default_uid_to_rid: failed to allocate "
- "SAM_ACCOUNT object\n"));
+ "struct samu object\n"));
return False;
}
@@ -1302,7 +1302,7 @@ static BOOL pdb_default_uid_to_rid(struct pdb_methods *methods, uid_t uid,
if (!ret) {
DEBUG(5, ("pdb_default_uid_to_rid: Did not find user "
"%s (%d)\n", unix_pw->pw_name, uid));
- pdb_free_sam(&sampw);
+ TALLOC_FREE(sampw);
return False;
}
@@ -1314,7 +1314,7 @@ static BOOL pdb_default_uid_to_rid(struct pdb_methods *methods, uid_t uid,
sid_string_static(pdb_get_user_sid(sampw))));
}
- pdb_free_sam(&sampw);
+ TALLOC_FREE(sampw);
return ret;
}
@@ -1491,7 +1491,7 @@ NTSTATUS pdb_default_enum_group_members(struct pdb_methods *methods,
NTSTATUS pdb_default_enum_group_memberships(struct pdb_methods *methods,
TALLOC_CTX *mem_ctx,
- SAM_ACCOUNT *user,
+ struct samu *user,
DOM_SID **pp_sids,
gid_t **pp_gids,
size_t *p_num_groups)
@@ -1551,7 +1551,7 @@ static BOOL lookup_global_sam_rid(TALLOC_CTX *mem_ctx, uint32 rid,
enum SID_NAME_USE *psid_name_use,
union unid_t *unix_id)
{
- SAM_ACCOUNT *sam_account = NULL;
+ struct samu *sam_account = NULL;
GROUP_MAP map;
BOOL ret;
DOM_SID sid;
@@ -1578,7 +1578,7 @@ static BOOL lookup_global_sam_rid(TALLOC_CTX *mem_ctx, uint32 rid,
*name = talloc_strdup(mem_ctx, pdb_get_username(sam_account));
*psid_name_use = SID_NAME_USER;
- pdb_free_sam(&sam_account);
+ TALLOC_FREE(sam_account);
if (unix_id == NULL) {
return True;
@@ -1591,7 +1591,7 @@ static BOOL lookup_global_sam_rid(TALLOC_CTX *mem_ctx, uint32 rid,
unix_id->uid = pw->pw_uid;
return True;
}
- pdb_free_sam(&sam_account);
+ TALLOC_FREE(sam_account);
ret = pdb_getgrsid(&map, sid);
unbecome_root();
@@ -1812,7 +1812,7 @@ static BOOL next_entry_users(struct pdb_search *s,
struct samr_displayentry *entry)
{
struct user_search *state = s->private_data;
- SAM_ACCOUNT *user = NULL;
+ struct samu *user = NULL;
NTSTATUS status;
next:
@@ -1823,13 +1823,13 @@ static BOOL next_entry_users(struct pdb_search *s,
}
if (!pdb_getsampwent(user)) {
- pdb_free_sam(&user);
+ TALLOC_FREE(user);
return False;
}
if ((state->acct_flags != 0) &&
((pdb_get_acct_ctrl(user) & state->acct_flags) == 0)) {
- pdb_free_sam(&user);
+ TALLOC_FREE(user);
goto next;
}
@@ -1838,7 +1838,7 @@ static BOOL next_entry_users(struct pdb_search *s,
pdb_get_fullname(user), pdb_get_acct_desc(user),
entry);
- pdb_free_sam(&user);
+ TALLOC_FREE(user);
return True;
}
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index 9abd668d6f..3344b17888 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -30,7 +30,7 @@
* Clean up SSL stuff, compile on OpenLDAP 1.x, 2.x, and Netscape SDK
*
* Other LDAP based login attributes: accountExpires, etc.
-* (should be the domain of Samba proper, but the sam_password/SAM_ACCOUNT
+* (should be the domain of Samba proper, but the sam_password/struct samu
* structures don't have fields for some of these attributes)
*
* SSL is done, but can't get the certificate based authentication to work
@@ -77,10 +77,6 @@
#endif
-#ifndef SAM_ACCOUNT
-#define SAM_ACCOUNT struct sam_passwd
-#endif
-
#include "smbldap.h"
/**********************************************************************
@@ -450,10 +446,10 @@ static int ldapsam_delete_entry(struct ldapsam_privates *priv,
#if 0 /* JERRY - not uesed anymore */
/**********************************************************************
-Initialize SAM_ACCOUNT from an LDAP query (unix attributes only)
+Initialize struct samu from an LDAP query (unix attributes only)
*********************************************************************/
static BOOL get_unix_attributes (struct ldapsam_privates *ldap_state,
- SAM_ACCOUNT * sampass,
+ struct samu * sampass,
LDAPMessage * entry,
gid_t *gid)
{
@@ -521,12 +517,12 @@ static time_t ldapsam_get_entry_timestamp(
}
/**********************************************************************
- Initialize SAM_ACCOUNT from an LDAP query.
+ Initialize struct samu from an LDAP query.
(Based on init_sam_from_buffer in pdb_tdb.c)
*********************************************************************/
static BOOL init_sam_from_ldap(struct ldapsam_privates *ldap_state,
- SAM_ACCOUNT * sampass,
+ struct samu * sampass,
LDAPMessage * entry)
{
time_t logon_time,
@@ -734,7 +730,7 @@ static BOOL init_sam_from_ldap(struct ldapsam_privates *ldap_state,
get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_HOME_PATH), homedir))
{
pdb_set_homedir( sampass,
- talloc_sub_basic(sampass->mem_ctx, username, lp_logon_home()),
+ talloc_sub_basic(sampass, username, lp_logon_home()),
PDB_DEFAULT );
} else {
pstrcpy( tmpstring, homedir );
@@ -749,7 +745,7 @@ static BOOL init_sam_from_ldap(struct ldapsam_privates *ldap_state,
get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_LOGON_SCRIPT), logon_script))
{
pdb_set_logon_script( sampass,
- talloc_sub_basic(sampass->mem_ctx, username, lp_logon_script()),
+ talloc_sub_basic(sampass, username, lp_logon_script()),
PDB_DEFAULT );
} else {
pstrcpy( tmpstring, logon_script );
@@ -764,7 +760,7 @@ static BOOL init_sam_from_ldap(struct ldapsam_privates *ldap_state,
get_userattr_key2string(ldap_state->schema_ver, LDAP_ATTR_PROFILE_PATH), profile_path))
{
pdb_set_profile_path( sampass,
- talloc_sub_basic( sampass->mem_ctx, username, lp_logon_path()),
+ talloc_sub_basic( sampass, username, lp_logon_path()),
PDB_DEFAULT );
} else {
pstrcpy( tmpstring, profile_path );
@@ -1003,14 +999,14 @@ static BOOL init_sam_from_ldap(struct ldapsam_privates *ldap_state,
}
/**********************************************************************
- Initialize the ldap db from a SAM_ACCOUNT. Called on update.
+ Initialize the ldap db from a struct samu. Called on update.
(Based on init_buffer_from_sam in pdb_tdb.c)
*********************************************************************/
static BOOL init_ldap_from_sam (struct ldapsam_privates *ldap_state,
LDAPMessage *existing,
- LDAPMod *** mods, SAM_ACCOUNT * sampass,
- BOOL (*need_update)(const SAM_ACCOUNT *,
+ LDAPMod *** mods, struct samu * sampass,
+ BOOL (*need_update)(const struct samu *,
enum pdb_elements))
{
pstring temp;
@@ -1392,7 +1388,7 @@ Get the next entry in the LDAP password database.
*********************************************************************/
static NTSTATUS ldapsam_getsampwent(struct pdb_methods *my_methods,
- SAM_ACCOUNT *user)
+ struct samu *user)
{
NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
struct ldapsam_privates *ldap_state =
@@ -1434,10 +1430,10 @@ static void append_attr(TALLOC_CTX *mem_ctx, const char ***attr_list,
}
/**********************************************************************
-Get SAM_ACCOUNT entry from LDAP by username.
+Get struct samu entry from LDAP by username.
*********************************************************************/
-static NTSTATUS ldapsam_getsampwnam(struct pdb_methods *my_methods, SAM_ACCOUNT *user, const char *sname)
+static NTSTATUS ldapsam_getsampwnam(struct pdb_methods *my_methods, struct samu *user, const char *sname)
{
NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
struct ldapsam_privates *ldap_state = (struct ldapsam_privates *)my_methods->private_data;
@@ -1447,11 +1443,11 @@ static NTSTATUS ldapsam_getsampwnam(struct pdb_methods *my_methods, SAM_ACCOUNT
const char ** attr_list;
int rc;
- attr_list = get_userattr_list( user->mem_ctx, ldap_state->schema_ver );
- append_attr(user->mem_ctx, &attr_list,
+ attr_list = get_userattr_list( user, ldap_state->schema_ver );
+ append_attr(user, &attr_list,
get_userattr_key2string(ldap_state->schema_ver,
LDAP_ATTR_MOD_TIMESTAMP));
- append_attr(user->mem_ctx, &attr_list, "uidNumber");
+ append_attr(user, &attr_list, "uidNumber");
rc = ldapsam_search_suffix_by_name(ldap_state, sname, &result,
attr_list);
TALLOC_FREE( attr_list );
@@ -1480,7 +1476,7 @@ static NTSTATUS ldapsam_getsampwnam(struct pdb_methods *my_methods, SAM_ACCOUNT
}
pdb_set_backend_private_data(user, result, NULL,
my_methods, PDB_CHANGED);
- talloc_autofree_ldapmsg(user->mem_ctx, result);
+ talloc_autofree_ldapmsg(user, result);
ret = NT_STATUS_OK;
} else {
ldap_msgfree(result);
@@ -1536,10 +1532,10 @@ static int ldapsam_get_ldap_user_by_sid(struct ldapsam_privates *ldap_state,
}
/**********************************************************************
- Get SAM_ACCOUNT entry from LDAP by SID.
+ Get struct samu entry from LDAP by SID.
*********************************************************************/
-static NTSTATUS ldapsam_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT * user, const DOM_SID *sid)
+static NTSTATUS ldapsam_getsampwsid(struct pdb_methods *my_methods, struct samu * user, const DOM_SID *sid)
{
struct ldapsam_privates *ldap_state = (struct ldapsam_privates *)my_methods->private_data;
LDAPMessage *result = NULL;
@@ -1581,7 +1577,7 @@ static NTSTATUS ldapsam_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT
pdb_set_backend_private_data(user, result, NULL,
my_methods, PDB_CHANGED);
- talloc_autofree_ldapmsg(user->mem_ctx, result);
+ talloc_autofree_ldapmsg(user, result);
return NT_STATUS_OK;
}
@@ -1596,9 +1592,9 @@ static BOOL ldapsam_can_pwchange_exop(struct smbldap_state *ldap_state)
**********************************************************************/
static NTSTATUS ldapsam_modify_entry(struct pdb_methods *my_methods,
- SAM_ACCOUNT *newpwd, char *dn,
+ struct samu *newpwd, char *dn,
LDAPMod **mods, int ldap_op,
- BOOL (*need_update)(const SAM_ACCOUNT *, enum pdb_elements))
+ BOOL (*need_update)(const struct samu *, enum pdb_elements))
{
struct ldapsam_privates *ldap_state = (struct ldapsam_privates *)my_methods->private_data;
int rc;
@@ -1731,7 +1727,7 @@ static NTSTATUS ldapsam_modify_entry(struct pdb_methods *my_methods,
*********************************************************************/
static NTSTATUS ldapsam_delete_sam_account(struct pdb_methods *my_methods,
- SAM_ACCOUNT * sam_acct)
+ struct samu * sam_acct)
{
struct ldapsam_privates *priv =
(struct ldapsam_privates *)my_methods->private_data;
@@ -1792,17 +1788,17 @@ static NTSTATUS ldapsam_delete_sam_account(struct pdb_methods *my_methods,
we need LDAP modification.
*********************************************************************/
-static BOOL element_is_changed(const SAM_ACCOUNT *sampass,
+static BOOL element_is_changed(const struct samu *sampass,
enum pdb_elements element)
{
return IS_SAM_CHANGED(sampass, element);
}
/**********************************************************************
- Update SAM_ACCOUNT.
+ Update struct samu.
*********************************************************************/
-static NTSTATUS ldapsam_update_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT * newpwd)
+static NTSTATUS ldapsam_update_sam_account(struct pdb_methods *my_methods, struct samu * newpwd)
{
NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
struct ldapsam_privates *ldap_state = (struct ldapsam_privates *)my_methods->private_data;
@@ -1823,7 +1819,7 @@ static NTSTATUS ldapsam_update_sam_account(struct pdb_methods *my_methods, SAM_A
}
pdb_set_backend_private_data(newpwd, result, NULL,
my_methods, PDB_CHANGED);
- talloc_autofree_ldapmsg(newpwd->mem_ctx, result);
+ talloc_autofree_ldapmsg(newpwd, result);
}
if (ldap_count_entries(ldap_state->smbldap_state->ldap_struct, result) == 0) {
@@ -1869,12 +1865,12 @@ static NTSTATUS ldapsam_update_sam_account(struct pdb_methods *my_methods, SAM_A
}
/***************************************************************************
- Renames a SAM_ACCOUNT
+ Renames a struct samu
- The "rename user script" has full responsibility for changing everything
***************************************************************************/
static NTSTATUS ldapsam_rename_sam_account(struct pdb_methods *my_methods,
- SAM_ACCOUNT *old_acct,
+ struct samu *old_acct,
const char *newname)
{
const char *oldname;
@@ -1919,7 +1915,7 @@ static NTSTATUS ldapsam_rename_sam_account(struct pdb_methods *my_methods,
we need LDAP modification.
*********************************************************************/
-static BOOL element_is_set_or_changed(const SAM_ACCOUNT *sampass,
+static BOOL element_is_set_or_changed(const struct samu *sampass,
enum pdb_elements element)
{
return (IS_SAM_SET(sampass, element) ||
@@ -1927,10 +1923,10 @@ static BOOL element_is_set_or_changed(const SAM_ACCOUNT *sampass,
}
/**********************************************************************
- Add SAM_ACCOUNT to LDAP.
+ Add struct samu to LDAP.
*********************************************************************/
-static NTSTATUS ldapsam_add_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT * newpwd)
+static NTSTATUS ldapsam_add_sam_account(struct pdb_methods *my_methods, struct samu * newpwd)
{
NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
struct ldapsam_privates *ldap_state = (struct ldapsam_privates *)my_methods->private_data;
@@ -2561,7 +2557,7 @@ static NTSTATUS ldapsam_enum_group_members(struct pdb_methods *methods,
static NTSTATUS ldapsam_enum_group_memberships(struct pdb_methods *methods,
TALLOC_CTX *mem_ctx,
- SAM_ACCOUNT *user,
+ struct samu *user,
DOM_SID **pp_sids,
gid_t **pp_gids,
size_t *p_num_groups)
diff --git a/source3/passdb/pdb_nds.c b/source3/passdb/pdb_nds.c
index 4bbdeb4dbb..34e550d413 100644
--- a/source3/passdb/pdb_nds.c
+++ b/source3/passdb/pdb_nds.c
@@ -741,7 +741,7 @@ int pdb_nds_set_password(
*********************************************************************/
static NTSTATUS pdb_nds_update_login_attempts(struct pdb_methods *methods,
- SAM_ACCOUNT *sam_acct, BOOL success)
+ struct samu *sam_acct, BOOL success)
{
struct ldapsam_privates *ldap_state;
@@ -780,7 +780,7 @@ static NTSTATUS pdb_nds_update_login_attempts(struct pdb_methods *methods,
}
pdb_set_backend_private_data(sam_acct, result, NULL,
methods, PDB_CHANGED);
- talloc_autofree_ldapmsg(sam_acct->mem_ctx, result);
+ talloc_autofree_ldapmsg(sam_acct, result);
}
if (ldap_count_entries(ldap_state->smbldap_state->ldap_struct, result) == 0) {
diff --git a/source3/passdb/pdb_smbpasswd.c b/source3/passdb/pdb_smbpasswd.c
index 1837b4fcee..ebd5de2258 100644
--- a/source3/passdb/pdb_smbpasswd.c
+++ b/source3/passdb/pdb_smbpasswd.c
@@ -1137,12 +1137,12 @@ Error was %s\n", pwd->smb_name, pfile2, strerror(errno)));
}
/*********************************************************************
- Create a smb_passwd struct from a SAM_ACCOUNT.
+ Create a smb_passwd struct from a struct samu.
We will not allocate any new memory. The smb_passwd struct
- should only stay around as long as the SAM_ACCOUNT does.
+ should only stay around as long as the struct samu does.
********************************************************************/
-static BOOL build_smb_pass (struct smb_passwd *smb_pw, const SAM_ACCOUNT *sampass)
+static BOOL build_smb_pass (struct smb_passwd *smb_pw, const struct samu *sampass)
{
uint32 rid;
@@ -1182,16 +1182,16 @@ static BOOL build_smb_pass (struct smb_passwd *smb_pw, const SAM_ACCOUNT *sampas
}
/*********************************************************************
- Create a SAM_ACCOUNT from a smb_passwd struct
+ Create a struct samu from a smb_passwd struct
********************************************************************/
static BOOL build_sam_account(struct smbpasswd_privates *smbpasswd_state,
- SAM_ACCOUNT *sam_pass, const struct smb_passwd *pw_buf)
+ struct samu *sam_pass, const struct smb_passwd *pw_buf)
{
struct passwd *pwfile;
if (sam_pass==NULL) {
- DEBUG(5,("build_sam_account: SAM_ACCOUNT is NULL\n"));
+ DEBUG(5,("build_sam_account: struct samu is NULL\n"));
return False;
}
@@ -1263,7 +1263,7 @@ static void smbpasswd_endsampwent (struct pdb_methods *my_methods)
/*****************************************************************
****************************************************************/
-static NTSTATUS smbpasswd_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT *user)
+static NTSTATUS smbpasswd_getsampwent(struct pdb_methods *my_methods, struct samu *user)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
struct smbpasswd_privates *smbpasswd_state = (struct smbpasswd_privates*)my_methods->private_data;
@@ -1285,7 +1285,7 @@ static NTSTATUS smbpasswd_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUN
if (pw_buf == NULL)
return nt_status;
- /* build the SAM_ACCOUNT entry from the smb_passwd struct.
+ /* build the struct samu entry from the smb_passwd struct.
We loop in case the user in the pdb does not exist in
the local system password file */
if (build_sam_account(smbpasswd_state, user, pw_buf))
@@ -1305,7 +1305,7 @@ static NTSTATUS smbpasswd_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUN
***************************************************************/
static NTSTATUS smbpasswd_getsampwnam(struct pdb_methods *my_methods,
- SAM_ACCOUNT *sam_acct, const char *username)
+ struct samu *sam_acct, const char *username)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
struct smbpasswd_privates *smbpasswd_state = (struct smbpasswd_privates*)my_methods->private_data;
@@ -1337,14 +1337,14 @@ static NTSTATUS smbpasswd_getsampwnam(struct pdb_methods *my_methods,
DEBUG(10, ("getsampwnam (smbpasswd): found by name: %s\n", smb_pw->smb_name));
if (!sam_acct) {
- DEBUG(10,("getsampwnam (smbpasswd): SAM_ACCOUNT 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;
}
- /* now build the SAM_ACCOUNT */
+ /* now build the struct samu */
if (!build_sam_account(smbpasswd_state, sam_acct, smb_pw))
return nt_status;
@@ -1352,7 +1352,7 @@ static NTSTATUS smbpasswd_getsampwnam(struct pdb_methods *my_methods,
return NT_STATUS_OK;
}
-static NTSTATUS smbpasswd_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT *sam_acct, const DOM_SID *sid)
+static NTSTATUS smbpasswd_getsampwsid(struct pdb_methods *my_methods, struct samu *sam_acct, const DOM_SID *sid)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
struct smbpasswd_privates *smbpasswd_state = (struct smbpasswd_privates*)my_methods->private_data;
@@ -1397,14 +1397,14 @@ static NTSTATUS smbpasswd_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUN
DEBUG(10, ("getsampwrid (smbpasswd): found by name: %s\n", smb_pw->smb_name));
if (!sam_acct) {
- DEBUG(10,("getsampwrid: (smbpasswd) SAM_ACCOUNT 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;
}
- /* now build the SAM_ACCOUNT */
+ /* now build the struct samu */
if (!build_sam_account (smbpasswd_state, sam_acct, smb_pw))
return nt_status;
@@ -1420,12 +1420,12 @@ static NTSTATUS smbpasswd_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUN
return NT_STATUS_OK;
}
-static NTSTATUS smbpasswd_add_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT *sampass)
+static NTSTATUS smbpasswd_add_sam_account(struct pdb_methods *my_methods, struct samu *sampass)
{
struct smbpasswd_privates *smbpasswd_state = (struct smbpasswd_privates*)my_methods->private_data;
struct smb_passwd smb_pw;
- /* convert the SAM_ACCOUNT */
+ /* convert the struct samu */
if (!build_smb_pass(&smb_pw, sampass)) {
return NT_STATUS_UNSUCCESSFUL;
}
@@ -1438,12 +1438,12 @@ static NTSTATUS smbpasswd_add_sam_account(struct pdb_methods *my_methods, SAM_AC
return NT_STATUS_OK;
}
-static NTSTATUS smbpasswd_update_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT *sampass)
+static NTSTATUS smbpasswd_update_sam_account(struct pdb_methods *my_methods, struct samu *sampass)
{
struct smbpasswd_privates *smbpasswd_state = (struct smbpasswd_privates*)my_methods->private_data;
struct smb_passwd smb_pw;
- /* convert the SAM_ACCOUNT */
+ /* convert the struct samu */
if (!build_smb_pass(&smb_pw, sampass)) {
DEBUG(0, ("smbpasswd_update_sam_account: build_smb_pass failed!\n"));
return NT_STATUS_UNSUCCESSFUL;
@@ -1458,7 +1458,7 @@ static NTSTATUS smbpasswd_update_sam_account(struct pdb_methods *my_methods, SAM
return NT_STATUS_OK;
}
-static NTSTATUS smbpasswd_delete_sam_account (struct pdb_methods *my_methods, SAM_ACCOUNT *sampass)
+static NTSTATUS smbpasswd_delete_sam_account (struct pdb_methods *my_methods, struct samu *sampass)
{
struct smbpasswd_privates *smbpasswd_state = (struct smbpasswd_privates*)my_methods->private_data;
@@ -1471,11 +1471,11 @@ static NTSTATUS smbpasswd_delete_sam_account (struct pdb_methods *my_methods, SA
}
static NTSTATUS smbpasswd_rename_sam_account (struct pdb_methods *my_methods,
- SAM_ACCOUNT *old_acct,
+ struct samu *old_acct,
const char *newname)
{
pstring rename_script;
- SAM_ACCOUNT *new_acct = NULL;
+ struct samu *new_acct = NULL;
BOOL interim_account = False;
NTSTATUS ret = NT_STATUS_UNSUCCESSFUL;
@@ -1520,7 +1520,7 @@ done:
smbpasswd_delete_sam_account(my_methods, new_acct);
if (new_acct)
- pdb_free_sam(&new_acct);
+ TALLOC_FREE(new_acct);
return (ret);
}
diff --git a/source3/passdb/pdb_tdb.c b/source3/passdb/pdb_tdb.c
index e7f5e0cac9..a5e2f7ae02 100644
--- a/source3/passdb/pdb_tdb.c
+++ b/source3/passdb/pdb_tdb.c
@@ -68,7 +68,6 @@ static pstring tdbsam_filename;
static BOOL tdbsam_convert(int32 from)
{
const char *vstring = TDBSAM_VERSION_STRING;
- SAM_ACCOUNT *user = NULL;
const char *prefix = USERPREFIX;
TDB_DATA data, key, old_key;
uint8 *buf = NULL;
@@ -77,11 +76,6 @@ static BOOL tdbsam_convert(int32 from)
/* handle a Samba upgrade */
tdb_lock_bystring(tdbsam, vstring, 0);
- if ( !NT_STATUS_IS_OK(pdb_init_sam(&user)) ) {
- DEBUG(0,("tdbsam_convert: cannot initialized a SAM_ACCOUNT.\n"));
- return False;
- }
-
/* Enumerate all records and convert them */
key = tdb_firstkey(tdbsam);
@@ -96,7 +90,8 @@ static BOOL tdbsam_convert(int32 from)
}
if (key.dptr) {
-
+ struct samu *user = NULL;
+
/* read from tdbsam */
data = tdb_fetch(tdbsam, key);
if (!data.dptr) {
@@ -104,13 +99,8 @@ static BOOL tdbsam_convert(int32 from)
return False;
}
- if (!NT_STATUS_IS_OK(pdb_reset_sam(user))) {
- DEBUG(0,("tdbsam_convert: cannot reset SAM_ACCOUNT.\n"));
- SAFE_FREE(data.dptr);
- return False;
- }
-
/* unpack the buffer from the former format */
+ pdb_init_sam( &user );
DEBUG(10,("tdbsam_convert: Try unpacking a record with (key:%s) (version:%d)\n", key.dptr, from));
switch (from) {
case 0:
@@ -127,8 +117,9 @@ static BOOL tdbsam_convert(int32 from)
ret = False;
}
if (!ret) {
- DEBUG(0,("tdbsam_convert: Bad SAM_ACCOUNT entry returned from TDB (key:%s) (version:%d)\n", key.dptr, from));
+ DEBUG(0,("tdbsam_convert: Bad struct samu entry returned from TDB (key:%s) (version:%d)\n", key.dptr, from));
SAFE_FREE(data.dptr);
+ TALLOC_FREE(user );
return False;
}
@@ -136,17 +127,20 @@ static BOOL tdbsam_convert(int32 from)
SAFE_FREE(data.dptr);
/* pack from the buffer into the new format */
+
DEBUG(10,("tdbsam_convert: Try packing a record (key:%s) (version:%d)\n", key.dptr, from));
- if ((data.dsize=init_buffer_from_sam (&buf, user, False)) == -1) {
- DEBUG(0,("tdbsam_convert: cannot pack the SAM_ACCOUNT into the new format\n"));
- SAFE_FREE(data.dptr);
+ data.dsize = init_buffer_from_sam (&buf, user, False);
+ TALLOC_FREE(user );
+
+ if ( data.dsize == -1 ) {
+ DEBUG(0,("tdbsam_convert: cannot pack the struct samu into the new format\n"));
return False;
}
data.dptr = (char *)buf;
/* Store the buffer inside the TDBSAM */
if (tdb_store(tdbsam, key, data, TDB_MODIFY) != TDB_SUCCESS) {
- DEBUG(0,("tdbsam_convert: cannot store the SAM_ACCOUNT (key:%s) in new format\n",key.dptr));
+ DEBUG(0,("tdbsam_convert: cannot store the struct samu (key:%s) in new format\n",key.dptr));
SAFE_FREE(data.dptr);
return False;
}
@@ -161,7 +155,6 @@ static BOOL tdbsam_convert(int32 from)
}
- pdb_free_sam(&user);
/* upgrade finished */
tdb_store_int32(tdbsam, vstring, TDBSAM_VERSION);
@@ -293,8 +286,13 @@ static int tdbsam_traverse_setpwent(TDB_CONTEXT *t, TDB_DATA key, TDB_DATA data,
static NTSTATUS tdbsam_setsampwent(struct pdb_methods *my_methods, BOOL update, uint16 acb_mask)
{
+ if ( !tdbsam_open( tdbsam_filename ) ) {
+ DEBUG(0,("tdbsam_getsampwnam: failed to open %s!\n", tdbsam_filename));
+ return NT_STATUS_ACCESS_DENIED;
+ }
+
tdb_traverse( tdbsam, tdbsam_traverse_setpwent, NULL );
-
+
return NT_STATUS_OK;
}
@@ -317,20 +315,22 @@ static void tdbsam_endsampwent(struct pdb_methods *my_methods)
}
DEBUG(7, ("endtdbpwent: closed sam database.\n"));
+
+ tdbsam_close();
}
/*****************************************************************
- Get one SAM_ACCOUNT from the TDB (next in line)
+ Get one struct samu from the TDB (next in line)
*****************************************************************/
-static NTSTATUS tdbsam_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT *user)
+static NTSTATUS tdbsam_getsampwent(struct pdb_methods *my_methods, struct samu *user)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
TDB_DATA data;
struct pwent_list *pkey;
if ( !user ) {
- DEBUG(0,("tdbsam_getsampwent: SAM_ACCOUNT is NULL.\n"));
+ DEBUG(0,("tdbsam_getsampwent: struct samu is NULL.\n"));
return nt_status;
}
@@ -355,7 +355,7 @@ static NTSTATUS tdbsam_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT *
}
if ( !init_sam_from_buffer(user, (unsigned char *)data.dptr, data.dsize) ) {
- DEBUG(0,("pdb_getsampwent: Bad SAM_ACCOUNT entry returned from TDB!\n"));
+ DEBUG(0,("pdb_getsampwent: Bad struct samu entry returned from TDB!\n"));
}
SAFE_FREE( data.dptr );
@@ -367,7 +367,7 @@ static NTSTATUS tdbsam_getsampwent(struct pdb_methods *my_methods, SAM_ACCOUNT *
Lookup a name in the SAM TDB
******************************************************************/
-static NTSTATUS tdbsam_getsampwnam (struct pdb_methods *my_methods, SAM_ACCOUNT *user, const char *sname)
+static NTSTATUS tdbsam_getsampwnam (struct pdb_methods *my_methods, struct samu *user, const char *sname)
{
NTSTATUS result;
TDB_DATA data, key;
@@ -375,7 +375,7 @@ static NTSTATUS tdbsam_getsampwnam (struct pdb_methods *my_methods, SAM_ACCOUNT
fstring name;
if ( !user ) {
- DEBUG(0,("pdb_getsampwnam: SAM_ACCOUNT is NULL.\n"));
+ DEBUG(0,("pdb_getsampwnam: struct samu is NULL.\n"));
return NT_STATUS_NO_MEMORY;
}
@@ -409,7 +409,7 @@ static NTSTATUS tdbsam_getsampwnam (struct pdb_methods *my_methods, SAM_ACCOUNT
/* unpack the buffer */
if (!init_sam_from_buffer(user, (unsigned char *)data.dptr, data.dsize)) {
- DEBUG(0,("pdb_getsampwent: Bad SAM_ACCOUNT entry returned from TDB!\n"));
+ DEBUG(0,("pdb_getsampwent: Bad struct samu entry returned from TDB!\n"));
SAFE_FREE(data.dptr);
result = NT_STATUS_NO_MEMORY;
goto done;
@@ -428,7 +428,7 @@ static NTSTATUS tdbsam_getsampwnam (struct pdb_methods *my_methods, SAM_ACCOUNT
Search by rid
**************************************************************************/
-static NTSTATUS tdbsam_getsampwrid (struct pdb_methods *my_methods, SAM_ACCOUNT *user, uint32 rid)
+static NTSTATUS tdbsam_getsampwrid (struct pdb_methods *my_methods, struct samu *user, uint32 rid)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
TDB_DATA data, key;
@@ -436,7 +436,7 @@ static NTSTATUS tdbsam_getsampwrid (struct pdb_methods *my_methods, SAM_ACCOUNT
fstring name;
if ( !user ) {
- DEBUG(0,("pdb_getsampwrid: SAM_ACCOUNT is NULL.\n"));
+ DEBUG(0,("pdb_getsampwrid: struct samu is NULL.\n"));
return nt_status;
}
@@ -476,7 +476,7 @@ static NTSTATUS tdbsam_getsampwrid (struct pdb_methods *my_methods, SAM_ACCOUNT
return nt_status;
}
-static NTSTATUS tdbsam_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT * user, const DOM_SID *sid)
+static NTSTATUS tdbsam_getsampwsid(struct pdb_methods *my_methods, struct samu * user, const DOM_SID *sid)
{
uint32 rid;
@@ -486,7 +486,7 @@ static NTSTATUS tdbsam_getsampwsid(struct pdb_methods *my_methods, SAM_ACCOUNT *
return tdbsam_getsampwrid(my_methods, user, rid);
}
-static BOOL tdb_delete_samacct_only( SAM_ACCOUNT *sam_pass )
+static BOOL tdb_delete_samacct_only( struct samu *sam_pass )
{
TDB_DATA key;
fstring keystr;
@@ -513,10 +513,10 @@ static BOOL tdb_delete_samacct_only( SAM_ACCOUNT *sam_pass )
}
/***************************************************************************
- Delete a SAM_ACCOUNT records for the username and RID key
+ Delete a struct samu records for the username and RID key
****************************************************************************/
-static NTSTATUS tdbsam_delete_sam_account(struct pdb_methods *my_methods, SAM_ACCOUNT *sam_pass)
+static NTSTATUS tdbsam_delete_sam_account(struct pdb_methods *my_methods, struct samu *sam_pass)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
TDB_DATA key;
@@ -587,7 +587,7 @@ static NTSTATUS tdbsam_delete_sam_account(struct pdb_methods *my_methods, SAM_AC
Update the TDB SAM account record only
Assumes that the tdbsam is already open
****************************************************************************/
-static BOOL tdb_update_samacct_only( SAM_ACCOUNT* newpwd, int flag )
+static BOOL tdb_update_samacct_only( struct samu* newpwd, int flag )
{
TDB_DATA key, data;
uint8 *buf = NULL;
@@ -595,10 +595,10 @@ static BOOL tdb_update_samacct_only( SAM_ACCOUNT* newpwd, int flag )
fstring name;
BOOL ret = True;
- /* copy the SAM_ACCOUNT struct into a BYTE buffer for storage */
+ /* copy the struct samu struct into a BYTE buffer for storage */
if ( (data.dsize=init_buffer_from_sam (&buf, newpwd, False)) == -1 ) {
- DEBUG(0,("tdb_update_sam: ERROR - Unable to copy SAM_ACCOUNT info BYTE buffer!\n"));
+ DEBUG(0,("tdb_update_sam: ERROR - Unable to copy struct samu info BYTE buffer!\n"));
ret = False;
goto done;
}
@@ -638,7 +638,7 @@ done:
Update the TDB SAM RID record only
Assumes that the tdbsam is already open
****************************************************************************/
-static BOOL tdb_update_ridrec_only( SAM_ACCOUNT* newpwd, int flag )
+static BOOL tdb_update_ridrec_only( struct samu* newpwd, int flag )
{
TDB_DATA key, data;
fstring keystr;
@@ -672,7 +672,7 @@ static BOOL tdb_update_ridrec_only( SAM_ACCOUNT* newpwd, int flag )
Update the TDB SAM
****************************************************************************/
-static BOOL tdb_update_sam(struct pdb_methods *my_methods, SAM_ACCOUNT* newpwd, int flag)
+static BOOL tdb_update_sam(struct pdb_methods *my_methods, struct samu* newpwd, int flag)
{
uint32 user_rid;
BOOL result = True;
@@ -682,13 +682,13 @@ static BOOL tdb_update_sam(struct pdb_methods *my_methods, SAM_ACCOUNT* newpwd,
tdbsam_endsampwent( my_methods );
if ( !pdb_get_group_rid(newpwd) ) {
- DEBUG (0,("tdb_update_sam: Failing to store a SAM_ACCOUNT for [%s] "
+ DEBUG (0,("tdb_update_sam: Failing to store a struct samu for [%s] "
"without a primary group RID\n", pdb_get_username(newpwd)));
return False;
}
if ( !(user_rid = pdb_get_user_rid(newpwd)) ) {
- DEBUG(0,("tdb_update_sam: SAM_ACCOUNT (%s) with no RID!\n", pdb_get_username(newpwd)));
+ DEBUG(0,("tdb_update_sam: struct samu (%s) with no RID!\n", pdb_get_username(newpwd)));
return False;
}
@@ -711,10 +711,10 @@ static BOOL tdb_update_sam(struct pdb_methods *my_methods, SAM_ACCOUNT* newpwd,
}
/***************************************************************************
- Modifies an existing SAM_ACCOUNT
+ Modifies an existing struct samu
****************************************************************************/
-static NTSTATUS tdbsam_update_sam_account (struct pdb_methods *my_methods, SAM_ACCOUNT *newpwd)
+static NTSTATUS tdbsam_update_sam_account (struct pdb_methods *my_methods, struct samu *newpwd)
{
if ( !tdb_update_sam(my_methods, newpwd, TDB_MODIFY) )
return NT_STATUS_UNSUCCESSFUL;
@@ -723,10 +723,10 @@ static NTSTATUS tdbsam_update_sam_account (struct pdb_methods *my_methods, SAM_A
}
/***************************************************************************
- Adds an existing SAM_ACCOUNT
+ Adds an existing struct samu
****************************************************************************/
-static NTSTATUS tdbsam_add_sam_account (struct pdb_methods *my_methods, SAM_ACCOUNT *newpwd)
+static NTSTATUS tdbsam_add_sam_account (struct pdb_methods *my_methods, struct samu *newpwd)
{
if ( !tdb_update_sam(my_methods, newpwd, TDB_INSERT) )
return NT_STATUS_UNSUCCESSFUL;
@@ -735,7 +735,7 @@ static NTSTATUS tdbsam_add_sam_account (struct pdb_methods *my_methods, SAM_ACCO
}
/***************************************************************************
- Renames a SAM_ACCOUNT
+ Renames a struct samu
- check for the posix user/rename user script
- Add and lock the new user record
- rename the posix user
@@ -744,10 +744,10 @@ static NTSTATUS tdbsam_add_sam_account (struct pdb_methods *my_methods, SAM_ACCO
- unlock the new user record
***************************************************************************/
static NTSTATUS tdbsam_rename_sam_account(struct pdb_methods *my_methods,
- SAM_ACCOUNT *old_acct,
+ struct samu *old_acct,
const char *newname)
{
- SAM_ACCOUNT *new_acct = NULL;
+ struct samu *new_acct = NULL;
pstring rename_script;
BOOL interim_account = False;
int rename_ret;
@@ -773,7 +773,7 @@ static NTSTATUS tdbsam_rename_sam_account(struct pdb_methods *my_methods,
if ( !pdb_copy_sam_account(old_acct, &new_acct)
|| !pdb_set_username(new_acct, newname, PDB_CHANGED))
{
- pdb_free_sam( &new_acct );
+ TALLOC_FREE(new_acct );
return NT_STATUS_NO_MEMORY;
}
@@ -781,7 +781,7 @@ static NTSTATUS tdbsam_rename_sam_account(struct pdb_methods *my_methods,
if ( !tdbsam_open( tdbsam_filename ) ) {
DEBUG(0,("tdbsam_getsampwnam: failed to open %s!\n", tdbsam_filename));
- pdb_free_sam( &new_acct );
+ TALLOC_FREE(new_acct );
return NT_STATUS_ACCESS_DENIED;
}
@@ -820,7 +820,7 @@ static NTSTATUS tdbsam_rename_sam_account(struct pdb_methods *my_methods,
tdbsam_close();
- pdb_free_sam( &new_acct );
+ TALLOC_FREE(new_acct );
return NT_STATUS_OK;
done:
@@ -833,7 +833,7 @@ done:
tdbsam_close();
if (new_acct)
- pdb_free_sam(&new_acct);
+ TALLOC_FREE(new_acct);
return NT_STATUS_ACCESS_DENIED;
}