printing: reload printer shares on OpenPrinter
authorDavid Disseldorp <ddiss@samba.org>
Tue, 5 Aug 2014 15:33:33 +0000 (17:33 +0200)
committerKarolin Seeger <kseeger@samba.org>
Tue, 2 Sep 2014 18:39:20 +0000 (20:39 +0200)
The printer share inventory should be reloaded on open _and_
enumeration, as there are some clients, such as cupsaddsmb, that do not
perform an enumeration prior to access.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=10652

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Aug  8 16:33:50 CEST 2014 on sn-devel-104

(cherry picked from commit 1ad71f79eb473822d36d9629cf52c2fca4c53752)

source3/rpc_server/spoolss/srv_spoolss_nt.c

index edb276bfb1fffccc38875b86732f358d846f64df..44497a69a855c65469d9bdccc9c9b0fb5acb0596 100644 (file)
@@ -1724,6 +1724,16 @@ WERROR _spoolss_OpenPrinterEx(struct pipes_struct *p,
                return WERR_INVALID_PARAM;
        }
 
+       /*
+        * The printcap printer share inventory is updated on client
+        * enumeration. For clients that do not perform enumeration prior to
+        * access, such as cupssmbadd, we reinitialise the printer share
+        * inventory on open as well.
+        */
+       become_root();
+       delete_and_reload_printers(server_event_context(), p->msg_ctx);
+       unbecome_root();
+
        /* some sanity check because you can open a printer or a print server */
        /* aka: \\server\printer or \\server */
 
@@ -4301,7 +4311,7 @@ static WERROR enum_all_printers_info_level(TALLOC_CTX *mem_ctx,
        }
 
        /*
-        * printer shares are only updated on client enumeration. The background
+        * printer shares are updated on client enumeration. The background
         * printer process updates printer_list.tdb at regular intervals.
         */
        become_root();