1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

It looks like we never tested the 'cleanup' code, so when I triggered it

(invalid passdb backends smb.conf entry) we picked up a few things :-).

Andrew Bartlett
This commit is contained in:
Andrew Bartlett 0001-01-01 00:00:00 +00:00
parent c8c490bcb8
commit dfa98ae0ac
2 changed files with 20 additions and 12 deletions

View File

@ -222,8 +222,9 @@ static void free_pdb_context(struct pdb_context **context)
struct pdb_methods *pdb_selected = (*context)->pdb_methods;
while (pdb_selected){
if (pdb_selected->free_private_data)
pdb_selected->free_private_data(pdb_selected->private_data);
if (pdb_selected->free_private_data) {
pdb_selected->free_private_data(&(pdb_selected->private_data));
}
pdb_selected = pdb_selected->next;
}
@ -258,19 +259,20 @@ static NTSTATUS make_pdb_methods_name(struct pdb_methods **methods, struct pdb_c
if (strequal(builtin_pdb_init_functions[i].name, module_name))
{
DEBUG(5,("Found pdb backend %s (at pos %d)\n", module_name, i));
if (NT_STATUS_IS_OK(nt_status
= builtin_pdb_init_functions[i].init(context, methods, module_location))) {
nt_status = builtin_pdb_init_functions[i].init(context, methods, module_location);
if (NT_STATUS_IS_OK(nt_status)) {
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;
SAFE_FREE(module_name);
return nt_status;
break; /* unreached */
}
}
/* No such backend found */
SAFE_FREE(module_name);
return NT_STATUS_INVALID_PARAMETER;
}
@ -332,8 +334,7 @@ NTSTATUS make_pdb_context_list(struct pdb_context **context, char **selected)
/* 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]))) {
DEBUG(5, ("Loading %s failed!\n", selected[i]));
SAFE_FREE(curmethods);
DEBUG(1, ("Loading %s failed!\n", selected[i]));
free_pdb_context(context);
return nt_status;
}

View File

@ -101,6 +101,10 @@ static BOOL pw_file_unlock(int fd, int *plock_depth)
{
BOOL ret=True;
if (fd == 0 || *plock_depth == 0) {
return True;
}
if(*plock_depth == 1)
ret = do_file_lock(fd, 5, F_UNLCK);
@ -264,10 +268,13 @@ Error was %s\n.", pfile, strerror(errno) ));
****************************************************************/
static void endsmbfilepwent(FILE *fp, int *lock_depth)
{
if (!fp) {
return;
}
pw_file_unlock(fileno(fp), lock_depth);
fclose(fp);
DEBUG(7, ("endsmbfilepwent_internal: closed password file.\n"));
pw_file_unlock(fileno(fp), lock_depth);
fclose(fp);
DEBUG(7, ("endsmbfilepwent_internal: closed password file.\n"));
}
/*************************************************************************