+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);
+