bool nt_printing_tdb_migrate(struct messaging_context *msg_ctx)
{
- const char *drivers_path = state_path("ntdrivers.tdb");
- const char *printers_path = state_path("ntprinters.tdb");
- const char *forms_path = state_path("ntforms.tdb");
- bool drivers_exists = file_exist(drivers_path);
- bool printers_exists = file_exist(printers_path);
- bool forms_exists = file_exist(forms_path);
+ const char *drivers_path;
+ const char *printers_path;
+ const char *forms_path;
+ bool drivers_exists;
+ bool printers_exists;
+ bool forms_exists;
struct auth_session_info *session_info;
struct rpc_pipe_client *winreg_pipe = NULL;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
NTSTATUS status;
+ /* paths talloced on new stackframe */
+ drivers_path = state_path("ntdrivers.tdb");
+ printers_path = state_path("ntprinters.tdb");
+ forms_path = state_path("ntforms.tdb");
+ if ((drivers_path == NULL) || (printers_path == NULL)
+ || (forms_path == NULL)) {
+ talloc_free(tmp_ctx);
+ return false;
+ }
+ drivers_exists = file_exist(drivers_path);
+ printers_exists = file_exist(printers_path);
+ forms_exists = file_exist(forms_path);
+
if (!drivers_exists && !printers_exists && !forms_exists) {
talloc_free(tmp_ctx);
return true;
bool nt_printing_tdb_upgrade(void)
{
- const char *drivers_path = state_path("ntdrivers.tdb");
- const char *printers_path = state_path("ntprinters.tdb");
- const char *forms_path = state_path("ntforms.tdb");
- bool drivers_exists = file_exist(drivers_path);
- bool printers_exists = file_exist(printers_path);
- bool forms_exists = file_exist(forms_path);
+ char *drivers_path;
+ char *printers_path;
+ char *forms_path;
+ bool drivers_exists;
+ bool printers_exists;
+ bool forms_exists;
const char *vstring = "INFO/version";
int32_t vers_id;
+ bool ret;
+
+ drivers_path = state_path("ntdrivers.tdb");
+ if (drivers_path == NULL) {
+ ret = false;
+ goto err_out;
+ }
+ printers_path = state_path("ntprinters.tdb");
+ if (printers_path == NULL) {
+ ret = false;
+ goto err_drvdb_free;
+ }
+ forms_path = state_path("ntforms.tdb");
+ if (forms_path == NULL) {
+ ret = false;
+ goto err_prdb_free;
+ }
+
+ drivers_exists = file_exist(drivers_path);
+ printers_exists = file_exist(printers_path);
+ forms_exists = file_exist(forms_path);
if (!drivers_exists && !printers_exists && !forms_exists) {
- return true;
+ ret = true;
+ goto err_formsdb_free;
}
tdb_drivers = tdb_open_log(drivers_path,
DEBUG(0,("nt_printing_init: Failed to open nt drivers "
"database %s (%s)\n",
drivers_path, strerror(errno)));
- return false;
+ ret = false;
+ goto err_formsdb_free;
}
tdb_printers = tdb_open_log(printers_path,
DEBUG(0,("nt_printing_init: Failed to open nt printers "
"database %s (%s)\n",
printers_path, strerror(errno)));
- return false;
+ ret = false;
+ goto err_drvdb_close;
}
tdb_forms = tdb_open_log(forms_path,
DEBUG(0,("nt_printing_init: Failed to open nt forms "
"database %s (%s)\n",
forms_path, strerror(errno)));
- return false;
+ ret = false;
+ goto err_prdb_close;
}
/* Samba upgrade */
if ((vers_id == NTDRIVERS_DATABASE_VERSION_1) ||
(IREV(vers_id) == NTDRIVERS_DATABASE_VERSION_1)) {
if (!upgrade_to_version_3()) {
- return false;
+ ret = false;
+ goto err_formsdb_close;
}
tdb_store_int32(tdb_drivers, vstring, NTDRIVERS_DATABASE_VERSION_3);
if (vers_id == NTDRIVERS_DATABASE_VERSION_3) {
if (!upgrade_to_version_4()) {
- return false;
+ ret = false;
+ goto err_formsdb_close;
}
tdb_store_int32(tdb_drivers, vstring, NTDRIVERS_DATABASE_VERSION_4);
vers_id = NTDRIVERS_DATABASE_VERSION_4;
if (vers_id == NTDRIVERS_DATABASE_VERSION_4 ) {
if (!upgrade_to_version_5()) {
- return false;
+ ret = false;
+ goto err_formsdb_close;
}
tdb_store_int32(tdb_drivers, vstring, NTDRIVERS_DATABASE_VERSION_5);
vers_id = NTDRIVERS_DATABASE_VERSION_5;
if (vers_id != NTDRIVERS_DATABASE_VERSION_5) {
DEBUG(0,("nt_printing_init: Unknown printer database version [%d]\n", vers_id));
- return false;
+ ret = false;
+ goto err_formsdb_close;
}
}
+ ret = true;
- if (tdb_drivers) {
- tdb_close(tdb_drivers);
- tdb_drivers = NULL;
+err_formsdb_close:
+ if (tdb_forms) {
+ tdb_close(tdb_forms);
+ tdb_forms = NULL;
}
-
+err_prdb_close:
if (tdb_printers) {
tdb_close(tdb_printers);
tdb_printers = NULL;
}
-
- if (tdb_forms) {
- tdb_close(tdb_forms);
- tdb_forms = NULL;
+err_drvdb_close:
+ if (tdb_drivers) {
+ tdb_close(tdb_drivers);
+ tdb_drivers = NULL;
}
-
- return true;
+err_formsdb_free:
+ talloc_free(forms_path);
+err_prdb_free:
+ talloc_free(printers_path);
+err_drvdb_free:
+ talloc_free(drivers_path);
+err_out:
+ return ret;
}