diff options
author | Andrew Bartlett <abartlet@samba.org> | 2002-06-14 06:23:42 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2002-06-14 06:23:42 +0000 |
commit | a8748f886ad6bda17cf97d2e7baaa2968cf5f696 (patch) | |
tree | 136a6362fc58da2296f932018582f9c641b93e0a /source3 | |
parent | f1b393ce11245fb7bc4488a5377fa516fb4ae17a (diff) | |
download | samba-a8748f886ad6bda17cf97d2e7baaa2968cf5f696.tar.gz samba-a8748f886ad6bda17cf97d2e7baaa2968cf5f696.tar.bz2 samba-a8748f886ad6bda17cf97d2e7baaa2968cf5f696.zip |
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 used to be commit dfa98ae0ac195956490ca2f4140a8eff1566095e)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/passdb/pdb_interface.c | 19 | ||||
-rw-r--r-- | source3/passdb/pdb_smbpasswd.c | 13 |
2 files changed, 20 insertions, 12 deletions
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c index a0f9ff5ec6..da013f6851 100644 --- a/source3/passdb/pdb_interface.c +++ b/source3/passdb/pdb_interface.c @@ -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; } diff --git a/source3/passdb/pdb_smbpasswd.c b/source3/passdb/pdb_smbpasswd.c index 25957100d8..09277e2d23 100644 --- a/source3/passdb/pdb_smbpasswd.c +++ b/source3/passdb/pdb_smbpasswd.c @@ -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")); } /************************************************************************* |