summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/printing/nt_printing.c51
1 files changed, 37 insertions, 14 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 2348bbe3d4..f208cabb60 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -3764,7 +3764,7 @@ static WERROR delete_printer_driver_internal( NT_PRINTER_DRIVER_INFO_LEVEL_3 *i,
{
pstring key;
fstring arch;
- TDB_DATA kbuf;
+ TDB_DATA kbuf, dbuf;
NT_PRINTER_DRIVER_INFO_LEVEL ctr;
/* delete the tdb data first */
@@ -3782,8 +3782,20 @@ static WERROR delete_printer_driver_internal( NT_PRINTER_DRIVER_INFO_LEVEL_3 *i,
kbuf.dptr=key;
kbuf.dsize=strlen(key)+1;
+ /* check if the driver actually exists for this environment */
+
+ dbuf = tdb_fetch( tdb_drivers, kbuf );
+ if ( !dbuf.dptr ) {
+ DEBUG(8,("delete_printer_driver_internal: Driver unknown [%s]\n", key));
+ return WERR_UNKNOWN_PRINTER_DRIVER;
+ }
+
+ SAFE_FREE( dbuf.dptr );
+
+ /* ok... the driver exists so the delete should return success */
+
if (tdb_delete(tdb_drivers, kbuf) == -1) {
- DEBUG (0,("delete_printer_driver: fail to delete %s!\n", key));
+ DEBUG (0,("delete_printer_driver_internal: fail to delete %s!\n", key));
return WERR_ACCESS_DENIED;
}
@@ -3796,8 +3808,8 @@ static WERROR delete_printer_driver_internal( NT_PRINTER_DRIVER_INFO_LEVEL_3 *i,
if ( delete_files )
delete_driver_files( i, user );
- DEBUG(5,("delete_printer_driver: [%s] driver delete successful.\n",
- i->name));
+
+ DEBUG(5,("delete_printer_driver_internal: driver delete successful [%s]\n", key));
return WERR_OK;
}
@@ -3810,22 +3822,33 @@ static WERROR delete_printer_driver_internal( NT_PRINTER_DRIVER_INFO_LEVEL_3 *i,
WERROR delete_printer_driver( NT_PRINTER_DRIVER_INFO_LEVEL_3 *i, struct current_user *user,
uint32 version, BOOL delete_files )
{
- int ver;
WERROR err;
- /* see if we should delete all versions of this driver */
+ /*
+ * see if we should delete all versions of this driver
+ * (DRIVER_ANY_VERSION uis only set for "Windows NT x86")
+ */
- if ( version == DRIVER_ANY_VERSION ) {
- for ( ver=0; ver<DRIVER_MAX_VERSION; ver++ ) {
- err = delete_printer_driver_internal(i, user, ver, delete_files );
- if ( !W_ERROR_IS_OK(err) )
+ if ( version == DRIVER_ANY_VERSION )
+ {
+ /* Windows NT 4.0 */
+
+ err = delete_printer_driver_internal(i, user, 2, delete_files );
+ if ( !W_ERROR_IS_OK(err) && (W_ERROR_V(err) != ERRunknownprinterdriver ) )
+ return err;
+
+ /* Windows 2000/XP */
+
+ err = delete_printer_driver_internal(i, user, 3, delete_files );
+ if ( !W_ERROR_IS_OK(err) && (W_ERROR_V(err) != ERRunknownprinterdriver ) )
return err;
- }
- }
- else
- delete_printer_driver_internal(i, user, version, delete_files );
return WERR_OK;
+ }
+
+ /* just delete what they asked for */
+
+ return delete_printer_driver_internal(i, user, version, delete_files );
}