summaryrefslogtreecommitdiff
path: root/source3/printing/nt_printing.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-07-30 23:12:48 +0000
committerJeremy Allison <jra@samba.org>2001-07-30 23:12:48 +0000
commita62c6e81fcf952d8937918a6d672b4b7ade07c76 (patch)
tree351f16198a3e840d2d4f85ee146286f985895f41 /source3/printing/nt_printing.c
parent996719cce26700c68ff0e456e6a25d20085d091f (diff)
downloadsamba-a62c6e81fcf952d8937918a6d672b4b7ade07c76.tar.gz
samba-a62c6e81fcf952d8937918a6d672b4b7ade07c76.tar.bz2
samba-a62c6e81fcf952d8937918a6d672b4b7ade07c76.zip
Fixup error returns in updating driver db version.
Jeremy. (This used to be commit 5bd39ce233fd14d01f434f39ce53e3e77b428845)
Diffstat (limited to 'source3/printing/nt_printing.c')
-rw-r--r--source3/printing/nt_printing.c62
1 files changed, 40 insertions, 22 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 57011dc9cc..c2c98d05bb 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -176,43 +176,59 @@ static nt_forms_struct default_forms[] = {
{"PRC Envelope #10 Rotated",0x1,0x6fd10,0x4f1a0,0x0,0x0,0x6fd10,0x4f1a0}
};
-static void upgrade_to_version_2(void)
+static BOOL upgrade_to_version_2(void)
{
TDB_DATA kbuf, newkey, dbuf;
+
+ DEBUG(0,("upgrade_to_version_2: upgrading print tdb's to version 2\n"));
+
+ for (kbuf = tdb_firstkey(tdb_drivers); kbuf.dptr;
+ newkey = tdb_nextkey(tdb_drivers, kbuf), safe_free(kbuf.dptr), kbuf=newkey) {
- DEBUG(0,("upgrade_to_version_2:upgrading to version 2\n"));
-
- for (kbuf = tdb_firstkey(tdb_drivers);
- kbuf.dptr;
- newkey = tdb_nextkey(tdb_drivers, kbuf), safe_free(kbuf.dptr), kbuf=newkey) {
dbuf = tdb_fetch(tdb_drivers, kbuf);
if (strncmp(kbuf.dptr, FORMS_PREFIX, strlen(FORMS_PREFIX)) == 0) {
DEBUG(0,("upgrade_to_version_2:moving form\n"));
- if (tdb_store(tdb_forms, kbuf, dbuf, TDB_REPLACE) != 0) break;
- tdb_delete(tdb_drivers, kbuf);
+ if (tdb_store(tdb_forms, kbuf, dbuf, TDB_REPLACE) != 0) {
+ DEBUG(0,("upgrade_to_version_2: failed to move form. Error (%s).\n", tdb_errorstr(tdb_forms)));
+ return False;
+ }
+ if (tdb_delete(tdb_drivers, kbuf) != 0) {
+ DEBUG(0,("upgrade_to_version_2: failed to delete form. Error (%s)\n", tdb_errorstr(tdb_drivers)));
+ return False;
+ }
}
-
+
if (strncmp(kbuf.dptr, PRINTERS_PREFIX, strlen(PRINTERS_PREFIX)) == 0) {
DEBUG(0,("upgrade_to_version_2:moving printer\n"));
- if (tdb_store(tdb_printers, kbuf, dbuf, TDB_REPLACE) != 0) break;
- tdb_delete(tdb_drivers, kbuf);
+ if (tdb_store(tdb_printers, kbuf, dbuf, TDB_REPLACE) != 0) {
+ DEBUG(0,("upgrade_to_version_2: failed to move printer. Error (%s)\n", tdb_errorstr(tdb_printers)));
+ return False;
+ }
+ if (tdb_delete(tdb_drivers, kbuf) != 0) {
+ DEBUG(0,("upgrade_to_version_2: failed to delete printer. Error (%s)\n", tdb_errorstr(tdb_drivers)));
+ return False;
+ }
}
-
+
if (strncmp(kbuf.dptr, SECDESC_PREFIX, strlen(SECDESC_PREFIX)) == 0) {
DEBUG(0,("upgrade_to_version_2:moving secdesc\n"));
- if (tdb_store(tdb_printers, kbuf, dbuf, TDB_REPLACE) != 0) break;
- tdb_delete(tdb_drivers, kbuf);
+ if (tdb_store(tdb_printers, kbuf, dbuf, TDB_REPLACE) != 0) {
+ DEBUG(0,("upgrade_to_version_2: failed to move secdesc. Error (%s)\n", tdb_errorstr(tdb_printers)));
+ return False;
+ }
+ if (tdb_delete(tdb_drivers, kbuf) != 0) {
+ DEBUG(0,("upgrade_to_version_2: failed to delete secdesc. Error (%s)\n", tdb_errorstr(tdb_drivers)));
+ return False;
+ }
}
-
+
safe_free(dbuf.dptr);
}
-
-
+ return True;
}
-
/****************************************************************************
open the NT printing tdb
****************************************************************************/
@@ -250,9 +266,10 @@ BOOL nt_printing_init(void)
tdb_lock_bystring(tdb_drivers, vstring);
if (tdb_fetch_int(tdb_drivers, vstring) != NTDRIVERS_DATABASE_VERSION) {
- if (tdb_fetch_int(tdb_drivers, vstring) == NTDRIVERS_DATABASE_VERSION_1)
- upgrade_to_version_2();
- else
+ if (tdb_fetch_int(tdb_drivers, vstring) == NTDRIVERS_DATABASE_VERSION_1) {
+ if (!upgrade_to_version_2())
+ return False;
+ } else
tdb_traverse(tdb_drivers, (tdb_traverse_func)tdb_delete, NULL);
tdb_store_int(tdb_drivers, vstring, NTDRIVERS_DATABASE_VERSION);
@@ -2912,7 +2929,8 @@ BOOL printer_driver_in_use (char *arch, char *driver)
int ret;
if (!tdb_printers)
- nt_printing_init();
+ if (!nt_printing_init())
+ return False;
DEBUG(5,("printer_driver_in_use: Beginning search through printers.tdb...\n"));