s3-secrets: only include secrets.h when needed.
[samba.git] / source3 / rpc_server / srv_spoolss_nt.c
index 6c1eab4168b05460b61b36c639973a423df559ac..7ada5fdb9a366e9343a9cc3728ab1e6b0e2340aa 100644 (file)
@@ -28,6 +28,7 @@
    up, all the errors returned are DOS errors, not NT status codes. */
 
 #include "includes.h"
+#include "nt_printing.h"
 #include "srv_spoolss_util.h"
 #include "../librpc/gen_ndr/srv_spoolss.h"
 #include "../librpc/gen_ndr/cli_spoolss.h"
@@ -36,6 +37,8 @@
 #include "librpc/gen_ndr/ndr_security.h"
 #include "registry.h"
 #include "registry/reg_objects.h"
+#include "include/printing.h"
+#include "secrets.h"
 
 /* macros stolen from s4 spoolss server */
 #define SPOOLSS_BUFFER_UNION(fn,info,level) \
 
 #define SPOOLSS_BUFFER_OK(val_true,val_false) ((r->in.offered >= *r->out.needed)?val_true:val_false)
 
-
-extern userdom_struct current_user_info;
-
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_RPC_SRV
 
-#ifndef MAX_OPEN_PRINTER_EXS
-#define MAX_OPEN_PRINTER_EXS 50
-#endif
-
-#define MAGIC_DISPLAY_FREQUENCY 0xfade2bad
-
 static Printer_entry *printers_list;
 
 typedef struct _counter_printer_0 {
@@ -77,9 +71,23 @@ static struct rpc_pipe_client *notify_cli_pipe; /* print notify back-channel pip
 static uint32_t smb_connections = 0;
 
 
-/* in printing/nt_printing.c */
+/* Map generic permissions to printer object specific permissions */
 
-extern struct standard_mapping printer_std_mapping, printserver_std_mapping;
+const struct standard_mapping printer_std_mapping = {
+       PRINTER_READ,
+       PRINTER_WRITE,
+       PRINTER_EXECUTE,
+       PRINTER_ALL_ACCESS
+};
+
+/* Map generic permissions to print server object specific permissions */
+
+const struct standard_mapping printserver_std_mapping = {
+       SERVER_READ,
+       SERVER_WRITE,
+       SERVER_EXECUTE,
+       SERVER_ALL_ACCESS
+};
 
 /* API table for Xcv Monitor functions */
 
@@ -224,7 +232,6 @@ static int printer_entry_destructor(Printer_entry *Printer)
        Printer->notify.client_connected = false;
 
        TALLOC_FREE(Printer->devmode);
-       free_a_printer( &Printer->printer_info, 2 );
 
        /* Remove from the internal list. */
        DLIST_REMOVE(printers_list, Printer);
@@ -235,7 +242,7 @@ static int printer_entry_destructor(Printer_entry *Printer)
   find printer index by handle
 ****************************************************************************/
 
-static Printer_entry *find_printer_index_by_hnd(pipes_struct *p,
+static Printer_entry *find_printer_index_by_hnd(struct pipes_struct *p,
                                                struct policy_handle *hnd)
 {
        Printer_entry *find_printer = NULL;
@@ -252,7 +259,7 @@ static Printer_entry *find_printer_index_by_hnd(pipes_struct *p,
  Close printer index by handle.
 ****************************************************************************/
 
-static bool close_printer_handle(pipes_struct *p, struct policy_handle *hnd)
+static bool close_printer_handle(struct pipes_struct *p, struct policy_handle *hnd)
 {
        Printer_entry *Printer = find_printer_index_by_hnd(p, hnd);
 
@@ -333,9 +340,10 @@ static WERROR delete_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const c
  Delete a printer given a handle.
 ****************************************************************************/
 
-static WERROR delete_printer_handle(pipes_struct *p, struct policy_handle *hnd)
+static WERROR delete_printer_handle(struct pipes_struct *p, struct policy_handle *hnd)
 {
        Printer_entry *Printer = find_printer_index_by_hnd(p, hnd);
+       WERROR result;
 
        if (!Printer) {
                DEBUG(2,("delete_printer_handle: Invalid handle (%s:%u:%u)\n",
@@ -358,7 +366,9 @@ static WERROR delete_printer_handle(pipes_struct *p, struct policy_handle *hnd)
        /* this does not need a become root since the access check has been
           done on the handle already */
 
-       if (del_a_printer( Printer->sharename ) != 0) {
+       result = winreg_delete_printer_key(p->mem_ctx, p->server_info,
+                                          Printer->sharename, "");
+       if (!W_ERROR_IS_OK(result)) {
                DEBUG(3,("Error deleting printer %s\n", Printer->sharename));
                return WERR_BADFID;
        }
@@ -371,7 +381,7 @@ static WERROR delete_printer_handle(pipes_struct *p, struct policy_handle *hnd)
  Return the snum of a printer corresponding to an handle.
 ****************************************************************************/
 
-static bool get_printer_snum(pipes_struct *p, struct policy_handle *hnd,
+static bool get_printer_snum(struct pipes_struct *p, struct policy_handle *hnd,
                             int *number, struct share_params **params)
 {
        Printer_entry *Printer = find_printer_index_by_hnd(p, hnd);
@@ -438,7 +448,7 @@ static bool set_printer_hnd_name(TALLOC_CTX *mem_ctx,
        int n_services=lp_numservices();
        char *aprinter;
        const char *printername;
-       const char *servername;
+       const char *servername = NULL;
        fstring sname;
        bool found = false;
        struct spoolss_PrinterInfo2 *info2 = NULL;
@@ -519,7 +529,7 @@ static bool set_printer_hnd_name(TALLOC_CTX *mem_ctx,
                                            sname,
                                            &info2);
                if ( !W_ERROR_IS_OK(result) ) {
-                       DEBUG(0,("set_printer_hnd_name: failed to lookup printer [%s] -- result [%s]\n",
+                       DEBUG(2,("set_printer_hnd_name: failed to lookup printer [%s] -- result [%s]\n",
                                 sname, win_errstr(result)));
                        continue;
                }
@@ -557,7 +567,7 @@ static bool set_printer_hnd_name(TALLOC_CTX *mem_ctx,
  Find first available printer slot. creates a printer handle for you.
  ****************************************************************************/
 
-static bool open_printer_hnd(pipes_struct *p, struct policy_handle *hnd,
+static bool open_printer_hnd(struct pipes_struct *p, struct policy_handle *hnd,
                             const char *name, uint32_t access_granted)
 {
        Printer_entry *new_printer;
@@ -1329,6 +1339,10 @@ void do_drv_upgrade_printer(struct messaging_context *msg,
                        continue;
                }
 
+               if (!pinfo2->drivername) {
+                       continue;
+               }
+
                if (strcmp(drivername, pinfo2->drivername) != 0) {
                        continue;
                }
@@ -1383,7 +1397,7 @@ void update_monitored_printq_cache( void )
  _spoolss_OpenPrinter
 ****************************************************************/
 
-WERROR _spoolss_OpenPrinter(pipes_struct *p,
+WERROR _spoolss_OpenPrinter(struct pipes_struct *p,
                            struct spoolss_OpenPrinter *r)
 {
        struct spoolss_OpenPrinterEx e;
@@ -1451,7 +1465,7 @@ static WERROR copy_devicemode(TALLOC_CTX *mem_ctx,
  _spoolss_OpenPrinterEx
 ****************************************************************/
 
-WERROR _spoolss_OpenPrinterEx(pipes_struct *p,
+WERROR _spoolss_OpenPrinterEx(struct pipes_struct *p,
                              struct spoolss_OpenPrinterEx *r)
 {
        int snum;
@@ -1685,7 +1699,7 @@ WERROR _spoolss_OpenPrinterEx(pipes_struct *p,
  _spoolss_ClosePrinter
 ****************************************************************/
 
-WERROR _spoolss_ClosePrinter(pipes_struct *p,
+WERROR _spoolss_ClosePrinter(struct pipes_struct *p,
                             struct spoolss_ClosePrinter *r)
 {
        Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
@@ -1715,7 +1729,7 @@ WERROR _spoolss_ClosePrinter(pipes_struct *p,
  _spoolss_DeletePrinter
 ****************************************************************/
 
-WERROR _spoolss_DeletePrinter(pipes_struct *p,
+WERROR _spoolss_DeletePrinter(struct pipes_struct *p,
                              struct spoolss_DeletePrinter *r)
 {
        Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
@@ -1776,7 +1790,7 @@ static int get_version_id(const char *arch)
  _spoolss_DeletePrinterDriver
 ****************************************************************/
 
-WERROR _spoolss_DeletePrinterDriver(pipes_struct *p,
+WERROR _spoolss_DeletePrinterDriver(struct pipes_struct *p,
                                    struct spoolss_DeletePrinterDriver *r)
 {
 
@@ -1869,7 +1883,7 @@ done:
  _spoolss_DeletePrinterDriverEx
 ****************************************************************/
 
-WERROR _spoolss_DeletePrinterDriverEx(pipes_struct *p,
+WERROR _spoolss_DeletePrinterDriverEx(struct pipes_struct *p,
                                      struct spoolss_DeletePrinterDriverEx *r)
 {
        struct spoolss_DriverInfo8      *info = NULL;
@@ -2022,19 +2036,6 @@ done:
 }
 
 
-/****************************************************************************
- Internal routine for storing printerdata
- ***************************************************************************/
-
-WERROR set_printer_dataex(NT_PRINTER_INFO_LEVEL *printer,
-                         const char *key, const char *value,
-                         uint32_t type, uint8_t *data, int real_len)
-{
-       /* the registry objects enforce uniqueness based on value name */
-
-       return add_printer_data( printer->info_2, key, value, type, data, real_len );
-}
-
 /********************************************************************
  GetPrinterData on a printer server Handle.
 ********************************************************************/
@@ -2179,7 +2180,7 @@ static WERROR getprinterdata_printer_server(TALLOC_CTX *mem_ctx,
  _spoolss_GetPrinterData
 ****************************************************************/
 
-WERROR _spoolss_GetPrinterData(pipes_struct *p,
+WERROR _spoolss_GetPrinterData(struct pipes_struct *p,
                               struct spoolss_GetPrinterData *r)
 {
        struct spoolss_GetPrinterDataEx r2;
@@ -2384,7 +2385,7 @@ static struct spoolss_NotifyOption *dup_spoolss_NotifyOption(TALLOC_CTX *mem_ctx
  * called from api_spoolss_rffpcnex
 ****************************************************************/
 
-WERROR _spoolss_RemoteFindFirstPrinterChangeNotifyEx(pipes_struct *p,
+WERROR _spoolss_RemoteFindFirstPrinterChangeNotifyEx(struct pipes_struct *p,
                                                     struct spoolss_RemoteFindFirstPrinterChangeNotifyEx *r)
 {
        int snum = -1;
@@ -3169,7 +3170,7 @@ static bool construct_notify_jobs_info(print_queue_struct *queue,
  *
  ********************************************************************/
 
-static WERROR printserver_notify_info(pipes_struct *p,
+static WERROR printserver_notify_info(struct pipes_struct *p,
                                      struct policy_handle *hnd,
                                      struct spoolss_NotifyInfo *info,
                                      TALLOC_CTX *mem_ctx)
@@ -3213,7 +3214,7 @@ static WERROR printserver_notify_info(pipes_struct *p,
                                continue; /* skip */
                        }
 
-                       /* FIXME: should we use a SYSTEM server_info here? */
+                       /* Maybe we should use the SYSTEM server_info here... */
                        result = winreg_get_printer(mem_ctx, p->server_info,
                                                    Printer->servername,
                                                    lp_servicename(snum),
@@ -3260,7 +3261,8 @@ static WERROR printserver_notify_info(pipes_struct *p,
  *
  ********************************************************************/
 
-static WERROR printer_notify_info(pipes_struct *p, struct policy_handle *hnd,
+static WERROR printer_notify_info(struct pipes_struct *p,
+                                 struct policy_handle *hnd,
                                  struct spoolss_NotifyInfo *info,
                                  TALLOC_CTX *mem_ctx)
 {
@@ -3296,7 +3298,7 @@ static WERROR printer_notify_info(pipes_struct *p, struct policy_handle *hnd,
 
        get_printer_snum(p, hnd, &snum, NULL);
 
-       /* FIXME: should we use a SYSTEM server_info here ? */
+       /* Maybe we should use the SYSTEM server_info here... */
        result = winreg_get_printer(mem_ctx, p->server_info,
                                    Printer->servername,
                                    lp_servicename(snum), &pinfo2);
@@ -3357,7 +3359,7 @@ static WERROR printer_notify_info(pipes_struct *p, struct policy_handle *hnd,
  _spoolss_RouterRefreshPrinterChangeNotify
 ****************************************************************/
 
-WERROR _spoolss_RouterRefreshPrinterChangeNotify(pipes_struct *p,
+WERROR _spoolss_RouterRefreshPrinterChangeNotify(struct pipes_struct *p,
                                                 struct spoolss_RouterRefreshPrinterChangeNotify *r)
 {
        struct spoolss_NotifyInfo *info;
@@ -4076,7 +4078,7 @@ static WERROR enumprinters_level5(TALLOC_CTX *mem_ctx,
  _spoolss_EnumPrinters
 ****************************************************************/
 
-WERROR _spoolss_EnumPrinters(pipes_struct *p,
+WERROR _spoolss_EnumPrinters(struct pipes_struct *p,
                             struct spoolss_EnumPrinters *r)
 {
        const char *name = NULL;
@@ -4160,7 +4162,7 @@ WERROR _spoolss_EnumPrinters(pipes_struct *p,
  _spoolss_GetPrinter
 ****************************************************************/
 
-WERROR _spoolss_GetPrinter(pipes_struct *p,
+WERROR _spoolss_GetPrinter(struct pipes_struct *p,
                           struct spoolss_GetPrinter *r)
 {
        Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
@@ -4255,30 +4257,52 @@ WERROR _spoolss_GetPrinter(pipes_struct *p,
 /********************************************************************
  ********************************************************************/
 
-static const char **string_array_from_driver_info(TALLOC_CTX *mem_ctx,
+#define FILL_DRIVER_STRING(mem_ctx, in, out) \
+       do { \
+               if (in && strlen(in)) { \
+                       out = talloc_strdup(mem_ctx, in); \
+               } else { \
+                       out = talloc_strdup(mem_ctx, ""); \
+               } \
+               W_ERROR_HAVE_NO_MEMORY(out); \
+       } while (0);
+
+#define FILL_DRIVER_UNC_STRING(mem_ctx, server, arch, ver, in, out) \
+       do { \
+               if (in && strlen(in)) { \
+                       out = talloc_asprintf(mem_ctx, "\\\\%s\\print$\\%s\\%d\\%s", server, get_short_archi(arch), ver, in); \
+               } else { \
+                       out = talloc_strdup(mem_ctx, ""); \
+               } \
+               W_ERROR_HAVE_NO_MEMORY(out); \
+       } while (0);
+
+static WERROR string_array_from_driver_info(TALLOC_CTX *mem_ctx,
                                                  const char **string_array,
-                                                 const char *cservername)
+                                                 const char ***presult,
+                                                 const char *cservername,
+                                                 const char *arch,
+                                                 int version)
 {
        int i, num_strings = 0;
        const char **array = NULL;
 
-       if (!string_array) {
-               return NULL;
+       if (string_array == NULL) {
+               return WERR_INVALID_PARAMETER;;
        }
 
        for (i=0; string_array[i] && string_array[i][0] != '\0'; i++) {
+               const char *str = NULL;
 
-               const char *str = talloc_asprintf(mem_ctx, "\\\\%s%s",
-                                                 cservername, string_array[i]);
-               if (!str) {
-                       TALLOC_FREE(array);
-                       return NULL;
+               if (cservername == NULL || arch == NULL) {
+                       FILL_DRIVER_STRING(mem_ctx, string_array[i], str);
+               } else {
+                       FILL_DRIVER_UNC_STRING(mem_ctx, cservername, arch, version, string_array[i], str);
                }
 
-
                if (!add_string_to_array(mem_ctx, str, &array, &num_strings)) {
                        TALLOC_FREE(array);
-                       return NULL;
+                       return WERR_NOMEM;
                }
        }
 
@@ -4287,28 +4311,12 @@ static const char **string_array_from_driver_info(TALLOC_CTX *mem_ctx,
                             &array, &num_strings);
        }
 
-       return array;
-}
-
-#define FILL_DRIVER_STRING(mem_ctx, in, out) \
-       do { \
-               if (in && strlen(in)) { \
-                       out = talloc_strdup(mem_ctx, in); \
-                       W_ERROR_HAVE_NO_MEMORY(out); \
-               } else { \
-                       out = NULL; \
-               } \
-       } while (0);
+       if (presult) {
+               *presult = array;
+       }
 
-#define FILL_DRIVER_UNC_STRING(mem_ctx, server, in, out) \
-       do { \
-               if (in && strlen(in)) { \
-                       out = talloc_asprintf(mem_ctx, "\\\\%s%s", server, in); \
-               } else { \
-                       out = talloc_strdup(mem_ctx, ""); \
-               } \
-               W_ERROR_HAVE_NO_MEMORY(out); \
-       } while (0);
+       return WERR_OK;
+}
 
 /********************************************************************
  * fill a spoolss_DriverInfo1 struct
@@ -4345,14 +4353,20 @@ static WERROR fill_printer_driver_info2(TALLOC_CTX *mem_ctx,
        W_ERROR_HAVE_NO_MEMORY(r->architecture);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->driver_path,
                               r->driver_path);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->data_file,
                               r->data_file);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->config_file,
                               r->config_file);
 
@@ -4378,18 +4392,26 @@ static WERROR fill_printer_driver_info3(TALLOC_CTX *mem_ctx,
        W_ERROR_HAVE_NO_MEMORY(r->architecture);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->driver_path,
                               r->driver_path);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->data_file,
                               r->data_file);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->config_file,
                               r->config_file);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->help_file,
                               r->help_file);
 
@@ -4401,10 +4423,12 @@ static WERROR fill_printer_driver_info3(TALLOC_CTX *mem_ctx,
                           driver->default_datatype,
                           r->default_datatype);
 
-       r->dependent_files = string_array_from_driver_info(mem_ctx,
-                                                          driver->dependent_files,
-                                                          cservername);
-       return WERR_OK;
+       return string_array_from_driver_info(mem_ctx,
+                                            driver->dependent_files,
+                                            &r->dependent_files,
+                                            cservername,
+                                            driver->architecture,
+                                            driver->version);
 }
 
 /********************************************************************
@@ -4417,6 +4441,7 @@ static WERROR fill_printer_driver_info4(TALLOC_CTX *mem_ctx,
                                        const char *servername)
 {
        const char *cservername = canon_servername(servername);
+       WERROR result;
 
        r->version              = driver->version;
 
@@ -4426,24 +4451,38 @@ static WERROR fill_printer_driver_info4(TALLOC_CTX *mem_ctx,
        W_ERROR_HAVE_NO_MEMORY(r->architecture);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->driver_path,
                               r->driver_path);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->data_file,
                               r->data_file);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->config_file,
                               r->config_file);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->help_file,
                               r->help_file);
 
-       r->dependent_files = string_array_from_driver_info(mem_ctx,
-                                                          driver->dependent_files,
-                                                          cservername);
+       result = string_array_from_driver_info(mem_ctx,
+                                              driver->dependent_files,
+                                              &r->dependent_files,
+                                              cservername,
+                                              driver->architecture,
+                                              driver->version);
+       if (!W_ERROR_IS_OK(result)) {
+               return result;
+       }
 
        FILL_DRIVER_STRING(mem_ctx,
                           driver->monitor_name,
@@ -4453,11 +4492,13 @@ static WERROR fill_printer_driver_info4(TALLOC_CTX *mem_ctx,
                           driver->default_datatype,
                           r->default_datatype);
 
-       r->previous_names = string_array_from_driver_info(mem_ctx,
-                                                         driver->previous_names,
-                                                         cservername);
 
-       return WERR_OK;
+       result = string_array_from_driver_info(mem_ctx,
+                                              driver->previous_names,
+                                              &r->previous_names,
+                                              NULL, NULL, 0);
+
+       return result;
 }
 
 /********************************************************************
@@ -4479,14 +4520,20 @@ static WERROR fill_printer_driver_info5(TALLOC_CTX *mem_ctx,
        W_ERROR_HAVE_NO_MEMORY(r->architecture);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->driver_path,
                               r->driver_path);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->data_file,
                               r->data_file);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->config_file,
                               r->config_file);
 
@@ -4506,6 +4553,7 @@ static WERROR fill_printer_driver_info6(TALLOC_CTX *mem_ctx,
                                        const char *servername)
 {
        const char *cservername = canon_servername(servername);
+       WERROR result;
 
        r->version              = driver->version;
 
@@ -4515,18 +4563,26 @@ static WERROR fill_printer_driver_info6(TALLOC_CTX *mem_ctx,
        W_ERROR_HAVE_NO_MEMORY(r->architecture);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->driver_path,
                               r->driver_path);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->data_file,
                               r->data_file);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->config_file,
                               r->config_file);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->help_file,
                               r->help_file);
 
@@ -4538,12 +4594,23 @@ static WERROR fill_printer_driver_info6(TALLOC_CTX *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);
+       result = string_array_from_driver_info(mem_ctx,
+                                              driver->dependent_files,
+                                              &r->dependent_files,
+                                              cservername,
+                                              driver->architecture,
+                                              driver->version);
+       if (!W_ERROR_IS_OK(result)) {
+               return result;
+       }
+
+       result = string_array_from_driver_info(mem_ctx,
+                                              driver->previous_names,
+                                              &r->previous_names,
+                                              NULL, NULL, 0);
+       if (!W_ERROR_IS_OK(result)) {
+               return result;
+       }
 
        r->driver_date          = driver->driver_date;
        r->driver_version       = driver->driver_version;
@@ -4574,6 +4641,7 @@ static WERROR fill_printer_driver_info8(TALLOC_CTX *mem_ctx,
                                        const char *servername)
 {
        const char *cservername = canon_servername(servername);
+       WERROR result;
 
        r->version              = driver->version;
 
@@ -4583,18 +4651,26 @@ static WERROR fill_printer_driver_info8(TALLOC_CTX *mem_ctx,
        W_ERROR_HAVE_NO_MEMORY(r->architecture);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->driver_path,
                               r->driver_path);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->data_file,
                               r->data_file);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->config_file,
                               r->config_file);
 
        FILL_DRIVER_UNC_STRING(mem_ctx, cservername,
+                              driver->architecture,
+                              driver->version,
                               driver->help_file,
                               r->help_file);
 
@@ -4606,12 +4682,23 @@ static WERROR fill_printer_driver_info8(TALLOC_CTX *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);
+       result = string_array_from_driver_info(mem_ctx,
+                                              driver->dependent_files,
+                                              &r->dependent_files,
+                                              cservername,
+                                              driver->architecture,
+                                              driver->version);
+       if (!W_ERROR_IS_OK(result)) {
+               return result;
+       }
+
+       result = string_array_from_driver_info(mem_ctx,
+                                              driver->previous_names,
+                                              &r->previous_names,
+                                              NULL, NULL, 0);
+       if (!W_ERROR_IS_OK(result)) {
+               return result;
+       }
 
        r->driver_date          = driver->driver_date;
        r->driver_version       = driver->driver_version;
@@ -4636,9 +4723,13 @@ static WERROR fill_printer_driver_info8(TALLOC_CTX *mem_ctx,
                           driver->vendor_setup,
                           r->vendor_setup);
 
-       r->color_profiles = string_array_from_driver_info(mem_ctx,
-                                                         driver->color_profiles,
-                                                         cservername);
+       result = string_array_from_driver_info(mem_ctx,
+                                              driver->color_profiles,
+                                              &r->color_profiles,
+                                              NULL, NULL, 0);
+       if (!W_ERROR_IS_OK(result)) {
+               return result;
+       }
 
        FILL_DRIVER_STRING(mem_ctx,
                           driver->inf_path,
@@ -4646,9 +4737,13 @@ static WERROR fill_printer_driver_info8(TALLOC_CTX *mem_ctx,
 
        r->printer_driver_attributes    = driver->printer_driver_attributes;
 
-       r->core_driver_dependencies = string_array_from_driver_info(mem_ctx,
-                                                                   driver->core_driver_dependencies,
-                                                                   cservername);
+       result = string_array_from_driver_info(mem_ctx,
+                                              driver->core_driver_dependencies,
+                                              &r->core_driver_dependencies,
+                                              NULL, NULL, 0);
+       if (!W_ERROR_IS_OK(result)) {
+               return result;
+       }
 
        r->min_inbox_driver_ver_date    = driver->min_inbox_driver_ver_date;
        r->min_inbox_driver_ver_version = driver->min_inbox_driver_ver_version;
@@ -4809,9 +4904,14 @@ static WERROR fill_printer_driver_info101(TALLOC_CTX *mem_ctx,
                           driver->default_datatype,
                           r->default_datatype);
 
-       r->previous_names = string_array_from_driver_info(mem_ctx,
-                                                         driver->previous_names,
-                                                         cservername);
+       result = string_array_from_driver_info(mem_ctx,
+                                              driver->previous_names,
+                                              &r->previous_names,
+                                              NULL, NULL, 0);
+       if (!W_ERROR_IS_OK(result)) {
+               return result;
+       }
+
        r->driver_date          = driver->driver_date;
        r->driver_version       = driver->driver_version;
 
@@ -4931,13 +5031,12 @@ static WERROR construct_printer_driver_info_level(TALLOC_CTX *mem_ctx,
  _spoolss_GetPrinterDriver2
 ****************************************************************/
 
-WERROR _spoolss_GetPrinterDriver2(pipes_struct *p,
+WERROR _spoolss_GetPrinterDriver2(struct pipes_struct *p,
                                  struct spoolss_GetPrinterDriver2 *r)
 {
        Printer_entry *printer;
        WERROR result;
 
-       const char *servername;
        int snum;
 
        /* that's an [in out] buffer */
@@ -4957,15 +5056,13 @@ WERROR _spoolss_GetPrinterDriver2(pipes_struct *p,
        *r->out.server_major_version = 0;
        *r->out.server_minor_version = 0;
 
-       servername = get_server_name(printer);
-
        if (!get_printer_snum(p, r->in.handle, &snum, NULL)) {
                return WERR_BADFID;
        }
 
        result = construct_printer_driver_info_level(p->mem_ctx, p->server_info,
                                                     r->in.level, r->out.info,
-                                                    snum, servername,
+                                                    snum, printer->servername,
                                                     r->in.architecture,
                                                     r->in.client_major_version);
        if (!W_ERROR_IS_OK(result)) {
@@ -4985,7 +5082,7 @@ WERROR _spoolss_GetPrinterDriver2(pipes_struct *p,
  _spoolss_StartPagePrinter
 ****************************************************************/
 
-WERROR _spoolss_StartPagePrinter(pipes_struct *p,
+WERROR _spoolss_StartPagePrinter(struct pipes_struct *p,
                                 struct spoolss_StartPagePrinter *r)
 {
        Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
@@ -5004,7 +5101,7 @@ WERROR _spoolss_StartPagePrinter(pipes_struct *p,
  _spoolss_EndPagePrinter
 ****************************************************************/
 
-WERROR _spoolss_EndPagePrinter(pipes_struct *p,
+WERROR _spoolss_EndPagePrinter(struct pipes_struct *p,
                               struct spoolss_EndPagePrinter *r)
 {
        int snum;
@@ -5030,12 +5127,13 @@ WERROR _spoolss_EndPagePrinter(pipes_struct *p,
  _spoolss_StartDocPrinter
 ****************************************************************/
 
-WERROR _spoolss_StartDocPrinter(pipes_struct *p,
+WERROR _spoolss_StartDocPrinter(struct pipes_struct *p,
                                struct spoolss_StartDocPrinter *r)
 {
        struct spoolss_DocumentInfo1 *info_1;
        int snum;
        Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
+       WERROR werr;
 
        if (!Printer) {
                DEBUG(2,("_spoolss_StartDocPrinter: "
@@ -5044,6 +5142,13 @@ WERROR _spoolss_StartDocPrinter(pipes_struct *p,
                return WERR_BADFID;
        }
 
+       if (Printer->jobid) {
+               DEBUG(2, ("_spoolss_StartDocPrinter: "
+                         "StartDocPrinter called twice! "
+                         "(existing jobid = %d)\n", Printer->jobid));
+               return WERR_INVALID_HANDLE;
+       }
+
        if (r->in.level != 1) {
                return WERR_UNKNOWN_LEVEL;
        }
@@ -5070,15 +5175,15 @@ WERROR _spoolss_StartDocPrinter(pipes_struct *p,
                return WERR_BADFID;
        }
 
-       Printer->jobid = print_job_start(p->server_info, snum,
-                                        info_1->document_name,
-                                        Printer->devmode);
+       werr = print_job_start(p->server_info, snum,
+                               info_1->document_name, info_1->output_file,
+                               Printer->devmode, &Printer->jobid);
 
        /* An error occured in print_job_start() so return an appropriate
           NT error code. */
 
-       if (Printer->jobid == -1) {
-               return map_werror_from_unix(errno);
+       if (!W_ERROR_IS_OK(werr)) {
+               return werr;
        }
 
        Printer->document_started = true;
@@ -5091,10 +5196,11 @@ WERROR _spoolss_StartDocPrinter(pipes_struct *p,
  _spoolss_EndDocPrinter
 ****************************************************************/
 
-WERROR _spoolss_EndDocPrinter(pipes_struct *p,
+WERROR _spoolss_EndDocPrinter(struct pipes_struct *p,
                              struct spoolss_EndDocPrinter *r)
 {
        Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
+       NTSTATUS status;
        int snum;
 
        if (!Printer) {
@@ -5108,17 +5214,22 @@ WERROR _spoolss_EndDocPrinter(pipes_struct *p,
        }
 
        Printer->document_started = false;
-       print_job_end(snum, Printer->jobid, NORMAL_CLOSE);
-       /* error codes unhandled so far ... */
+       status = print_job_end(snum, Printer->jobid, NORMAL_CLOSE);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(2, ("_spoolss_EndDocPrinter: "
+                         "print_job_end failed [%s]\n",
+                         nt_errstr(status)));
+       }
 
-       return WERR_OK;
+       Printer->jobid = 0;
+       return ntstatus_to_werror(status);
 }
 
 /****************************************************************
  _spoolss_WritePrinter
 ****************************************************************/
 
-WERROR _spoolss_WritePrinter(pipes_struct *p,
+WERROR _spoolss_WritePrinter(struct pipes_struct *p,
                             struct spoolss_WritePrinter *r)
 {
        ssize_t buffer_written;
@@ -5135,6 +5246,7 @@ WERROR _spoolss_WritePrinter(pipes_struct *p,
        if (!get_printer_snum(p, r->in.handle, &snum, NULL))
                return WERR_BADFID;
 
+       /* print_job_write takes care of checking for PJOB_SMBD_SPOOLING */
        buffer_written = print_job_write(snum, Printer->jobid,
                                                   (const char *)r->in.data.data,
                                                   (SMB_OFF_T)-1,
@@ -5159,7 +5271,7 @@ WERROR _spoolss_WritePrinter(pipes_struct *p,
  ********************************************************************/
 
 static WERROR control_printer(struct policy_handle *handle, uint32_t command,
-                             pipes_struct *p)
+                             struct pipes_struct *p)
 {
        int snum;
        WERROR errcode = WERR_BADFUNC;
@@ -5199,7 +5311,7 @@ static WERROR control_printer(struct policy_handle *handle, uint32_t command,
  * for spooling"
 ****************************************************************/
 
-WERROR _spoolss_AbortPrinter(pipes_struct *p,
+WERROR _spoolss_AbortPrinter(struct pipes_struct *p,
                             struct spoolss_AbortPrinter *r)
 {
        Printer_entry   *Printer = find_printer_index_by_hnd(p, r->in.handle);
@@ -5215,7 +5327,11 @@ WERROR _spoolss_AbortPrinter(pipes_struct *p,
        if (!get_printer_snum(p, r->in.handle, &snum, NULL))
                return WERR_BADFID;
 
-       print_job_delete(p->server_info, snum, Printer->jobid, &errcode );
+       if (!Printer->document_started) {
+               return WERR_SPL_NO_STARTDOC;
+       }
+
+       errcode = print_job_delete(p->server_info, snum, Printer->jobid);
 
        return errcode;
 }
@@ -5226,7 +5342,8 @@ WERROR _spoolss_AbortPrinter(pipes_struct *p,
  ********************************************************************/
 
 static WERROR update_printer_sec(struct policy_handle *handle,
-                                pipes_struct *p, struct sec_desc_buf *secdesc_ctr)
+                                struct pipes_struct *p,
+                                struct sec_desc_buf *secdesc_ctr)
 {
        struct spoolss_security_descriptor *new_secdesc = NULL;
        struct spoolss_security_descriptor *old_secdesc = NULL;
@@ -5278,7 +5395,7 @@ static WERROR update_printer_sec(struct policy_handle *handle,
                struct security_acl *the_acl;
                int i;
 
-               the_acl = secdesc_ctr->sd->dacl;
+               the_acl = old_secdesc->dacl;
                DEBUG(10, ("old_secdesc_ctr for %s has %d aces:\n",
                           printer, the_acl->num_aces));
 
@@ -5326,11 +5443,6 @@ static WERROR update_printer_sec(struct policy_handle *handle,
 
 /********************************************************************
  Canonicalize printer info from a client
-
- ATTN: It does not matter what we set the servername to hear
- since we do the necessary work in get_a_printer() to set it to
- the correct value based on what the client sent in the
- _spoolss_open_printer_ex().
  ********************************************************************/
 
 static bool check_printer_ok(TALLOC_CTX *mem_ctx,
@@ -5435,7 +5547,8 @@ static WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *p
 ****************************************************************************/
 
 bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token,
-                     struct spoolss_SetPrinterInfo2 *info2)
+                     struct spoolss_SetPrinterInfo2 *info2,
+                     const char *remote_machine)
 {
        char *cmd = lp_addprinter_cmd();
        char **qlines;
@@ -5445,18 +5558,10 @@ bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token,
        int fd;
        SE_PRIV se_printop = SE_PRINT_OPERATOR;
        bool is_print_op = false;
-       char *remote_machine = talloc_strdup(ctx, "%m");
 
        if (!remote_machine) {
                return false;
        }
-       remote_machine = talloc_sub_basic(ctx,
-                               current_user_info.smb_name,
-                               current_user_info.domain,
-                               remote_machine);
-       if (!remote_machine) {
-               return false;
-       }
 
        command = talloc_asprintf(ctx,
                        "%s \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"",
@@ -5491,7 +5596,6 @@ bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token,
        DEBUGADD(10,("returned [%d]\n", ret));
 
        TALLOC_FREE(command);
-       TALLOC_FREE(remote_machine);
 
        if ( ret != 0 ) {
                if (fd != -1)
@@ -5523,220 +5627,362 @@ bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token,
        return true;
 }
 
-
-/********************************************************************
- * Called by spoolss_api_setprinter
- * when updating a printer description.
- ********************************************************************/
-
-static WERROR update_printer(pipes_struct *p, struct policy_handle *handle,
-                            struct spoolss_SetPrinterInfoCtr *info_ctr,
-                            struct spoolss_DeviceMode *devmode)
+static WERROR update_dsspooler(TALLOC_CTX *mem_ctx,
+                              struct auth_serversupplied_info *server_info,
+                              int snum,
+                              struct spoolss_SetPrinterInfo2 *printer,
+                              struct spoolss_PrinterInfo2 *old_printer)
 {
-       uint32_t printer_mask = SPOOLSS_PRINTER_INFO_ALL;
-       struct spoolss_SetPrinterInfo2 *printer = info_ctr->info.info2;
-       struct spoolss_PrinterInfo2 *old_printer;
-       Printer_entry *Printer = find_printer_index_by_hnd(p, handle);
-       const char *servername = NULL;
-       int snum;
-       WERROR result;
+       bool force_update = (old_printer == NULL);
+       const char *dnsdomname;
+       const char *longname;
+       const char *uncname;
+       const char *spooling;
        DATA_BLOB buffer;
-       fstring asc_buffer;
+       WERROR result = WERR_OK;
 
-       DEBUG(8,("update_printer\n"));
+       if (force_update || !strequal(printer->drivername, old_printer->drivername)) {
+               push_reg_sz(mem_ctx, &buffer, printer->drivername);
+               winreg_set_printer_dataex(mem_ctx,
+                                         server_info,
+                                         printer->sharename,
+                                         SPOOL_DSSPOOLER_KEY,
+                                         SPOOL_REG_DRIVERNAME,
+                                         REG_SZ,
+                                         buffer.data,
+                                         buffer.length);
 
-       result = WERR_OK;
+               if (!force_update) {
+                       DEBUG(10,("update_printer: changing driver [%s]!  Sending event!\n",
+                               printer->drivername));
 
-       if (!Printer) {
-               result = WERR_BADFID;
-               goto done;
+                       notify_printer_driver(snum, printer->drivername);
+               }
        }
 
-       if (!get_printer_snum(p, handle, &snum, NULL)) {
-               result = WERR_BADFID;
-               goto done;
-       }
+       if (force_update || !strequal(printer->comment, old_printer->comment)) {
+               push_reg_sz(mem_ctx, &buffer, printer->comment);
+               winreg_set_printer_dataex(mem_ctx,
+                                         server_info,
+                                         printer->sharename,
+                                         SPOOL_DSSPOOLER_KEY,
+                                         SPOOL_REG_DESCRIPTION,
+                                         REG_SZ,
+                                         buffer.data,
+                                         buffer.length);
 
-       if (Printer != NULL || Printer->servername != NULL) {
-               servername = Printer->servername;
+               if (!force_update) {
+                       notify_printer_comment(snum, printer->comment);
+               }
        }
 
-       result = winreg_get_printer(p->mem_ctx,
-                                   p->server_info,
-                                   servername,
-                                   lp_const_servicename(snum),
-                                   &old_printer);
-       if (!W_ERROR_IS_OK(result)) {
-               result = WERR_BADFID;
-               goto done;
-       }
+       if (force_update || !strequal(printer->sharename, old_printer->sharename)) {
+               push_reg_sz(mem_ctx, &buffer, printer->sharename);
+               winreg_set_printer_dataex(mem_ctx,
+                                         server_info,
+                                         printer->sharename,
+                                         SPOOL_DSSPOOLER_KEY,
+                                         SPOOL_REG_PRINTSHARENAME,
+                                         REG_SZ,
+                                         buffer.data,
+                                         buffer.length);
 
-       /* Do sanity check on the requested changes for Samba */
-       if (!check_printer_ok(p->mem_ctx, printer, snum)) {
-               result = WERR_INVALID_PARAM;
-               goto done;
+               if (!force_update) {
+                       notify_printer_sharename(snum, printer->sharename);
+               }
        }
 
-       /* FIXME!!! If the driver has changed we really should verify that
-          it is installed before doing much else   --jerry */
+       if (force_update || !strequal(printer->printername, old_printer->printername)) {
+               const char *p;
 
-       /* Check calling user has permission to update printer description */
-       if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) {
-               DEBUG(3, ("update_printer: printer property change denied by handle\n"));
-               result = WERR_ACCESS_DENIED;
-               goto done;
-       }
+               p = strrchr(printer->printername, '\\' );
+               if (p != NULL) {
+                       p++;
+               } else {
+                       p = printer->printername;
+               }
 
-       /* Call addprinter hook */
-       /* Check changes to see if this is really needed */
+               push_reg_sz(mem_ctx, &buffer, p);
+               winreg_set_printer_dataex(mem_ctx,
+                                         server_info,
+                                         printer->sharename,
+                                         SPOOL_DSSPOOLER_KEY,
+                                         SPOOL_REG_PRINTERNAME,
+                                         REG_SZ,
+                                         buffer.data,
+                                         buffer.length);
 
-       if (*lp_addprinter_cmd() &&
-                       (!strequal(printer->drivername, old_printer->drivername) ||
-                        !strequal(printer->comment, old_printer->comment) ||
-                        !strequal(printer->portname, old_printer->portname) ||
-                        !strequal(printer->location, old_printer->location)) )
-       {
-               /* add_printer_hook() will call reload_services() */
-               if (!add_printer_hook(p->mem_ctx, p->server_info->ptok,
-                                     printer) ) {
-                       result = WERR_ACCESS_DENIED;
-                       goto done;
+               if (!force_update) {
+                       notify_printer_printername(snum, p);
                }
        }
 
-       /*
-        * When a *new* driver is bound to a printer, the drivername is used to
-        * lookup previously saved driver initialization info, which is then
-        * bound to the printer, simulating what happens in the Windows arch.
-        */
-       if (!strequal(printer->drivername, old_printer->drivername)) {
-               DEBUG(10,("update_printer: changing driver [%s]!  Sending event!\n",
-                       printer->drivername));
+       if (force_update || !strequal(printer->portname, old_printer->portname)) {
+               push_reg_sz(mem_ctx, &buffer, printer->portname);
+               winreg_set_printer_dataex(mem_ctx,
+                                         server_info,
+                                         printer->sharename,
+                                         SPOOL_DSSPOOLER_KEY,
+                                         SPOOL_REG_PORTNAME,
+                                         REG_SZ,
+                                         buffer.data,
+                                         buffer.length);
 
-               notify_printer_driver(snum, printer->drivername);
+               if (!force_update) {
+                       notify_printer_port(snum, printer->portname);
+               }
        }
 
-       /*
-        * flag which changes actually occured.  This is a small subset of
-        * all the possible changes.  We also have to update things in the
-        * DsSpooler key.
-        */
-       if (!strequal(printer->comment, old_printer->comment)) {
-               push_reg_sz(talloc_tos(), &buffer, printer->comment);
-               winreg_set_printer_dataex(p->mem_ctx,
-                                         p->server_info,
+       if (force_update || !strequal(printer->location, old_printer->location)) {
+               push_reg_sz(mem_ctx, &buffer, printer->location);
+               winreg_set_printer_dataex(mem_ctx,
+                                         server_info,
                                          printer->sharename,
                                          SPOOL_DSSPOOLER_KEY,
-                                         "description",
+                                         SPOOL_REG_LOCATION,
                                          REG_SZ,
                                          buffer.data,
                                          buffer.length);
 
-               notify_printer_comment(snum, printer->comment);
+               if (!force_update) {
+                       notify_printer_location(snum, printer->location);
+               }
        }
 
-       if (!strequal(printer->sharename, old_printer->sharename)) {
-               push_reg_sz(talloc_tos(), &buffer, printer->sharename);
-               winreg_set_printer_dataex(p->mem_ctx,
-                                         p->server_info,
+       if (force_update || !strequal(printer->sepfile, old_printer->sepfile)) {
+               push_reg_sz(mem_ctx, &buffer, printer->sepfile);
+               winreg_set_printer_dataex(mem_ctx,
+                                         server_info,
                                          printer->sharename,
                                          SPOOL_DSSPOOLER_KEY,
-                                         "shareName",
+                                         SPOOL_REG_PRINTSEPARATORFILE,
                                          REG_SZ,
                                          buffer.data,
                                          buffer.length);
 
-               notify_printer_sharename(snum, printer->sharename);
+               if (!force_update) {
+                       notify_printer_location(snum, printer->location);
+               }
        }
 
-       if (!strequal(printer->printername, old_printer->printername)) {
-               const char *pname;
-
-               if ( (pname = strchr_m( printer->printername+2, '\\' )) != NULL )
-                       pname++;
-               else
-                       pname = printer->printername;
-
-               push_reg_sz(talloc_tos(), &buffer, pname);
-               winreg_set_printer_dataex(p->mem_ctx,
-                                         p->server_info,
+       if (force_update || printer->starttime != old_printer->starttime) {
+               buffer = data_blob_talloc(mem_ctx, NULL, 4);
+               SIVAL(buffer.data, 0, printer->starttime);
+               winreg_set_printer_dataex(mem_ctx,
+                                         server_info,
                                          printer->sharename,
                                          SPOOL_DSSPOOLER_KEY,
-                                         "printerName",
-                                         REG_SZ,
+                                         SPOOL_REG_PRINTSTARTTIME,
+                                         REG_DWORD,
                                          buffer.data,
                                          buffer.length);
-
-               notify_printer_printername( snum, pname );
        }
 
-       if (!strequal(printer->portname, old_printer->portname)) {
-               push_reg_sz(talloc_tos(), &buffer, printer->portname);
-               winreg_set_printer_dataex(p->mem_ctx,
-                                         p->server_info,
+       if (force_update || printer->untiltime != old_printer->untiltime) {
+               buffer = data_blob_talloc(mem_ctx, NULL, 4);
+               SIVAL(buffer.data, 0, printer->untiltime);
+               winreg_set_printer_dataex(mem_ctx,
+                                         server_info,
                                          printer->sharename,
                                          SPOOL_DSSPOOLER_KEY,
-                                         "portName",
-                                         REG_SZ,
+                                         SPOOL_REG_PRINTENDTIME,
+                                         REG_DWORD,
                                          buffer.data,
                                          buffer.length);
+       }
 
-               notify_printer_port(snum, printer->portname);
+       if (force_update || printer->priority != old_printer->priority) {
+               buffer = data_blob_talloc(mem_ctx, NULL, 4);
+               SIVAL(buffer.data, 0, printer->priority);
+               winreg_set_printer_dataex(mem_ctx,
+                                         server_info,
+                                         printer->sharename,
+                                         SPOOL_DSSPOOLER_KEY,
+                                         SPOOL_REG_PRIORITY,
+                                         REG_DWORD,
+                                         buffer.data,
+                                         buffer.length);
        }
 
-       if (!strequal(printer->location, old_printer->location)) {
-               push_reg_sz(talloc_tos(), &buffer, printer->location);
-               winreg_set_printer_dataex(p->mem_ctx,
-                                         p->server_info,
+       if (force_update || printer->attributes != old_printer->attributes) {
+               buffer = data_blob_talloc(mem_ctx, NULL, 4);
+               SIVAL(buffer.data, 0, (printer->attributes &
+                                      PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS));
+               winreg_set_printer_dataex(mem_ctx,
+                                         server_info,
                                          printer->sharename,
                                          SPOOL_DSSPOOLER_KEY,
-                                         "location",
-                                         REG_SZ,
+                                         SPOOL_REG_PRINTKEEPPRINTEDJOBS,
+                                         REG_DWORD,
                                          buffer.data,
                                          buffer.length);
 
-               notify_printer_location(snum, printer->location);
+               switch (printer->attributes & 0x3) {
+                       case 0:
+                               spooling = SPOOL_REGVAL_PRINTWHILESPOOLING;
+                               break;
+                       case 1:
+                               spooling = SPOOL_REGVAL_PRINTAFTERSPOOLED;
+                               break;
+                       case 2:
+                               spooling = SPOOL_REGVAL_PRINTDIRECT;
+                               break;
+                       default:
+                               spooling = "unknown";
+               }
+               push_reg_sz(mem_ctx, &buffer, spooling);
+               winreg_set_printer_dataex(mem_ctx,
+                                         server_info,
+                                         printer->sharename,
+                                         SPOOL_DSSPOOLER_KEY,
+                                         SPOOL_REG_PRINTSPOOLING,
+                                         REG_SZ,
+                                         buffer.data,
+                                         buffer.length);
        }
 
-       /* here we need to update some more DsSpooler keys */
-       /* uNCName, serverName, shortServerName */
-
-       push_reg_sz(talloc_tos(), &buffer, global_myname());
-       winreg_set_printer_dataex(p->mem_ctx,
-                                 p->server_info,
+       push_reg_sz(mem_ctx, &buffer, global_myname());
+       winreg_set_printer_dataex(mem_ctx,
+                                 server_info,
                                  printer->sharename,
                                  SPOOL_DSSPOOLER_KEY,
-                                 "serverName",
+                                 SPOOL_REG_SHORTSERVERNAME,
                                  REG_SZ,
                                  buffer.data,
                                  buffer.length);
-       winreg_set_printer_dataex(p->mem_ctx,
-                                 p->server_info,
+
+       dnsdomname = get_mydnsfullname();
+       if (dnsdomname != NULL && dnsdomname[0] != '\0') {
+               longname = talloc_strdup(mem_ctx, dnsdomname);
+       } else {
+               longname = talloc_strdup(mem_ctx, global_myname());
+       }
+       if (longname == NULL) {
+               result = WERR_NOMEM;
+               goto done;
+       }
+
+       push_reg_sz(mem_ctx, &buffer, longname);
+       winreg_set_printer_dataex(mem_ctx,
+                                 server_info,
                                  printer->sharename,
                                  SPOOL_DSSPOOLER_KEY,
-                                 "shortServerName",
+                                 SPOOL_REG_SERVERNAME,
                                  REG_SZ,
                                  buffer.data,
                                  buffer.length);
 
-       slprintf( asc_buffer, sizeof(asc_buffer)-1, "\\\\%s\\%s",
-                 global_myname(), printer->sharename );
-       push_reg_sz(talloc_tos(), &buffer, asc_buffer);
-       winreg_set_printer_dataex(p->mem_ctx,
-                                 p->server_info,
+       uncname = talloc_asprintf(mem_ctx, "\\\\%s\\%s",
+                                 global_myname(), printer->sharename);
+       push_reg_sz(mem_ctx, &buffer, uncname);
+       winreg_set_printer_dataex(mem_ctx,
+                                 server_info,
                                  printer->sharename,
                                  SPOOL_DSSPOOLER_KEY,
-                                 "uNCName",
+                                 SPOOL_REG_UNCNAME,
                                  REG_SZ,
                                  buffer.data,
                                  buffer.length);
 
+done:
+       return result;
+}
+
+/********************************************************************
+ * Called by spoolss_api_setprinter
+ * when updating a printer description.
+ ********************************************************************/
+
+static WERROR update_printer(struct pipes_struct *p,
+                            struct policy_handle *handle,
+                            struct spoolss_SetPrinterInfoCtr *info_ctr,
+                            struct spoolss_DeviceMode *devmode)
+{
+       uint32_t printer_mask = SPOOLSS_PRINTER_INFO_ALL;
+       struct spoolss_SetPrinterInfo2 *printer = info_ctr->info.info2;
+       struct spoolss_PrinterInfo2 *old_printer;
+       Printer_entry *Printer = find_printer_index_by_hnd(p, handle);
+       const char *servername = NULL;
+       int snum;
+       WERROR result = WERR_OK;
+       TALLOC_CTX *tmp_ctx;
+
+       DEBUG(8,("update_printer\n"));
+
+       tmp_ctx = talloc_new(p->mem_ctx);
+       if (tmp_ctx == NULL) {
+               return WERR_NOMEM;
+       }
+
+       if (!Printer) {
+               result = WERR_BADFID;
+               goto done;
+       }
+
+       if (!get_printer_snum(p, handle, &snum, NULL)) {
+               result = WERR_BADFID;
+               goto done;
+       }
+
+       if (Printer != NULL || Printer->servername != NULL) {
+               servername = Printer->servername;
+       }
+
+       result = winreg_get_printer(tmp_ctx,
+                                   p->server_info,
+                                   servername,
+                                   lp_const_servicename(snum),
+                                   &old_printer);
+       if (!W_ERROR_IS_OK(result)) {
+               result = WERR_BADFID;
+               goto done;
+       }
+
+       /* Do sanity check on the requested changes for Samba */
+       if (!check_printer_ok(tmp_ctx, printer, snum)) {
+               result = WERR_INVALID_PARAM;
+               goto done;
+       }
+
+       /* FIXME!!! If the driver has changed we really should verify that
+          it is installed before doing much else   --jerry */
+
+       /* Check calling user has permission to update printer description */
+       if (Printer->access_granted != PRINTER_ACCESS_ADMINISTER) {
+               DEBUG(3, ("update_printer: printer property change denied by handle\n"));
+               result = WERR_ACCESS_DENIED;
+               goto done;
+       }
+
+       /* Call addprinter hook */
+       /* Check changes to see if this is really needed */
+
+       if (*lp_addprinter_cmd() &&
+                       (!strequal(printer->drivername, old_printer->drivername) ||
+                        !strequal(printer->comment, old_printer->comment) ||
+                        !strequal(printer->portname, old_printer->portname) ||
+                        !strequal(printer->location, old_printer->location)) )
+       {
+               /* add_printer_hook() will call reload_services() */
+               if (!add_printer_hook(tmp_ctx, p->server_info->ptok,
+                                     printer, p->client_address) ) {
+                       result = WERR_ACCESS_DENIED;
+                       goto done;
+               }
+       }
+
+       update_dsspooler(tmp_ctx,
+                        p->server_info,
+                        snum,
+                        printer,
+                        old_printer);
+
        printer_mask &= ~SPOOLSS_PRINTER_INFO_SECDESC;
 
        if (devmode == NULL) {
                printer_mask &= ~SPOOLSS_PRINTER_INFO_DEVMODE;
        }
-       result = winreg_update_printer(p->mem_ctx,
+       result = winreg_update_printer(tmp_ctx,
                                       p->server_info,
                                       printer->sharename,
                                       printer_mask,
@@ -5745,14 +5991,14 @@ static WERROR update_printer(pipes_struct *p, struct policy_handle *handle,
                                       NULL);
 
 done:
-       talloc_free(old_printer);
+       talloc_free(tmp_ctx);
 
        return result;
 }
 
 /****************************************************************************
 ****************************************************************************/
-static WERROR publish_or_unpublish_printer(pipes_struct *p,
+static WERROR publish_or_unpublish_printer(struct pipes_struct *p,
                                           struct policy_handle *handle,
                                           struct spoolss_SetPrinterInfo7 *info7)
 {
@@ -5795,7 +6041,8 @@ static WERROR publish_or_unpublish_printer(pipes_struct *p,
 /********************************************************************
  ********************************************************************/
 
-static WERROR update_printer_devmode(pipes_struct *p, struct policy_handle *handle,
+static WERROR update_printer_devmode(struct pipes_struct *p,
+                                    struct policy_handle *handle,
                                     struct spoolss_DeviceMode *devmode)
 {
        int snum;
@@ -5832,7 +6079,7 @@ static WERROR update_printer_devmode(pipes_struct *p, struct policy_handle *hand
  _spoolss_SetPrinter
 ****************************************************************/
 
-WERROR _spoolss_SetPrinter(pipes_struct *p,
+WERROR _spoolss_SetPrinter(struct pipes_struct *p,
                           struct spoolss_SetPrinter *r)
 {
        WERROR result;
@@ -5877,7 +6124,7 @@ WERROR _spoolss_SetPrinter(pipes_struct *p,
  _spoolss_FindClosePrinterNotify
 ****************************************************************/
 
-WERROR _spoolss_FindClosePrinterNotify(pipes_struct *p,
+WERROR _spoolss_FindClosePrinterNotify(struct pipes_struct *p,
                                       struct spoolss_FindClosePrinterNotify *r)
 {
        Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
@@ -5914,7 +6161,7 @@ WERROR _spoolss_FindClosePrinterNotify(pipes_struct *p,
  _spoolss_AddJob
 ****************************************************************/
 
-WERROR _spoolss_AddJob(pipes_struct *p,
+WERROR _spoolss_AddJob(struct pipes_struct *p,
                       struct spoolss_AddJob *r)
 {
        if (!r->in.buffer && (r->in.offered != 0)) {
@@ -6104,7 +6351,6 @@ static WERROR enumjobs_level2(TALLOC_CTX *mem_ctx,
                              union spoolss_JobInfo **info_p,
                              uint32_t *count)
 {
-       struct spoolss_DeviceMode *devmode;
        union spoolss_JobInfo *info;
        int i;
        WERROR result = WERR_OK;
@@ -6115,16 +6361,11 @@ static WERROR enumjobs_level2(TALLOC_CTX *mem_ctx,
        *count = num_queues;
 
        for (i=0; i<*count; i++) {
+               struct spoolss_DeviceMode *devmode;
 
-               if (!pinfo2->devmode) {
-                       result = spoolss_create_default_devmode(info,
+               result = spoolss_create_default_devmode(info,
                                                        pinfo2->printername,
                                                        &devmode);
-               } else {
-                       result = copy_devicemode(info,
-                                                pinfo2->devmode,
-                                                &devmode);
-               }
                if (!W_ERROR_IS_OK(result)) {
                        DEBUG(3, ("Can't proceed w/o a devmode!"));
                        goto out;
@@ -6209,7 +6450,7 @@ static WERROR enumjobs_level3(TALLOC_CTX *mem_ctx,
  _spoolss_EnumJobs
 ****************************************************************/
 
-WERROR _spoolss_EnumJobs(pipes_struct *p,
+WERROR _spoolss_EnumJobs(struct pipes_struct *p,
                         struct spoolss_EnumJobs *r)
 {
        WERROR result;
@@ -6237,7 +6478,7 @@ WERROR _spoolss_EnumJobs(pipes_struct *p,
                return WERR_BADFID;
        }
 
-       result = winreg_get_printer(talloc_tos(), p->server_info, NULL,
+       result = winreg_get_printer(p->mem_ctx, p->server_info, NULL,
                                    lp_servicename(snum), &pinfo2);
        if (!W_ERROR_IS_OK(result)) {
                return result;
@@ -6292,7 +6533,7 @@ WERROR _spoolss_EnumJobs(pipes_struct *p,
  _spoolss_ScheduleJob
 ****************************************************************/
 
-WERROR _spoolss_ScheduleJob(pipes_struct *p,
+WERROR _spoolss_ScheduleJob(struct pipes_struct *p,
                            struct spoolss_ScheduleJob *r)
 {
        return WERR_OK;
@@ -6327,7 +6568,7 @@ static WERROR spoolss_setjob_1(TALLOC_CTX *mem_ctx,
  _spoolss_SetJob
 ****************************************************************/
 
-WERROR _spoolss_SetJob(pipes_struct *p,
+WERROR _spoolss_SetJob(struct pipes_struct *p,
                       struct spoolss_SetJob *r)
 {
        int snum;
@@ -6344,7 +6585,9 @@ WERROR _spoolss_SetJob(pipes_struct *p,
        switch (r->in.command) {
        case SPOOLSS_JOB_CONTROL_CANCEL:
        case SPOOLSS_JOB_CONTROL_DELETE:
-               if (print_job_delete(p->server_info, snum, r->in.job_id, &errcode)) {
+               errcode = print_job_delete(p->server_info,
+                                          snum, r->in.job_id);
+               if (W_ERROR_EQUAL(errcode, WERR_PRINTER_HAS_JOBS_QUEUED)) {
                        errcode = WERR_OK;
                }
                break;
@@ -6561,7 +6804,7 @@ static WERROR enumprinterdrivers_level(TALLOC_CTX *mem_ctx,
  _spoolss_EnumPrinterDrivers
 ****************************************************************/
 
-WERROR _spoolss_EnumPrinterDrivers(pipes_struct *p,
+WERROR _spoolss_EnumPrinterDrivers(struct pipes_struct *p,
                                   struct spoolss_EnumPrinterDrivers *r)
 {
        const char *cservername;
@@ -6610,7 +6853,7 @@ WERROR _spoolss_EnumPrinterDrivers(pipes_struct *p,
  _spoolss_EnumForms
 ****************************************************************/
 
-WERROR _spoolss_EnumForms(pipes_struct *p,
+WERROR _spoolss_EnumForms(struct pipes_struct *p,
                          struct spoolss_EnumForms *r)
 {
        WERROR result;
@@ -6663,7 +6906,7 @@ WERROR _spoolss_EnumForms(pipes_struct *p,
  _spoolss_GetForm
 ****************************************************************/
 
-WERROR _spoolss_GetForm(pipes_struct *p,
+WERROR _spoolss_GetForm(struct pipes_struct *p,
                        struct spoolss_GetForm *r)
 {
        WERROR result;
@@ -6908,7 +7151,7 @@ out:
  _spoolss_EnumPorts
 ****************************************************************/
 
-WERROR _spoolss_EnumPorts(pipes_struct *p,
+WERROR _spoolss_EnumPorts(struct pipes_struct *p,
                          struct spoolss_EnumPorts *r)
 {
        WERROR result;
@@ -6955,7 +7198,7 @@ WERROR _spoolss_EnumPorts(pipes_struct *p,
 /****************************************************************************
 ****************************************************************************/
 
-static WERROR spoolss_addprinterex_level_2(pipes_struct *p,
+static WERROR spoolss_addprinterex_level_2(struct pipes_struct *p,
                                           const char *server,
                                           struct spoolss_SetPrinterInfoCtr *info_ctr,
                                           struct spoolss_DeviceMode *devmode,
@@ -7012,7 +7255,7 @@ static WERROR spoolss_addprinterex_level_2(pipes_struct *p,
 
        if (*lp_addprinter_cmd() ) {
                if ( !add_printer_hook(p->mem_ctx, p->server_info->ptok,
-                                      info2) ) {
+                                      info2, p->client_address) ) {
                        return WERR_ACCESS_DENIED;
                }
        } else {
@@ -7043,6 +7286,12 @@ static WERROR spoolss_addprinterex_level_2(pipes_struct *p,
                info2_mask = ~SPOOLSS_PRINTER_INFO_DEVMODE;
        }
 
+       update_dsspooler(p->mem_ctx,
+                        p->server_info,
+                        0,
+                        info2,
+                        NULL);
+
        err = winreg_update_printer(p->mem_ctx,
                                    p->server_info,
                                    info2->sharename,
@@ -7067,7 +7316,7 @@ static WERROR spoolss_addprinterex_level_2(pipes_struct *p,
  _spoolss_AddPrinterEx
 ****************************************************************/
 
-WERROR _spoolss_AddPrinterEx(pipes_struct *p,
+WERROR _spoolss_AddPrinterEx(struct pipes_struct *p,
                             struct spoolss_AddPrinterEx *r)
 {
        switch (r->in.info_ctr->level) {
@@ -7091,7 +7340,7 @@ WERROR _spoolss_AddPrinterEx(pipes_struct *p,
  _spoolss_AddPrinter
 ****************************************************************/
 
-WERROR _spoolss_AddPrinter(pipes_struct *p,
+WERROR _spoolss_AddPrinter(struct pipes_struct *p,
                           struct spoolss_AddPrinter *r)
 {
        struct spoolss_AddPrinterEx a;
@@ -7115,7 +7364,7 @@ WERROR _spoolss_AddPrinter(pipes_struct *p,
  _spoolss_AddPrinterDriverEx
 ****************************************************************/
 
-WERROR _spoolss_AddPrinterDriverEx(pipes_struct *p,
+WERROR _spoolss_AddPrinterDriverEx(struct pipes_struct *p,
                                   struct spoolss_AddPrinterDriverEx *r)
 {
        WERROR err = WERR_OK;
@@ -7194,7 +7443,7 @@ done:
  _spoolss_AddPrinterDriver
 ****************************************************************/
 
-WERROR _spoolss_AddPrinterDriver(pipes_struct *p,
+WERROR _spoolss_AddPrinterDriver(struct pipes_struct *p,
                                 struct spoolss_AddPrinterDriver *r)
 {
        struct spoolss_AddPrinterDriverEx a;
@@ -7320,7 +7569,7 @@ static WERROR getprinterdriverdir_level_1(TALLOC_CTX *mem_ctx,
  _spoolss_GetPrinterDriverDirectory
 ****************************************************************/
 
-WERROR _spoolss_GetPrinterDriverDirectory(pipes_struct *p,
+WERROR _spoolss_GetPrinterDriverDirectory(struct pipes_struct *p,
                                          struct spoolss_GetPrinterDriverDirectory *r)
 {
        WERROR werror;
@@ -7358,7 +7607,7 @@ WERROR _spoolss_GetPrinterDriverDirectory(pipes_struct *p,
  _spoolss_EnumPrinterData
 ****************************************************************/
 
-WERROR _spoolss_EnumPrinterData(pipes_struct *p,
+WERROR _spoolss_EnumPrinterData(struct pipes_struct *p,
                                struct spoolss_EnumPrinterData *r)
 {
        WERROR result;
@@ -7498,7 +7747,7 @@ WERROR _spoolss_EnumPrinterData(pipes_struct *p,
  _spoolss_SetPrinterData
 ****************************************************************/
 
-WERROR _spoolss_SetPrinterData(pipes_struct *p,
+WERROR _spoolss_SetPrinterData(struct pipes_struct *p,
                               struct spoolss_SetPrinterData *r)
 {
        struct spoolss_SetPrinterDataEx r2;
@@ -7517,7 +7766,7 @@ WERROR _spoolss_SetPrinterData(pipes_struct *p,
  _spoolss_ResetPrinter
 ****************************************************************/
 
-WERROR _spoolss_ResetPrinter(pipes_struct *p,
+WERROR _spoolss_ResetPrinter(struct pipes_struct *p,
                             struct spoolss_ResetPrinter *r)
 {
        Printer_entry   *Printer = find_printer_index_by_hnd(p, r->in.handle);
@@ -7549,7 +7798,7 @@ WERROR _spoolss_ResetPrinter(pipes_struct *p,
  _spoolss_DeletePrinterData
 ****************************************************************/
 
-WERROR _spoolss_DeletePrinterData(pipes_struct *p,
+WERROR _spoolss_DeletePrinterData(struct pipes_struct *p,
                                  struct spoolss_DeletePrinterData *r)
 {
        struct spoolss_DeletePrinterDataEx r2;
@@ -7565,7 +7814,7 @@ WERROR _spoolss_DeletePrinterData(pipes_struct *p,
  _spoolss_AddForm
 ****************************************************************/
 
-WERROR _spoolss_AddForm(pipes_struct *p,
+WERROR _spoolss_AddForm(struct pipes_struct *p,
                        struct spoolss_AddForm *r)
 {
        struct spoolss_AddFormInfo1 *form = r->in.info.info1;
@@ -7634,7 +7883,7 @@ WERROR _spoolss_AddForm(pipes_struct *p,
  _spoolss_DeleteForm
 ****************************************************************/
 
-WERROR _spoolss_DeleteForm(pipes_struct *p,
+WERROR _spoolss_DeleteForm(struct pipes_struct *p,
                           struct spoolss_DeleteForm *r)
 {
        const char *form_name = r->in.form_name;
@@ -7692,7 +7941,7 @@ WERROR _spoolss_DeleteForm(pipes_struct *p,
  _spoolss_SetForm
 ****************************************************************/
 
-WERROR _spoolss_SetForm(pipes_struct *p,
+WERROR _spoolss_SetForm(struct pipes_struct *p,
                        struct spoolss_SetForm *r)
 {
        struct spoolss_AddFormInfo1 *form = r->in.info.info1;
@@ -7803,7 +8052,7 @@ static WERROR enumprintprocessors_level_1(TALLOC_CTX *mem_ctx,
  _spoolss_EnumPrintProcessors
 ****************************************************************/
 
-WERROR _spoolss_EnumPrintProcessors(pipes_struct *p,
+WERROR _spoolss_EnumPrintProcessors(struct pipes_struct *p,
                                    struct spoolss_EnumPrintProcessors *r)
 {
        WERROR result;
@@ -7901,7 +8150,7 @@ static WERROR enumprintprocdatatypes_level_1(TALLOC_CTX *mem_ctx,
  _spoolss_EnumPrintProcDataTypes
 ****************************************************************/
 
-WERROR _spoolss_EnumPrintProcDataTypes(pipes_struct *p,
+WERROR _spoolss_EnumPrintProcDataTypes(struct pipes_struct *p,
                                       struct spoolss_EnumPrintProcDataTypes *r)
 {
        WERROR result;
@@ -8059,7 +8308,7 @@ out:
  _spoolss_EnumMonitors
 ****************************************************************/
 
-WERROR _spoolss_EnumMonitors(pipes_struct *p,
+WERROR _spoolss_EnumMonitors(struct pipes_struct *p,
                             struct spoolss_EnumMonitors *r)
 {
        WERROR result;
@@ -8201,7 +8450,7 @@ static WERROR getjob_level_2(TALLOC_CTX *mem_ctx,
  _spoolss_GetJob
 ****************************************************************/
 
-WERROR _spoolss_GetJob(pipes_struct *p,
+WERROR _spoolss_GetJob(struct pipes_struct *p,
                       struct spoolss_GetJob *r)
 {
        WERROR result = WERR_OK;
@@ -8225,7 +8474,7 @@ WERROR _spoolss_GetJob(pipes_struct *p,
                return WERR_BADFID;
        }
 
-       result = winreg_get_printer(talloc_tos(), p->server_info, NULL,
+       result = winreg_get_printer(p->mem_ctx, p->server_info, NULL,
                                    lp_servicename(snum), &pinfo2);
        if (!W_ERROR_IS_OK(result)) {
                return result;
@@ -8271,7 +8520,7 @@ WERROR _spoolss_GetJob(pipes_struct *p,
  _spoolss_GetPrinterDataEx
 ****************************************************************/
 
-WERROR _spoolss_GetPrinterDataEx(pipes_struct *p,
+WERROR _spoolss_GetPrinterDataEx(struct pipes_struct *p,
                                 struct spoolss_GetPrinterDataEx *r)
 {
 
@@ -8393,7 +8642,7 @@ WERROR _spoolss_GetPrinterDataEx(pipes_struct *p,
  _spoolss_SetPrinterDataEx
 ****************************************************************/
 
-WERROR _spoolss_SetPrinterDataEx(pipes_struct *p,
+WERROR _spoolss_SetPrinterDataEx(struct pipes_struct *p,
                                 struct spoolss_SetPrinterDataEx *r)
 {
        struct spoolss_PrinterInfo2 *pinfo2 = NULL;
@@ -8505,7 +8754,7 @@ done:
  _spoolss_DeletePrinterDataEx
 ****************************************************************/
 
-WERROR _spoolss_DeletePrinterDataEx(pipes_struct *p,
+WERROR _spoolss_DeletePrinterDataEx(struct pipes_struct *p,
                                    struct spoolss_DeletePrinterDataEx *r)
 {
        const char *printer;
@@ -8555,7 +8804,7 @@ WERROR _spoolss_DeletePrinterDataEx(pipes_struct *p,
  _spoolss_EnumPrinterKey
 ****************************************************************/
 
-WERROR _spoolss_EnumPrinterKey(pipes_struct *p,
+WERROR _spoolss_EnumPrinterKey(struct pipes_struct *p,
                               struct spoolss_EnumPrinterKey *r)
 {
        uint32_t        num_keys;
@@ -8617,7 +8866,7 @@ WERROR _spoolss_EnumPrinterKey(pipes_struct *p,
  _spoolss_DeletePrinterKey
 ****************************************************************/
 
-WERROR _spoolss_DeletePrinterKey(pipes_struct *p,
+WERROR _spoolss_DeletePrinterKey(struct pipes_struct *p,
                                 struct spoolss_DeletePrinterKey *r)
 {
        Printer_entry           *Printer = find_printer_index_by_hnd(p, r->in.handle);
@@ -8667,7 +8916,7 @@ WERROR _spoolss_DeletePrinterKey(pipes_struct *p,
  _spoolss_EnumPrinterDataEx
 ****************************************************************/
 
-WERROR _spoolss_EnumPrinterDataEx(pipes_struct *p,
+WERROR _spoolss_EnumPrinterDataEx(struct pipes_struct *p,
                                  struct spoolss_EnumPrinterDataEx *r)
 {
        uint32_t        count = 0;
@@ -8776,7 +9025,7 @@ static WERROR getprintprocessordirectory_level_1(TALLOC_CTX *mem_ctx,
  _spoolss_GetPrintProcessorDirectory
 ****************************************************************/
 
-WERROR _spoolss_GetPrintProcessorDirectory(pipes_struct *p,
+WERROR _spoolss_GetPrintProcessorDirectory(struct pipes_struct *p,
                                           struct spoolss_GetPrintProcessorDirectory *r)
 {
        WERROR result;
@@ -9063,7 +9312,7 @@ static WERROR process_xcvlocal_command(TALLOC_CTX *mem_ctx,
  _spoolss_XcvData
 ****************************************************************/
 
-WERROR _spoolss_XcvData(pipes_struct *p,
+WERROR _spoolss_XcvData(struct pipes_struct *p,
                        struct spoolss_XcvData *r)
 {
        Printer_entry *Printer = find_printer_index_by_hnd(p, r->in.handle);
@@ -9136,7 +9385,7 @@ WERROR _spoolss_XcvData(pipes_struct *p,
  _spoolss_AddPrintProcessor
 ****************************************************************/
 
-WERROR _spoolss_AddPrintProcessor(pipes_struct *p,
+WERROR _spoolss_AddPrintProcessor(struct pipes_struct *p,
                                  struct spoolss_AddPrintProcessor *r)
 {
        /* for now, just indicate success and ignore the add.  We'll
@@ -9151,7 +9400,7 @@ WERROR _spoolss_AddPrintProcessor(pipes_struct *p,
  _spoolss_AddPort
 ****************************************************************/
 
-WERROR _spoolss_AddPort(pipes_struct *p,
+WERROR _spoolss_AddPort(struct pipes_struct *p,
                        struct spoolss_AddPort *r)
 {
        /* do what w2k3 does */
@@ -9163,7 +9412,7 @@ WERROR _spoolss_AddPort(pipes_struct *p,
  _spoolss_GetPrinterDriver
 ****************************************************************/
 
-WERROR _spoolss_GetPrinterDriver(pipes_struct *p,
+WERROR _spoolss_GetPrinterDriver(struct pipes_struct *p,
                                 struct spoolss_GetPrinterDriver *r)
 {
        p->rng_fault_state = true;
@@ -9174,7 +9423,7 @@ WERROR _spoolss_GetPrinterDriver(pipes_struct *p,
  _spoolss_ReadPrinter
 ****************************************************************/
 
-WERROR _spoolss_ReadPrinter(pipes_struct *p,
+WERROR _spoolss_ReadPrinter(struct pipes_struct *p,
                            struct spoolss_ReadPrinter *r)
 {
        p->rng_fault_state = true;
@@ -9185,7 +9434,7 @@ WERROR _spoolss_ReadPrinter(pipes_struct *p,
  _spoolss_WaitForPrinterChange
 ****************************************************************/
 
-WERROR _spoolss_WaitForPrinterChange(pipes_struct *p,
+WERROR _spoolss_WaitForPrinterChange(struct pipes_struct *p,
                                     struct spoolss_WaitForPrinterChange *r)
 {
        p->rng_fault_state = true;
@@ -9196,7 +9445,7 @@ WERROR _spoolss_WaitForPrinterChange(pipes_struct *p,
  _spoolss_ConfigurePort
 ****************************************************************/
 
-WERROR _spoolss_ConfigurePort(pipes_struct *p,
+WERROR _spoolss_ConfigurePort(struct pipes_struct *p,
                              struct spoolss_ConfigurePort *r)
 {
        p->rng_fault_state = true;
@@ -9207,7 +9456,7 @@ WERROR _spoolss_ConfigurePort(pipes_struct *p,
  _spoolss_DeletePort
 ****************************************************************/
 
-WERROR _spoolss_DeletePort(pipes_struct *p,
+WERROR _spoolss_DeletePort(struct pipes_struct *p,
                           struct spoolss_DeletePort *r)
 {
        p->rng_fault_state = true;
@@ -9218,7 +9467,7 @@ WERROR _spoolss_DeletePort(pipes_struct *p,
  _spoolss_CreatePrinterIC
 ****************************************************************/
 
-WERROR _spoolss_CreatePrinterIC(pipes_struct *p,
+WERROR _spoolss_CreatePrinterIC(struct pipes_struct *p,
                                struct spoolss_CreatePrinterIC *r)
 {
        p->rng_fault_state = true;
@@ -9229,7 +9478,7 @@ WERROR _spoolss_CreatePrinterIC(pipes_struct *p,
  _spoolss_PlayGDIScriptOnPrinterIC
 ****************************************************************/
 
-WERROR _spoolss_PlayGDIScriptOnPrinterIC(pipes_struct *p,
+WERROR _spoolss_PlayGDIScriptOnPrinterIC(struct pipes_struct *p,
                                         struct spoolss_PlayGDIScriptOnPrinterIC *r)
 {
        p->rng_fault_state = true;
@@ -9240,7 +9489,7 @@ WERROR _spoolss_PlayGDIScriptOnPrinterIC(pipes_struct *p,
  _spoolss_DeletePrinterIC
 ****************************************************************/
 
-WERROR _spoolss_DeletePrinterIC(pipes_struct *p,
+WERROR _spoolss_DeletePrinterIC(struct pipes_struct *p,
                                struct spoolss_DeletePrinterIC *r)
 {
        p->rng_fault_state = true;
@@ -9251,7 +9500,7 @@ WERROR _spoolss_DeletePrinterIC(pipes_struct *p,
  _spoolss_AddPrinterConnection
 ****************************************************************/
 
-WERROR _spoolss_AddPrinterConnection(pipes_struct *p,
+WERROR _spoolss_AddPrinterConnection(struct pipes_struct *p,
                                     struct spoolss_AddPrinterConnection *r)
 {
        p->rng_fault_state = true;
@@ -9262,7 +9511,7 @@ WERROR _spoolss_AddPrinterConnection(pipes_struct *p,
  _spoolss_DeletePrinterConnection
 ****************************************************************/
 
-WERROR _spoolss_DeletePrinterConnection(pipes_struct *p,
+WERROR _spoolss_DeletePrinterConnection(struct pipes_struct *p,
                                        struct spoolss_DeletePrinterConnection *r)
 {
        p->rng_fault_state = true;
@@ -9273,7 +9522,7 @@ WERROR _spoolss_DeletePrinterConnection(pipes_struct *p,
  _spoolss_PrinterMessageBox
 ****************************************************************/
 
-WERROR _spoolss_PrinterMessageBox(pipes_struct *p,
+WERROR _spoolss_PrinterMessageBox(struct pipes_struct *p,
                                  struct spoolss_PrinterMessageBox *r)
 {
        p->rng_fault_state = true;
@@ -9284,7 +9533,7 @@ WERROR _spoolss_PrinterMessageBox(pipes_struct *p,
  _spoolss_AddMonitor
 ****************************************************************/
 
-WERROR _spoolss_AddMonitor(pipes_struct *p,
+WERROR _spoolss_AddMonitor(struct pipes_struct *p,
                           struct spoolss_AddMonitor *r)
 {
        p->rng_fault_state = true;
@@ -9295,7 +9544,7 @@ WERROR _spoolss_AddMonitor(pipes_struct *p,
  _spoolss_DeleteMonitor
 ****************************************************************/
 
-WERROR _spoolss_DeleteMonitor(pipes_struct *p,
+WERROR _spoolss_DeleteMonitor(struct pipes_struct *p,
                              struct spoolss_DeleteMonitor *r)
 {
        p->rng_fault_state = true;
@@ -9306,7 +9555,7 @@ WERROR _spoolss_DeleteMonitor(pipes_struct *p,
  _spoolss_DeletePrintProcessor
 ****************************************************************/
 
-WERROR _spoolss_DeletePrintProcessor(pipes_struct *p,
+WERROR _spoolss_DeletePrintProcessor(struct pipes_struct *p,
                                     struct spoolss_DeletePrintProcessor *r)
 {
        p->rng_fault_state = true;
@@ -9317,7 +9566,7 @@ WERROR _spoolss_DeletePrintProcessor(pipes_struct *p,
  _spoolss_AddPrintProvidor
 ****************************************************************/
 
-WERROR _spoolss_AddPrintProvidor(pipes_struct *p,
+WERROR _spoolss_AddPrintProvidor(struct pipes_struct *p,
                                 struct spoolss_AddPrintProvidor *r)
 {
        p->rng_fault_state = true;
@@ -9328,7 +9577,7 @@ WERROR _spoolss_AddPrintProvidor(pipes_struct *p,
  _spoolss_DeletePrintProvidor
 ****************************************************************/
 
-WERROR _spoolss_DeletePrintProvidor(pipes_struct *p,
+WERROR _spoolss_DeletePrintProvidor(struct pipes_struct *p,
                                    struct spoolss_DeletePrintProvidor *r)
 {
        p->rng_fault_state = true;
@@ -9339,7 +9588,7 @@ WERROR _spoolss_DeletePrintProvidor(pipes_struct *p,
  _spoolss_FindFirstPrinterChangeNotification
 ****************************************************************/
 
-WERROR _spoolss_FindFirstPrinterChangeNotification(pipes_struct *p,
+WERROR _spoolss_FindFirstPrinterChangeNotification(struct pipes_struct *p,
                                                   struct spoolss_FindFirstPrinterChangeNotification *r)
 {
        p->rng_fault_state = true;
@@ -9350,7 +9599,7 @@ WERROR _spoolss_FindFirstPrinterChangeNotification(pipes_struct *p,
  _spoolss_FindNextPrinterChangeNotification
 ****************************************************************/
 
-WERROR _spoolss_FindNextPrinterChangeNotification(pipes_struct *p,
+WERROR _spoolss_FindNextPrinterChangeNotification(struct pipes_struct *p,
                                                  struct spoolss_FindNextPrinterChangeNotification *r)
 {
        p->rng_fault_state = true;
@@ -9361,7 +9610,7 @@ WERROR _spoolss_FindNextPrinterChangeNotification(pipes_struct *p,
  _spoolss_RouterFindFirstPrinterChangeNotificationOld
 ****************************************************************/
 
-WERROR _spoolss_RouterFindFirstPrinterChangeNotificationOld(pipes_struct *p,
+WERROR _spoolss_RouterFindFirstPrinterChangeNotificationOld(struct pipes_struct *p,
                                                            struct spoolss_RouterFindFirstPrinterChangeNotificationOld *r)
 {
        p->rng_fault_state = true;
@@ -9372,7 +9621,7 @@ WERROR _spoolss_RouterFindFirstPrinterChangeNotificationOld(pipes_struct *p,
  _spoolss_ReplyOpenPrinter
 ****************************************************************/
 
-WERROR _spoolss_ReplyOpenPrinter(pipes_struct *p,
+WERROR _spoolss_ReplyOpenPrinter(struct pipes_struct *p,
                                 struct spoolss_ReplyOpenPrinter *r)
 {
        p->rng_fault_state = true;
@@ -9383,7 +9632,7 @@ WERROR _spoolss_ReplyOpenPrinter(pipes_struct *p,
  _spoolss_RouterReplyPrinter
 ****************************************************************/
 
-WERROR _spoolss_RouterReplyPrinter(pipes_struct *p,
+WERROR _spoolss_RouterReplyPrinter(struct pipes_struct *p,
                                   struct spoolss_RouterReplyPrinter *r)
 {
        p->rng_fault_state = true;
@@ -9394,7 +9643,7 @@ WERROR _spoolss_RouterReplyPrinter(pipes_struct *p,
  _spoolss_ReplyClosePrinter
 ****************************************************************/
 
-WERROR _spoolss_ReplyClosePrinter(pipes_struct *p,
+WERROR _spoolss_ReplyClosePrinter(struct pipes_struct *p,
                                  struct spoolss_ReplyClosePrinter *r)
 {
        p->rng_fault_state = true;
@@ -9405,7 +9654,7 @@ WERROR _spoolss_ReplyClosePrinter(pipes_struct *p,
  _spoolss_AddPortEx
 ****************************************************************/
 
-WERROR _spoolss_AddPortEx(pipes_struct *p,
+WERROR _spoolss_AddPortEx(struct pipes_struct *p,
                          struct spoolss_AddPortEx *r)
 {
        p->rng_fault_state = true;
@@ -9416,7 +9665,7 @@ WERROR _spoolss_AddPortEx(pipes_struct *p,
  _spoolss_RouterFindFirstPrinterChangeNotification
 ****************************************************************/
 
-WERROR _spoolss_RouterFindFirstPrinterChangeNotification(pipes_struct *p,
+WERROR _spoolss_RouterFindFirstPrinterChangeNotification(struct pipes_struct *p,
                                                         struct spoolss_RouterFindFirstPrinterChangeNotification *r)
 {
        p->rng_fault_state = true;
@@ -9427,7 +9676,7 @@ WERROR _spoolss_RouterFindFirstPrinterChangeNotification(pipes_struct *p,
  _spoolss_SpoolerInit
 ****************************************************************/
 
-WERROR _spoolss_SpoolerInit(pipes_struct *p,
+WERROR _spoolss_SpoolerInit(struct pipes_struct *p,
                            struct spoolss_SpoolerInit *r)
 {
        p->rng_fault_state = true;
@@ -9438,7 +9687,7 @@ WERROR _spoolss_SpoolerInit(pipes_struct *p,
  _spoolss_ResetPrinterEx
 ****************************************************************/
 
-WERROR _spoolss_ResetPrinterEx(pipes_struct *p,
+WERROR _spoolss_ResetPrinterEx(struct pipes_struct *p,
                               struct spoolss_ResetPrinterEx *r)
 {
        p->rng_fault_state = true;
@@ -9449,7 +9698,7 @@ WERROR _spoolss_ResetPrinterEx(pipes_struct *p,
  _spoolss_RouterReplyPrinterEx
 ****************************************************************/
 
-WERROR _spoolss_RouterReplyPrinterEx(pipes_struct *p,
+WERROR _spoolss_RouterReplyPrinterEx(struct pipes_struct *p,
                                     struct spoolss_RouterReplyPrinterEx *r)
 {
        p->rng_fault_state = true;
@@ -9460,7 +9709,7 @@ WERROR _spoolss_RouterReplyPrinterEx(pipes_struct *p,
  _spoolss_44
 ****************************************************************/
 
-WERROR _spoolss_44(pipes_struct *p,
+WERROR _spoolss_44(struct pipes_struct *p,
                   struct spoolss_44 *r)
 {
        p->rng_fault_state = true;
@@ -9471,7 +9720,7 @@ WERROR _spoolss_44(pipes_struct *p,
  _spoolss_47
 ****************************************************************/
 
-WERROR _spoolss_47(pipes_struct *p,
+WERROR _spoolss_47(struct pipes_struct *p,
                   struct spoolss_47 *r)
 {
        p->rng_fault_state = true;
@@ -9482,7 +9731,7 @@ WERROR _spoolss_47(pipes_struct *p,
  _spoolss_4a
 ****************************************************************/
 
-WERROR _spoolss_4a(pipes_struct *p,
+WERROR _spoolss_4a(struct pipes_struct *p,
                   struct spoolss_4a *r)
 {
        p->rng_fault_state = true;
@@ -9493,7 +9742,7 @@ WERROR _spoolss_4a(pipes_struct *p,
  _spoolss_4b
 ****************************************************************/
 
-WERROR _spoolss_4b(pipes_struct *p,
+WERROR _spoolss_4b(struct pipes_struct *p,
                   struct spoolss_4b *r)
 {
        p->rng_fault_state = true;
@@ -9504,7 +9753,7 @@ WERROR _spoolss_4b(pipes_struct *p,
  _spoolss_4c
 ****************************************************************/
 
-WERROR _spoolss_4c(pipes_struct *p,
+WERROR _spoolss_4c(struct pipes_struct *p,
                   struct spoolss_4c *r)
 {
        p->rng_fault_state = true;
@@ -9515,7 +9764,7 @@ WERROR _spoolss_4c(pipes_struct *p,
  _spoolss_53
 ****************************************************************/
 
-WERROR _spoolss_53(pipes_struct *p,
+WERROR _spoolss_53(struct pipes_struct *p,
                   struct spoolss_53 *r)
 {
        p->rng_fault_state = true;
@@ -9526,7 +9775,7 @@ WERROR _spoolss_53(pipes_struct *p,
  _spoolss_55
 ****************************************************************/
 
-WERROR _spoolss_55(pipes_struct *p,
+WERROR _spoolss_55(struct pipes_struct *p,
                   struct spoolss_55 *r)
 {
        p->rng_fault_state = true;
@@ -9537,7 +9786,7 @@ WERROR _spoolss_55(pipes_struct *p,
  _spoolss_56
 ****************************************************************/
 
-WERROR _spoolss_56(pipes_struct *p,
+WERROR _spoolss_56(struct pipes_struct *p,
                   struct spoolss_56 *r)
 {
        p->rng_fault_state = true;
@@ -9548,7 +9797,7 @@ WERROR _spoolss_56(pipes_struct *p,
  _spoolss_57
 ****************************************************************/
 
-WERROR _spoolss_57(pipes_struct *p,
+WERROR _spoolss_57(struct pipes_struct *p,
                   struct spoolss_57 *r)
 {
        p->rng_fault_state = true;
@@ -9559,7 +9808,7 @@ WERROR _spoolss_57(pipes_struct *p,
  _spoolss_5a
 ****************************************************************/
 
-WERROR _spoolss_5a(pipes_struct *p,
+WERROR _spoolss_5a(struct pipes_struct *p,
                   struct spoolss_5a *r)
 {
        p->rng_fault_state = true;
@@ -9570,7 +9819,7 @@ WERROR _spoolss_5a(pipes_struct *p,
  _spoolss_5b
 ****************************************************************/
 
-WERROR _spoolss_5b(pipes_struct *p,
+WERROR _spoolss_5b(struct pipes_struct *p,
                   struct spoolss_5b *r)
 {
        p->rng_fault_state = true;
@@ -9581,7 +9830,7 @@ WERROR _spoolss_5b(pipes_struct *p,
  _spoolss_5c
 ****************************************************************/
 
-WERROR _spoolss_5c(pipes_struct *p,
+WERROR _spoolss_5c(struct pipes_struct *p,
                   struct spoolss_5c *r)
 {
        p->rng_fault_state = true;
@@ -9592,7 +9841,7 @@ WERROR _spoolss_5c(pipes_struct *p,
  _spoolss_5d
 ****************************************************************/
 
-WERROR _spoolss_5d(pipes_struct *p,
+WERROR _spoolss_5d(struct pipes_struct *p,
                   struct spoolss_5d *r)
 {
        p->rng_fault_state = true;
@@ -9603,7 +9852,7 @@ WERROR _spoolss_5d(pipes_struct *p,
  _spoolss_5e
 ****************************************************************/
 
-WERROR _spoolss_5e(pipes_struct *p,
+WERROR _spoolss_5e(struct pipes_struct *p,
                   struct spoolss_5e *r)
 {
        p->rng_fault_state = true;
@@ -9614,7 +9863,7 @@ WERROR _spoolss_5e(pipes_struct *p,
  _spoolss_5f
 ****************************************************************/
 
-WERROR _spoolss_5f(pipes_struct *p,
+WERROR _spoolss_5f(struct pipes_struct *p,
                   struct spoolss_5f *r)
 {
        p->rng_fault_state = true;
@@ -9625,7 +9874,7 @@ WERROR _spoolss_5f(pipes_struct *p,
  _spoolss_60
 ****************************************************************/
 
-WERROR _spoolss_60(pipes_struct *p,
+WERROR _spoolss_60(struct pipes_struct *p,
                   struct spoolss_60 *r)
 {
        p->rng_fault_state = true;
@@ -9636,7 +9885,7 @@ WERROR _spoolss_60(pipes_struct *p,
  _spoolss_61
 ****************************************************************/
 
-WERROR _spoolss_61(pipes_struct *p,
+WERROR _spoolss_61(struct pipes_struct *p,
                   struct spoolss_61 *r)
 {
        p->rng_fault_state = true;
@@ -9647,7 +9896,7 @@ WERROR _spoolss_61(pipes_struct *p,
  _spoolss_62
 ****************************************************************/
 
-WERROR _spoolss_62(pipes_struct *p,
+WERROR _spoolss_62(struct pipes_struct *p,
                   struct spoolss_62 *r)
 {
        p->rng_fault_state = true;
@@ -9658,7 +9907,7 @@ WERROR _spoolss_62(pipes_struct *p,
  _spoolss_63
 ****************************************************************/
 
-WERROR _spoolss_63(pipes_struct *p,
+WERROR _spoolss_63(struct pipes_struct *p,
                   struct spoolss_63 *r)
 {
        p->rng_fault_state = true;
@@ -9669,7 +9918,7 @@ WERROR _spoolss_63(pipes_struct *p,
  _spoolss_64
 ****************************************************************/
 
-WERROR _spoolss_64(pipes_struct *p,
+WERROR _spoolss_64(struct pipes_struct *p,
                   struct spoolss_64 *r)
 {
        p->rng_fault_state = true;
@@ -9680,7 +9929,7 @@ WERROR _spoolss_64(pipes_struct *p,
  _spoolss_65
 ****************************************************************/
 
-WERROR _spoolss_65(pipes_struct *p,
+WERROR _spoolss_65(struct pipes_struct *p,
                   struct spoolss_65 *r)
 {
        p->rng_fault_state = true;
@@ -9691,7 +9940,7 @@ WERROR _spoolss_65(pipes_struct *p,
  _spoolss_GetCorePrinterDrivers
 ****************************************************************/
 
-WERROR _spoolss_GetCorePrinterDrivers(pipes_struct *p,
+WERROR _spoolss_GetCorePrinterDrivers(struct pipes_struct *p,
                                      struct spoolss_GetCorePrinterDrivers *r)
 {
        p->rng_fault_state = true;
@@ -9702,7 +9951,7 @@ WERROR _spoolss_GetCorePrinterDrivers(pipes_struct *p,
  _spoolss_67
 ****************************************************************/
 
-WERROR _spoolss_67(pipes_struct *p,
+WERROR _spoolss_67(struct pipes_struct *p,
                   struct spoolss_67 *r)
 {
        p->rng_fault_state = true;
@@ -9713,7 +9962,7 @@ WERROR _spoolss_67(pipes_struct *p,
  _spoolss_GetPrinterDriverPackagePath
 ****************************************************************/
 
-WERROR _spoolss_GetPrinterDriverPackagePath(pipes_struct *p,
+WERROR _spoolss_GetPrinterDriverPackagePath(struct pipes_struct *p,
                                            struct spoolss_GetPrinterDriverPackagePath *r)
 {
        p->rng_fault_state = true;
@@ -9724,7 +9973,7 @@ WERROR _spoolss_GetPrinterDriverPackagePath(pipes_struct *p,
  _spoolss_69
 ****************************************************************/
 
-WERROR _spoolss_69(pipes_struct *p,
+WERROR _spoolss_69(struct pipes_struct *p,
                   struct spoolss_69 *r)
 {
        p->rng_fault_state = true;
@@ -9735,7 +9984,7 @@ WERROR _spoolss_69(pipes_struct *p,
  _spoolss_6a
 ****************************************************************/
 
-WERROR _spoolss_6a(pipes_struct *p,
+WERROR _spoolss_6a(struct pipes_struct *p,
                   struct spoolss_6a *r)
 {
        p->rng_fault_state = true;
@@ -9746,7 +9995,7 @@ WERROR _spoolss_6a(pipes_struct *p,
  _spoolss_6b
 ****************************************************************/
 
-WERROR _spoolss_6b(pipes_struct *p,
+WERROR _spoolss_6b(struct pipes_struct *p,
                   struct spoolss_6b *r)
 {
        p->rng_fault_state = true;
@@ -9757,7 +10006,7 @@ WERROR _spoolss_6b(pipes_struct *p,
  _spoolss_6c
 ****************************************************************/
 
-WERROR _spoolss_6c(pipes_struct *p,
+WERROR _spoolss_6c(struct pipes_struct *p,
                   struct spoolss_6c *r)
 {
        p->rng_fault_state = true;
@@ -9768,7 +10017,7 @@ WERROR _spoolss_6c(pipes_struct *p,
  _spoolss_6d
 ****************************************************************/
 
-WERROR _spoolss_6d(pipes_struct *p,
+WERROR _spoolss_6d(struct pipes_struct *p,
                   struct spoolss_6d *r)
 {
        p->rng_fault_state = true;