s3-spoolss: Use winreg_delete_printer_key to delete printers.
authorSimo Sorce <idra@samba.org>
Mon, 26 Apr 2010 22:50:44 +0000 (18:50 -0400)
committerSimo Sorce <idra@samba.org>
Tue, 27 Jul 2010 14:27:10 +0000 (10:27 -0400)
Signed-off-by: Jim McDonough <jmcd@samba.org>
source3/include/proto.h
source3/printing/nt_printing.c
source3/rpc_server/srv_spoolss_nt.c
source3/smbd/server_reload.c

index 95d94119275b5712a1f044c1e9ecef65a5bcf28d..d56ed3b349bf88a900f52c85d2239249f96403da 100644 (file)
@@ -4795,6 +4795,9 @@ bool print_access_check(struct auth_serversupplied_info *server_info, int snum,
                        int access_type);
 bool print_time_access_check(struct auth_serversupplied_info *server_info,
                             const char *servicename);
+void nt_printer_remove(TALLOC_CTX *mem_ctx,
+                       struct auth_serversupplied_info *server_info,
+                       const char *printer);
 
 /* The following definitions come from printing/pcap.c  */
 
index a3b5c7f1dc9c082f87d479006452e401e18af844..74a2dc433e2eced2e01479615e664b2c97fa1ecb 100644 (file)
@@ -2113,38 +2113,6 @@ static int pack_values(NT_PRINTER_DATA *data, uint8 *buf, int buflen)
 }
 
 
-/****************************************************************************
- Delete a printer - this just deletes the printer info file, any open
- handles are not affected.
-****************************************************************************/
-
-uint32 del_a_printer(const char *sharename)
-{
-       TDB_DATA kbuf;
-       char *printdb_path = NULL;
-       TALLOC_CTX *ctx = talloc_tos();
-
-       kbuf = make_printer_tdbkey(ctx, sharename);
-       tdb_delete(tdb_printers, kbuf);
-
-       kbuf= make_printers_secdesc_tdbkey(ctx, sharename);
-       tdb_delete(tdb_printers, kbuf);
-
-       close_all_print_db();
-
-       if (geteuid() == sec_initial_uid()) {
-               if (asprintf(&printdb_path, "%s%s.tdb",
-                               cache_path("printing/"),
-                               sharename) < 0) {
-                       return (uint32)-1;
-               }
-               unlink(printdb_path);
-               SAFE_FREE(printdb_path);
-       }
-
-       return 0;
-}
-
 /****************************************************************************
 ****************************************************************************/
 static WERROR update_a_printer_2(NT_PRINTER_INFO_LEVEL_2 *info)
@@ -5238,4 +5206,15 @@ bool print_time_access_check(struct auth_serversupplied_info *server_info,
        return ok;
 }
 
+void nt_printer_remove(TALLOC_CTX *mem_ctx,
+                       struct auth_serversupplied_info *server_info,
+                       const char *printer)
+{
+       WERROR result;
 
+       result = winreg_delete_printer_key(mem_ctx, server_info, printer, "");
+       if (!W_ERROR_IS_OK(result)) {
+               DEBUG(0, ("nt_printer_remove: failed to remove rpinter %s",
+                         printer));
+       }
+}
index 07e541d37f1087af257a36b6ce5c44cdc5886600..2967fe11e20432cf17320168a67025835347e73a 100644 (file)
@@ -336,6 +336,7 @@ static WERROR delete_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const c
 static WERROR delete_printer_handle(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 +359,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;
        }
index aed10377189b955bfcc1234ef5ef4d32fff7576c..e958d284f81672c587924abad31124803df4adae 100644 (file)
@@ -69,7 +69,7 @@ void reload_printers(void)
                                                   DSPRINT_UNPUBLISH);
                                TALLOC_FREE(pinfo2);
                        }
-                       del_a_printer(pname);
+                       nt_printer_remove(server_info, server_info, pname);
                        lp_killservice(snum);
                }
        }