s3-spoolss: remove unused architecture from fill_printer_driver_info1().
[kai/samba.git] / source3 / rpc_server / srv_spoolss_nt.c
index 73e2a7436447f67dd8a9365143bfb896fe234ff6..13c3710a9aa5d2a6908dac26943352ca1e6a05cc 100644 (file)
@@ -1928,8 +1928,8 @@ WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
                                    struct spoolss_DeletePrinterDriver *r)
 {
 
-       union spoolss_DriverInfo *info = NULL;
-       union spoolss_DriverInfo *info_win2k = NULL;
+       struct spoolss_DriverInfo8 *info = NULL;
+       struct spoolss_DriverInfo8 *info_win2k = NULL;
        int                             version;
        WERROR                          status;
        WERROR                          status_win2k = WERR_ACCESS_DENIED;
@@ -1953,7 +1953,7 @@ WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
        if ((version = get_version_id(r->in.architecture)) == -1)
                return WERR_INVALID_ENVIRONMENT;
 
-       if (!W_ERROR_IS_OK(get_a_printer_driver(p->mem_ctx, &info, 3, r->in.driver,
+       if (!W_ERROR_IS_OK(get_a_printer_driver(p->mem_ctx, &info, r->in.driver,
                                                r->in.architecture,
                                                version)))
        {
@@ -1962,7 +1962,7 @@ WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
                if ( version == 2 ) {
                        version = 3;
                        if (!W_ERROR_IS_OK(get_a_printer_driver(p->mem_ctx,
-                                                               &info, 3,
+                                                               &info,
                                                                r->in.driver,
                                                                r->in.architecture,
                                                                version))) {
@@ -1978,7 +1978,7 @@ WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
 
        }
 
-       if (printer_driver_in_use(&info->info3)) {
+       if (printer_driver_in_use(info)) {
                status = WERR_PRINTER_DRIVER_IN_USE;
                goto done;
        }
@@ -1986,7 +1986,7 @@ WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
        if ( version == 2 )
        {
                if (W_ERROR_IS_OK(get_a_printer_driver(p->mem_ctx,
-                                                      &info_win2k, 3,
+                                                      &info_win2k,
                                                       r->in.driver,
                                                       r->in.architecture, 3)))
                {
@@ -1994,7 +1994,7 @@ WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
                        /* remove the Win2k driver first*/
 
                        status_win2k = delete_printer_driver(
-                               p, &info_win2k->info3, 3, false);
+                               p, info_win2k, 3, false);
                        free_a_printer_driver(info_win2k);
 
                        /* this should not have failed---if it did, report to client */
@@ -2006,7 +2006,7 @@ WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
                }
        }
 
-       status = delete_printer_driver(p, &info->info3, version, false);
+       status = delete_printer_driver(p, info, version, false);
 
        /* if at least one of the deletes succeeded return OK */
 
@@ -2026,8 +2026,8 @@ done:
 WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
                                      struct spoolss_DeletePrinterDriverEx *r)
 {
-       union spoolss_DriverInfo        *info = NULL;
-       union spoolss_DriverInfo        *info_win2k = NULL;
+       struct spoolss_DriverInfo8      *info = NULL;
+       struct spoolss_DriverInfo8      *info_win2k = NULL;
        int                             version;
        bool                            delete_files;
        WERROR                          status;
@@ -2055,7 +2055,7 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
        if (r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION)
                version = r->in.version;
 
-       status = get_a_printer_driver(p->mem_ctx, &info, 3, r->in.driver,
+       status = get_a_printer_driver(p->mem_ctx, &info, r->in.driver,
                                      r->in.architecture, version);
 
        if ( !W_ERROR_IS_OK(status) )
@@ -2072,7 +2072,7 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
                /* try for Win2k driver if "Windows NT x86" */
 
                version = 3;
-               if (!W_ERROR_IS_OK(get_a_printer_driver(p->mem_ctx, &info, 3, r->in.driver,
+               if (!W_ERROR_IS_OK(get_a_printer_driver(p->mem_ctx, &info, r->in.driver,
                                                        r->in.architecture,
                                                        version))) {
                        status = WERR_UNKNOWN_PRINTER_DRIVER;
@@ -2080,7 +2080,7 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
                }
        }
 
-       if ( printer_driver_in_use(&info->info3) ) {
+       if (printer_driver_in_use(info)) {
                status = WERR_PRINTER_DRIVER_IN_USE;
                goto done;
        }
@@ -2101,7 +2101,7 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
 
        /* fail if any files are in use and DPD_DELETE_ALL_FILES is set */
 
-       if ( delete_files && printer_driver_files_in_use(info, &info->info3) & (r->in.delete_flags & DPD_DELETE_ALL_FILES) ) {
+       if (delete_files && printer_driver_files_in_use(info, info) & (r->in.delete_flags & DPD_DELETE_ALL_FILES)) {
                /* no idea of the correct error here */
                status = WERR_ACCESS_DENIED;
                goto done;
@@ -2111,12 +2111,12 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
        /* also check for W32X86/3 if necessary; maybe we already have? */
 
        if ( (version == 2) && ((r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION) != DPD_DELETE_SPECIFIC_VERSION)  ) {
-               if (W_ERROR_IS_OK(get_a_printer_driver(p->mem_ctx, &info_win2k, 3,
+               if (W_ERROR_IS_OK(get_a_printer_driver(p->mem_ctx, &info_win2k,
                                                       r->in.driver,
                                                       r->in.architecture, 3)))
                {
 
-                       if ( delete_files && printer_driver_files_in_use(info, &info_win2k->info3) & (r->in.delete_flags & DPD_DELETE_ALL_FILES) ) {
+                       if (delete_files && printer_driver_files_in_use(info, info_win2k) & (r->in.delete_flags & DPD_DELETE_ALL_FILES) ) {
                                /* no idea of the correct error here */
                                free_a_printer_driver(info_win2k);
                                status = WERR_ACCESS_DENIED;
@@ -2127,7 +2127,7 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
                        /* remove the Win2k driver first*/
 
                        status_win2k = delete_printer_driver(
-                               p, &info_win2k->info3, 3, delete_files);
+                               p, info_win2k, 3, delete_files);
                        free_a_printer_driver(info_win2k);
 
                        /* this should not have failed---if it did, report to client */
@@ -2137,7 +2137,7 @@ WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
                }
        }
 
-       status = delete_printer_driver(p, &info->info3, version, delete_files);
+       status = delete_printer_driver(p, info, version, delete_files);
 
        if ( W_ERROR_IS_OK(status) || W_ERROR_IS_OK(status_win2k) )
                status = WERR_OK;
@@ -4476,6 +4476,8 @@ static const char **string_array_from_driver_info(TALLOC_CTX *mem_ctx,
                if (in && strlen(in)) { \
                        out = talloc_strdup(mem_ctx, in); \
                        W_ERROR_HAVE_NO_MEMORY(out); \
+               } else { \
+                       out = NULL; \
                } \
        } while (0);
 
@@ -4495,9 +4497,8 @@ static const char **string_array_from_driver_info(TALLOC_CTX *mem_ctx,
 
 static WERROR fill_printer_driver_info1(TALLOC_CTX *mem_ctx,
                                        struct spoolss_DriverInfo1 *r,
-                                       const struct spoolss_DriverInfo3 *driver,
-                                       const char *servername,
-                                       const char *architecture)
+                                       const struct spoolss_DriverInfo8 *driver,
+                                       const char *servername)
 {
        r->driver_name          = talloc_strdup(mem_ctx, driver->driver_name);
        W_ERROR_HAVE_NO_MEMORY(r->driver_name);
@@ -4511,7 +4512,7 @@ static WERROR fill_printer_driver_info1(TALLOC_CTX *mem_ctx,
 
 static WERROR fill_printer_driver_info2(TALLOC_CTX *mem_ctx,
                                        struct spoolss_DriverInfo2 *r,
-                                       const struct spoolss_DriverInfo3 *driver,
+                                       const struct spoolss_DriverInfo8 *driver,
                                        const char *servername)
 
 {
@@ -4545,7 +4546,7 @@ static WERROR fill_printer_driver_info2(TALLOC_CTX *mem_ctx,
 
 static WERROR fill_printer_driver_info3(TALLOC_CTX *mem_ctx,
                                        struct spoolss_DriverInfo3 *r,
-                                       const struct spoolss_DriverInfo3 *driver,
+                                       const struct spoolss_DriverInfo8 *driver,
                                        const char *servername)
 {
        const char *cservername = canon_servername(servername);
@@ -4593,7 +4594,7 @@ static WERROR fill_printer_driver_info3(TALLOC_CTX *mem_ctx,
 
 static WERROR fill_printer_driver_info4(TALLOC_CTX *mem_ctx,
                                        struct spoolss_DriverInfo4 *r,
-                                       const struct spoolss_DriverInfo3 *driver,
+                                       const struct spoolss_DriverInfo8 *driver,
                                        const char *servername)
 {
        const char *cservername = canon_servername(servername);
@@ -4634,7 +4635,7 @@ static WERROR fill_printer_driver_info4(TALLOC_CTX *mem_ctx,
                           r->default_datatype);
 
        r->previous_names = string_array_from_driver_info(mem_ctx,
-                                                         NULL,
+                                                         driver->previous_names,
                                                          cservername);
 
        return WERR_OK;
@@ -4646,7 +4647,7 @@ static WERROR fill_printer_driver_info4(TALLOC_CTX *mem_ctx,
 
 static WERROR fill_printer_driver_info5(TALLOC_CTX *mem_ctx,
                                        struct spoolss_DriverInfo5 *r,
-                                       const struct spoolss_DriverInfo3 *driver,
+                                       const struct spoolss_DriverInfo8 *driver,
                                        const char *servername)
 {
        const char *cservername = canon_servername(servername);
@@ -4682,7 +4683,7 @@ static WERROR fill_printer_driver_info5(TALLOC_CTX *mem_ctx,
 
 static WERROR fill_printer_driver_info6(TALLOC_CTX *mem_ctx,
                                        struct spoolss_DriverInfo6 *r,
-                                       const struct spoolss_DriverInfo3 *driver,
+                                       const struct spoolss_DriverInfo8 *driver,
                                        const char *servername)
 {
        const char *cservername = canon_servername(servername);
@@ -4722,24 +4723,119 @@ static WERROR fill_printer_driver_info6(TALLOC_CTX *mem_ctx,
                                                           driver->dependent_files,
                                                           cservername);
        r->previous_names = string_array_from_driver_info(mem_ctx,
-                                                         NULL,
+                                                         driver->previous_names,
                                                          cservername);
 
-       r->driver_date          = 0;
-       r->driver_version       = 0;
+       r->driver_date          = driver->driver_date;
+       r->driver_version       = driver->driver_version;
 
-       FILL_DRIVER_STRING(mem_ctx, "",
+       FILL_DRIVER_STRING(mem_ctx,
+                          driver->manufacturer_name,
                           r->manufacturer_name);
-       FILL_DRIVER_STRING(mem_ctx, "",
+       FILL_DRIVER_STRING(mem_ctx,
+                          driver->manufacturer_url,
                           r->manufacturer_url);
-       FILL_DRIVER_STRING(mem_ctx, "",
+       FILL_DRIVER_STRING(mem_ctx,
+                          driver->hardware_id,
                           r->hardware_id);
-       FILL_DRIVER_STRING(mem_ctx, "",
+       FILL_DRIVER_STRING(mem_ctx,
+                          driver->provider,
                           r->provider);
 
        return WERR_OK;
 }
 
+/********************************************************************
+ * fill a spoolss_DriverInfo8 struct
+ ********************************************************************/
+
+static WERROR fill_printer_driver_info8(TALLOC_CTX *mem_ctx,
+                                       struct spoolss_DriverInfo8 *r,
+                                       const struct spoolss_DriverInfo8 *driver,
+                                       const char *servername)
+{
+       const char *cservername = canon_servername(servername);
+
+       r->version              = driver->version;
+
+       r->driver_name          = talloc_strdup(mem_ctx, driver->driver_name);
+       W_ERROR_HAVE_NO_MEMORY(r->driver_name);
+       r->architecture         = talloc_strdup(mem_ctx, driver->architecture);
+       W_ERROR_HAVE_NO_MEMORY(r->architecture);
+
+       FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->driver_path,
+                              r->driver_path);
+
+       FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->data_file,
+                              r->data_file);
+
+       FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->config_file,
+                              r->config_file);
+
+       FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->help_file,
+                              r->help_file);
+
+       FILL_DRIVER_STRING(mem_ctx,
+                          driver->monitor_name,
+                          r->monitor_name);
+
+       FILL_DRIVER_STRING(mem_ctx,
+                          driver->default_datatype,
+                          r->default_datatype);
+
+       r->dependent_files = string_array_from_driver_info(mem_ctx,
+                                                          driver->dependent_files,
+                                                          cservername);
+       r->previous_names = string_array_from_driver_info(mem_ctx,
+                                                         driver->previous_names,
+                                                         cservername);
+
+       r->driver_date          = driver->driver_date;
+       r->driver_version       = driver->driver_version;
+
+       FILL_DRIVER_STRING(mem_ctx,
+                          driver->manufacturer_name,
+                          r->manufacturer_name);
+       FILL_DRIVER_STRING(mem_ctx,
+                          driver->manufacturer_url,
+                          r->manufacturer_url);
+       FILL_DRIVER_STRING(mem_ctx,
+                          driver->hardware_id,
+                          r->hardware_id);
+       FILL_DRIVER_STRING(mem_ctx,
+                          driver->provider,
+                          r->provider);
+
+       FILL_DRIVER_STRING(mem_ctx,
+                          driver->print_processor,
+                          r->print_processor);
+       FILL_DRIVER_STRING(mem_ctx,
+                          driver->vendor_setup,
+                          r->vendor_setup);
+
+       r->color_profiles = string_array_from_driver_info(mem_ctx,
+                                                         driver->color_profiles,
+                                                         cservername);
+
+       FILL_DRIVER_STRING(mem_ctx,
+                          driver->inf_path,
+                          r->inf_path);
+
+       r->printer_driver_attributes    = driver->printer_driver_attributes;
+
+       r->core_driver_dependencies = string_array_from_driver_info(mem_ctx,
+                                                                   driver->core_driver_dependencies,
+                                                                   cservername);
+
+       r->min_inbox_driver_ver_date    = driver->min_inbox_driver_ver_date;
+       r->min_inbox_driver_ver_version = driver->min_inbox_driver_ver_version;
+
+       return WERR_OK;
+}
 /********************************************************************
  ********************************************************************/
 
@@ -4763,7 +4859,7 @@ static WERROR fill_spoolss_DriverFileInfo(TALLOC_CTX *mem_ctx,
  ********************************************************************/
 
 static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
-                                                const struct spoolss_DriverInfo3 *driver,
+                                                const struct spoolss_DriverInfo8 *driver,
                                                 const char *cservername,
                                                 struct spoolss_DriverFileInfo **info_p,
                                                 uint32_t *count_p)
@@ -4863,7 +4959,7 @@ static WERROR spoolss_DriverFileInfo_from_driver(TALLOC_CTX *mem_ctx,
 
 static WERROR fill_printer_driver_info101(TALLOC_CTX *mem_ctx,
                                          struct spoolss_DriverInfo101 *r,
-                                         const struct spoolss_DriverInfo3 *driver,
+                                         const struct spoolss_DriverInfo8 *driver,
                                          const char *servername)
 {
        const char *cservername = canon_servername(servername);
@@ -4893,238 +4989,55 @@ static WERROR fill_printer_driver_info101(TALLOC_CTX *mem_ctx,
                           r->default_datatype);
 
        r->previous_names = string_array_from_driver_info(mem_ctx,
-                                                         NULL,
+                                                         driver->previous_names,
                                                          cservername);
-       r->driver_date          = 0;
-       r->driver_version       = 0;
+       r->driver_date          = driver->driver_date;
+       r->driver_version       = driver->driver_version;
 
-       FILL_DRIVER_STRING(mem_ctx, "",
+       FILL_DRIVER_STRING(mem_ctx,
+                          driver->manufacturer_name,
                           r->manufacturer_name);
-       FILL_DRIVER_STRING(mem_ctx, "",
+       FILL_DRIVER_STRING(mem_ctx,
+                          driver->manufacturer_url,
                           r->manufacturer_url);
-       FILL_DRIVER_STRING(mem_ctx, "",
+       FILL_DRIVER_STRING(mem_ctx,
+                          driver->hardware_id,
                           r->hardware_id);
-       FILL_DRIVER_STRING(mem_ctx, "",
+       FILL_DRIVER_STRING(mem_ctx,
+                          driver->provider,
                           r->provider);
 
        return WERR_OK;
 }
 
 /********************************************************************
- * construct_printer_driver_info_1
  ********************************************************************/
 
-static WERROR construct_printer_driver_info_1(TALLOC_CTX *mem_ctx,
-                                             struct spoolss_DriverInfo1 *r,
-                                             int snum,
-                                             const char *servername,
-                                             const char *architecture,
-                                             uint32_t version)
+static WERROR construct_printer_driver_info_level(TALLOC_CTX *mem_ctx,
+                                                 uint32_t level,
+                                                 union spoolss_DriverInfo *r,
+                                                 int snum,
+                                                 const char *servername,
+                                                 const char *architecture,
+                                                 uint32_t version)
 {
        NT_PRINTER_INFO_LEVEL *printer = NULL;
-       union spoolss_DriverInfo *driver;
+       struct spoolss_DriverInfo8 *driver;
        WERROR result;
 
-       if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum))))
-               return WERR_INVALID_PRINTER_NAME;
-
-       if (!W_ERROR_IS_OK(get_a_printer_driver(mem_ctx, &driver, 3, printer->info_2->drivername, architecture, version))) {
-               free_a_printer(&printer, 2);
-               return WERR_UNKNOWN_PRINTER_DRIVER;
-       }
-
-       result = fill_printer_driver_info1(mem_ctx, r, &driver->info3, servername, architecture);
-
-       free_a_printer_driver(driver);
-       free_a_printer(&printer,2);
-
-       return result;
-}
-
-/********************************************************************
- * construct_printer_driver_info_2
- * fill a printer_info_2 struct
- ********************************************************************/
-
-static WERROR construct_printer_driver_info_2(TALLOC_CTX *mem_ctx,
-                                             struct spoolss_DriverInfo2 *r,
-                                             int snum,
-                                             const char *servername,
-                                             const char *architecture,
-                                             uint32_t version)
-{
-       NT_PRINTER_INFO_LEVEL *printer = NULL;
-       union spoolss_DriverInfo *driver;
-       WERROR result;
-
-       ZERO_STRUCT(printer);
-
-       if (!W_ERROR_IS_OK(get_a_printer(NULL, &printer, 2, lp_const_servicename(snum))))
-               return WERR_INVALID_PRINTER_NAME;
-
-       if (!W_ERROR_IS_OK(get_a_printer_driver(mem_ctx, &driver, 3, printer->info_2->drivername, architecture, version))) {
-               free_a_printer(&printer, 2);
-               return WERR_UNKNOWN_PRINTER_DRIVER;
-       }
-
-       result = fill_printer_driver_info2(mem_ctx, r, &driver->info3, servername);
-
-       free_a_printer_driver(driver);
-       free_a_printer(&printer,2);
-
-       return result;
-}
-
-/********************************************************************
- * construct_printer_info_3
- * fill a printer_info_3 struct
- ********************************************************************/
-
-static WERROR construct_printer_driver_info_3(TALLOC_CTX *mem_ctx,
-                                             struct spoolss_DriverInfo3 *r,
-                                             int snum,
-                                             const char *servername,
-                                             const char *architecture,
-                                             uint32_t version)
-{
-       NT_PRINTER_INFO_LEVEL *printer = NULL;
-       union spoolss_DriverInfo *driver;
-       WERROR status;
-       ZERO_STRUCT(driver);
-
-       status=get_a_printer(NULL, &printer, 2, lp_const_servicename(snum) );
-       DEBUG(8,("construct_printer_driver_info_3: status: %s\n", win_errstr(status)));
-       if (!W_ERROR_IS_OK(status))
-               return WERR_INVALID_PRINTER_NAME;
-
-       status = get_a_printer_driver(mem_ctx, &driver, 3, printer->info_2->drivername, architecture, version);
-       DEBUG(8,("construct_printer_driver_info_3: status: %s\n", win_errstr(status)));
-
-#if 0  /* JERRY */
-
-       /*
-        * I put this code in during testing.  Helpful when commenting out the
-        * support for DRIVER_INFO_6 in regards to win2k.  Not needed in general
-        * as win2k always queries the driver using an infor level of 6.
-        * I've left it in (but ifdef'd out) because I'll probably
-        * use it in experimentation again in the future.   --jerry 22/01/2002
-        */
-
-       if (!W_ERROR_IS_OK(status)) {
-               /*
-                * Is this a W2k client ?
-                */
-               if (version == 3) {
-                       /* Yes - try again with a WinNT driver. */
-                       version = 2;
-                       status=get_a_printer_driver(&driver, 3, printer->info_2->drivername, architecture, version);
-                       DEBUG(8,("construct_printer_driver_info_3: status: %s\n", win_errstr(status)));
-               }
-#endif
-
-               if (!W_ERROR_IS_OK(status)) {
-                       free_a_printer(&printer,2);
-                       return WERR_UNKNOWN_PRINTER_DRIVER;
-               }
-
-#if 0  /* JERRY */
-       }
-#endif
-
-
-       status = fill_printer_driver_info3(mem_ctx, r, &driver->info3, servername);
-
-       free_a_printer_driver(driver);
-       free_a_printer(&printer,2);
-
-       return status;
-}
-
-/********************************************************************
- * construct_printer_info_6
- * fill a printer_info_6 struct
- ********************************************************************/
-
-static WERROR construct_printer_driver_info_6(TALLOC_CTX *mem_ctx,
-                                             struct spoolss_DriverInfo6 *r,
-                                             int snum,
-                                             const char *servername,
-                                             const char *architecture,
-                                             uint32_t version)
-{
-       NT_PRINTER_INFO_LEVEL           *printer = NULL;
-       union spoolss_DriverInfo *driver;
-       WERROR                          status;
-
-       status=get_a_printer(NULL, &printer, 2, lp_const_servicename(snum) );
-
-       DEBUG(8,("construct_printer_driver_info_6: status: %s\n", win_errstr(status)));
-
-       if (!W_ERROR_IS_OK(status))
-               return WERR_INVALID_PRINTER_NAME;
-
-       status = get_a_printer_driver(mem_ctx, &driver, 3, printer->info_2->drivername, architecture, version);
-
-       DEBUG(8,("construct_printer_driver_info_6: status: %s\n", win_errstr(status)));
-
-       if (!W_ERROR_IS_OK(status))
-       {
-               /*
-                * Is this a W2k client ?
-                */
-
-               if (version < 3) {
-                       free_a_printer(&printer,2);
-                       return WERR_UNKNOWN_PRINTER_DRIVER;
-               }
-
-               /* Yes - try again with a WinNT driver. */
-               version = 2;
-               status = get_a_printer_driver(mem_ctx, &driver, 3, printer->info_2->drivername, architecture, version);
-               DEBUG(8,("construct_printer_driver_info_6: status: %s\n", win_errstr(status)));
-               if (!W_ERROR_IS_OK(status)) {
-                       free_a_printer(&printer,2);
-                       return WERR_UNKNOWN_PRINTER_DRIVER;
-               }
-       }
-
-       status = fill_printer_driver_info6(mem_ctx, r, &driver->info3, servername);
-
-       free_a_printer(&printer,2);
-       free_a_printer_driver(driver);
-
-       return status;
-}
-
-/********************************************************************
- * construct_printer_info_101
- * fill a printer_info_101 struct
- ********************************************************************/
-
-static WERROR construct_printer_driver_info_101(TALLOC_CTX *mem_ctx,
-                                               struct spoolss_DriverInfo101 *r,
-                                               int snum,
-                                               const char *servername,
-                                               const char *architecture,
-                                               uint32_t version)
-{
-       NT_PRINTER_INFO_LEVEL           *printer = NULL;
-       union spoolss_DriverInfo *driver;
-       WERROR                          result;
-
        result = get_a_printer(NULL, &printer, 2, lp_const_servicename(snum));
 
-       DEBUG(8,("construct_printer_driver_info_101: status: %s\n",
+       DEBUG(8,("construct_printer_driver_info_level: status: %s\n",
                win_errstr(result)));
 
        if (!W_ERROR_IS_OK(result)) {
                return WERR_INVALID_PRINTER_NAME;
        }
 
-       result = get_a_printer_driver(mem_ctx, &driver, 3, printer->info_2->drivername,
+       result = get_a_printer_driver(mem_ctx, &driver, printer->info_2->drivername,
                                      architecture, version);
 
-       DEBUG(8,("construct_printer_driver_info_101: status: %s\n",
+       DEBUG(8,("construct_printer_driver_info_level: status: %s\n",
                win_errstr(result)));
 
        if (!W_ERROR_IS_OK(result)) {
@@ -5139,9 +5052,9 @@ static WERROR construct_printer_driver_info_101(TALLOC_CTX *mem_ctx,
 
                /* Yes - try again with a WinNT driver. */
                version = 2;
-               result = get_a_printer_driver(mem_ctx, &driver, 3, printer->info_2->drivername,
+               result = get_a_printer_driver(mem_ctx, &driver, printer->info_2->drivername,
                                              architecture, version);
-               DEBUG(8,("construct_printer_driver_info_6: status: %s\n",
+               DEBUG(8,("construct_printer_driver_level: status: %s\n",
                        win_errstr(result)));
                if (!W_ERROR_IS_OK(result)) {
                        free_a_printer(&printer, 2);
@@ -5149,7 +5062,35 @@ static WERROR construct_printer_driver_info_101(TALLOC_CTX *mem_ctx,
                }
        }
 
-       result = fill_printer_driver_info101(mem_ctx, r, &driver->info3, servername);
+       switch (level) {
+       case 1:
+               result = fill_printer_driver_info1(mem_ctx, &r->info1, driver, servername);
+               break;
+       case 2:
+               result = fill_printer_driver_info2(mem_ctx, &r->info2, driver, servername);
+               break;
+       case 3:
+               result = fill_printer_driver_info3(mem_ctx, &r->info3, driver, servername);
+               break;
+       case 4:
+               result = fill_printer_driver_info4(mem_ctx, &r->info4, driver, servername);
+               break;
+       case 5:
+               result = fill_printer_driver_info5(mem_ctx, &r->info5, driver, servername);
+               break;
+       case 6:
+               result = fill_printer_driver_info6(mem_ctx, &r->info6, driver, servername);
+               break;
+       case 8:
+               result = fill_printer_driver_info8(mem_ctx, &r->info8, driver, servername);
+               break;
+       case 101:
+               result = fill_printer_driver_info101(mem_ctx, &r->info101, driver, servername);
+               break;
+       default:
+               result = WERR_UNKNOWN_LEVEL;
+               break;
+       }
 
        free_a_printer(&printer, 2);
        free_a_printer_driver(driver);
@@ -5193,52 +5134,11 @@ WERROR _spoolss_GetPrinterDriver2(pipes_struct *p,
                return WERR_BADFID;
        }
 
-       switch (r->in.level) {
-       case 1:
-               result = construct_printer_driver_info_1(p->mem_ctx,
-                                                        &r->out.info->info1,
-                                                        snum,
-                                                        servername,
-                                                        r->in.architecture,
-                                                        r->in.client_major_version);
-               break;
-       case 2:
-               result = construct_printer_driver_info_2(p->mem_ctx,
-                                                        &r->out.info->info2,
-                                                        snum,
-                                                        servername,
-                                                        r->in.architecture,
-                                                        r->in.client_major_version);
-               break;
-       case 3:
-               result = construct_printer_driver_info_3(p->mem_ctx,
-                                                        &r->out.info->info3,
-                                                        snum,
-                                                        servername,
-                                                        r->in.architecture,
-                                                        r->in.client_major_version);
-               break;
-       case 6:
-               result = construct_printer_driver_info_6(p->mem_ctx,
-                                                        &r->out.info->info6,
-                                                        snum,
-                                                        servername,
-                                                        r->in.architecture,
-                                                        r->in.client_major_version);
-               break;
-       case 101:
-               result = construct_printer_driver_info_101(p->mem_ctx,
-                                                          &r->out.info->info101,
-                                                          snum,
-                                                          servername,
-                                                          r->in.architecture,
-                                                          r->in.client_major_version);
-               break;
-       default:
-               result = WERR_UNKNOWN_LEVEL;
-               break;
-       }
-
+       result = construct_printer_driver_info_level(p->mem_ctx, r->in.level,
+                                                    r->out.info, snum,
+                                                    servername,
+                                                    r->in.architecture,
+                                                    r->in.client_major_version);
        if (!W_ERROR_IS_OK(result)) {
                TALLOC_FREE(r->out.info);
                return result;
@@ -6448,7 +6348,7 @@ static WERROR enumprinterdrivers_level_by_architecture(TALLOC_CTX *mem_ctx,
        int ndrivers;
        uint32_t version;
        fstring *list = NULL;
-       union spoolss_DriverInfo *driver;
+       struct spoolss_DriverInfo8 *driver;
        union spoolss_DriverInfo *info = NULL;
        uint32_t count = 0;
        WERROR result = WERR_OK;
@@ -6482,7 +6382,7 @@ static WERROR enumprinterdrivers_level_by_architecture(TALLOC_CTX *mem_ctx,
                for (i=0; i<ndrivers; i++) {
                        DEBUGADD(5,("\tdriver: [%s]\n", list[i]));
                        ZERO_STRUCT(driver);
-                       result = get_a_printer_driver(mem_ctx, &driver, 3, list[i],
+                       result = get_a_printer_driver(mem_ctx, &driver, list[i],
                                                      architecture, version);
                        if (!W_ERROR_IS_OK(result)) {
                                goto out;
@@ -6491,28 +6391,31 @@ static WERROR enumprinterdrivers_level_by_architecture(TALLOC_CTX *mem_ctx,
                        switch (level) {
                        case 1:
                                result = fill_printer_driver_info1(info, &info[count+i].info1,
-                                                                  &driver->info3, servername,
-                                                                  architecture);
+                                                                  driver, servername);
                                break;
                        case 2:
                                result = fill_printer_driver_info2(info, &info[count+i].info2,
-                                                                  &driver->info3, servername);
+                                                                  driver, servername);
                                break;
                        case 3:
                                result = fill_printer_driver_info3(info, &info[count+i].info3,
-                                                                  &driver->info3, servername);
+                                                                  driver, servername);
                                break;
                        case 4:
                                result = fill_printer_driver_info4(info, &info[count+i].info4,
-                                                                  &driver->info3, servername);
+                                                                  driver, servername);
                                break;
                        case 5:
                                result = fill_printer_driver_info5(info, &info[count+i].info5,
-                                                                  &driver->info3, servername);
+                                                                  driver, servername);
                                break;
                        case 6:
                                result = fill_printer_driver_info6(info, &info[count+i].info6,
-                                                                  &driver->info3, servername);
+                                                                  driver, servername);
+                               break;
+                       case 8:
+                               result = fill_printer_driver_info8(info, &info[count+i].info8,
+                                                                  driver, servername);
                                break;
                        default:
                                result = WERR_UNKNOWN_LEVEL;
@@ -6676,6 +6579,19 @@ static WERROR enumprinterdrivers_level6(TALLOC_CTX *mem_ctx,
                                        info_p, count);
 }
 
+/****************************************************************************
+ Enumerates all printer drivers at level 8.
+****************************************************************************/
+
+static WERROR enumprinterdrivers_level8(TALLOC_CTX *mem_ctx,
+                                       const char *servername,
+                                       const char *architecture,
+                                       union spoolss_DriverInfo **info_p,
+                                       uint32_t *count)
+{
+       return enumprinterdrivers_level(mem_ctx, servername, architecture, 8,
+                                       info_p, count);
+}
 
 /****************************************************************
  _spoolss_EnumPrinterDrivers
@@ -6736,6 +6652,11 @@ WERROR _spoolss_EnumPrinterDrivers(pipes_struct *p,
                                                   r->in.environment,
                                                   r->out.info, r->out.count);
                break;
+       case 8:
+               result = enumprinterdrivers_level8(p->mem_ctx, cservername,
+                                                  r->in.environment,
+                                                  r->out.info, r->out.count);
+               break;
        default:
                return WERR_UNKNOWN_LEVEL;
        }
@@ -7493,9 +7414,9 @@ WERROR _spoolss_AddPrinterDriver(pipes_struct *p,
                */
                case 2:
                {
-                       union spoolss_DriverInfo *driver1;
+                       struct spoolss_DriverInfo8 *driver1;
 
-                       if (!W_ERROR_IS_OK(get_a_printer_driver(p->mem_ctx, &driver1, 3, driver_name, "Windows NT x86", 3))) {
+                       if (!W_ERROR_IS_OK(get_a_printer_driver(p->mem_ctx, &driver1, driver_name, "Windows NT x86", 3))) {
                                /*
                                 * No 2k/Xp driver found, delete init data (if any) for the new Nt driver.
                                */
@@ -7910,46 +7831,13 @@ WERROR _spoolss_ResetPrinter(pipes_struct *p,
 WERROR _spoolss_DeletePrinterData(pipes_struct *p,
                                  struct spoolss_DeletePrinterData *r)
 {
-       NT_PRINTER_INFO_LEVEL   *printer = NULL;
-       int             snum=0;
-       WERROR          status = WERR_OK;
-       Printer_entry   *Printer = find_printer_index_by_hnd(p, r->in.handle);
-
-       DEBUG(5,("_spoolss_DeletePrinterData\n"));
-
-       if (!Printer) {
-               DEBUG(2,("_spoolss_DeletePrinterData: Invalid handle (%s:%u:%u).\n",
-                       OUR_HANDLE(r->in.handle)));
-               return WERR_BADFID;
-       }
-
-       if (!get_printer_snum(p, r->in.handle, &snum, NULL))
-               return WERR_BADFID;
-
-       if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) {
-               DEBUG(3, ("_spoolss_DeletePrinterData: "
-                       "printer properties change denied by handle\n"));
-               return WERR_ACCESS_DENIED;
-       }
+       struct spoolss_DeletePrinterDataEx r2;
 
-       status = get_a_printer(Printer, &printer, 2, lp_const_servicename(snum));
-       if (!W_ERROR_IS_OK(status))
-               return status;
-
-       if (!r->in.value_name) {
-               free_a_printer(&printer, 2);
-               return WERR_NOMEM;
-       }
-
-       status = delete_printer_dataex( printer, SPOOL_PRINTERDATA_KEY,
-                                       r->in.value_name );
-
-       if ( W_ERROR_IS_OK(status) )
-               mod_a_printer( printer, 2 );
-
-       free_a_printer(&printer, 2);
+       r2.in.handle            = r->in.handle;
+       r2.in.key_name          = "PrinterDriverData";
+       r2.in.value_name        = r->in.value_name;
 
-       return status;
+       return _spoolss_DeletePrinterDataEx(p, &r2);
 }
 
 /****************************************************************