summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2002-06-14 04:45:04 +0000
committerAndrew Bartlett <abartlet@samba.org>2002-06-14 04:45:04 +0000
commitf1b393ce11245fb7bc4488a5377fa516fb4ae17a (patch)
tree05055032cab3c8e86c76c7ae5fece626cd075b03
parenta2f07662a1637a6ee7802fa2d3d12c1227118e28 (diff)
downloadsamba-f1b393ce11245fb7bc4488a5377fa516fb4ae17a.tar.gz
samba-f1b393ce11245fb7bc4488a5377fa516fb4ae17a.tar.bz2
samba-f1b393ce11245fb7bc4488a5377fa516fb4ae17a.zip
Some updates from ctrlsoft <jelmer@nl.linux.org> to return failure if *any* of
the passdb backends fail to load (is this the right way? - I think so). Also, I've added some more comments, cleaned up some style etc. (This used to be commit c8c490bcb84df43be38bdcb48067fec12331e358)
-rw-r--r--source3/passdb/pdb_interface.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index 7ecc237cf4..a0f9ff5ec6 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -52,9 +52,10 @@ static BOOL context_setsampwent(struct pdb_context *context, BOOL update)
return True;
}
- while(!(context->pwent_methods->setsampwent(context->pwent_methods, update))){
+ while (!(context->pwent_methods->setsampwent(context->pwent_methods, update))) {
context->pwent_methods = context->pwent_methods->next;
- if(context->pwent_methods == NULL)return False;
+ if (context->pwent_methods == NULL)
+ return False;
}
return True;
}
@@ -93,7 +94,7 @@ static BOOL context_getsampwent(struct pdb_context *context, SAM_ACCOUNT *user)
return False;
if (!context->pwent_methods->setsampwent){
- DEBUG(5, ("invalid context->pwent_methods->setsampwent\n"));
+ DEBUG(5, ("next backend does not implment setsampwent\n"));
return False;
}
@@ -190,7 +191,10 @@ static BOOL context_delete_sam_account(struct pdb_context *context, SAM_ACCOUNT
if (!sam_acct->methods){
pdb_selected = context->pdb_methods;
/* There's no passdb backend specified for this account.
- * Try to delete it in every passdb available */
+ * Try to delete it in every passdb available
+ * Needed to delete accounts in smbpasswd that are not
+ * in /etc/passwd.
+ */
while (pdb_selected){
if (pdb_selected->delete_sam_account && pdb_selected->delete_sam_account(pdb_selected, sam_acct)){
return True;
@@ -208,6 +212,11 @@ static BOOL context_delete_sam_account(struct pdb_context *context, SAM_ACCOUNT
return sam_acct->methods->delete_sam_account(sam_acct->methods, sam_acct);
}
+/******************************************************************
+ Free and cleanup a pdb context, any associated data and anything
+ that the attached modules might have associated.
+ *******************************************************************/
+
static void free_pdb_context(struct pdb_context **context)
{
struct pdb_methods *pdb_selected = (*context)->pdb_methods;
@@ -252,22 +261,17 @@ static NTSTATUS make_pdb_methods_name(struct pdb_methods **methods, struct pdb_c
if (NT_STATUS_IS_OK(nt_status
= builtin_pdb_init_functions[i].init(context, methods, module_location))) {
DEBUG(5,("pdb backend %s has a valid init\n", selected));
+ return nt_status;
} else {
DEBUG(0,("pdb backend %s did not correctly init (error was %s)\n", selected, nt_errstr(nt_status)));
+ return nt_status;
}
break;
}
}
- if (!*methods) {
- DEBUG(0,("failed to select passdb backed!\n"));
- if (NT_STATUS_IS_OK(nt_status)) {
- return NT_STATUS_INVALID_PARAMETER;
- } else {
- return nt_status;
- }
- }
- return NT_STATUS_OK;
+ /* No such backend found */
+ return NT_STATUS_INVALID_PARAMETER;
}
/******************************************************************
@@ -304,9 +308,6 @@ static NTSTATUS make_pdb_context(struct pdb_context **context)
(*context)->pdb_update_sam_account = context_update_sam_account;
(*context)->pdb_delete_sam_account = context_delete_sam_account;
- (*context)->pdb_methods = NULL;
- (*context)->pwent_methods = NULL;
-
(*context)->free_fn = free_pdb_context;
return NT_STATUS_OK;
@@ -323,14 +324,14 @@ NTSTATUS make_pdb_context_list(struct pdb_context **context, char **selected)
struct pdb_methods *curmethods, *tmpmethods;
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
- if(!NT_STATUS_IS_OK(nt_status = make_pdb_context(context))){
+ if (!NT_STATUS_IS_OK(nt_status = make_pdb_context(context))) {
return nt_status;
}
- while(selected[i]){
+ while (selected[i]){
/* Try to initialise pdb */
DEBUG(5,("Trying to load: %s\n", selected[i]));
- if(!NT_STATUS_IS_OK(nt_status = make_pdb_methods_name(&curmethods, *context, selected[i]))){
+ if (!NT_STATUS_IS_OK(nt_status = make_pdb_methods_name(&curmethods, *context, selected[i]))) {
DEBUG(5, ("Loading %s failed!\n", selected[i]));
SAFE_FREE(curmethods);
free_pdb_context(context);