The branch, master has been updated
       via  0750542 s3-spoolss: Remove printer from registry if it is 
unpublished
       via  119c15f s3-printing: Improve debug message
      from  5c53d50 ctdb-tests: Add tests for updated Debian style Samba 
start/stop

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 07505429cc4bb7e56f4dcdcaeb4eabdcd8e550e5
Author: Andreas Schneider <[email protected]>
Date:   Tue Nov 8 12:20:41 2016 +0100

    s3-spoolss: Remove printer from registry if it is unpublished
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11665
    
    Signed-off-by: Andreas Schneider <[email protected]>
    Reviewed-by: Guenther Deschner <[email protected]>
    
    Autobuild-User(master): Andreas Schneider <[email protected]>
    Autobuild-Date(master): Tue Nov  8 18:05:10 CET 2016 on sn-devel-144

commit 119c15fc4a994e594cc9b0e63557404fd59f3aac
Author: Andreas Schneider <[email protected]>
Date:   Tue Nov 8 12:20:25 2016 +0100

    s3-printing: Improve debug message
    
    Signed-off-by: Andreas Schneider <[email protected]>
    Reviewed-by: Guenther Deschner <[email protected]>

-----------------------------------------------------------------------

Summary of changes:
 source3/printing/nt_printing_ads.c          |  4 +++-
 source3/rpc_server/spoolss/srv_spoolss_nt.c | 34 ++++++++++++++++++++++++-----
 2 files changed, 32 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/printing/nt_printing_ads.c 
b/source3/printing/nt_printing_ads.c
index cf4c310..2588e1d 100644
--- a/source3/printing/nt_printing_ads.c
+++ b/source3/printing/nt_printing_ads.c
@@ -569,7 +569,9 @@ WERROR nt_printer_publish(TALLOC_CTX *mem_ctx,
                                        pinfo2->sharename, info2_mask,
                                        sinfo2, NULL, NULL);
        if (!W_ERROR_IS_OK(win_rc)) {
-               DEBUG(3, ("err %d saving data\n", W_ERROR_V(win_rc)));
+               DBG_NOTICE("Failed to update data for printer [%s] - %s\n",
+                          pinfo2->sharename,
+                          win_errstr(win_rc));
                goto done;
        }
 
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c 
b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index 9f1d44f..deb87a3 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -4215,6 +4215,7 @@ static WERROR construct_printer_info7(TALLOC_CTX *mem_ctx,
                                      int snum)
 {
        const struct auth_session_info *session_info;
+       struct spoolss_PrinterInfo2 *pinfo2 = NULL;
        char *printer;
        WERROR werr;
        TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
@@ -4233,7 +4234,7 @@ static WERROR construct_printer_info7(TALLOC_CTX *mem_ctx,
        }
 
        if (is_printer_published(tmp_ctx, session_info, msg_ctx,
-                                servername, printer, NULL)) {
+                                servername, printer, &pinfo2)) {
                struct GUID guid;
                struct GUID_txt_buf guid_txt;
                werr = nt_printer_guid_get(tmp_ctx, session_info, msg_ctx,
@@ -4246,10 +4247,33 @@ static WERROR construct_printer_info7(TALLOC_CTX 
*mem_ctx,
                        werr = nt_printer_guid_retrieve(tmp_ctx, printer,
                                                        &guid);
                        if (!W_ERROR_IS_OK(werr)) {
-                               DEBUG(1, ("Failed to retrieve GUID for "
-                                         "printer [%s] from AD - "
-                                         "Is the the printer still "
-                                         "published ?\n", printer));
+                               DBG_NOTICE("Failed to retrieve GUID for "
+                                          "printer [%s] from AD - %s\n",
+                                          printer,
+                                          win_errstr(werr));
+                               if (W_ERROR_EQUAL(werr, WERR_FILE_NOT_FOUND)) {
+                                       /*
+                                        * If we did not find it in AD, then it
+                                        * is unpublished and we should reflect
+                                        * this in the registry and return
+                                        * success.
+                                        */
+                                       DBG_WARNING("Unpublish printer [%s]\n",
+                                                   pinfo2->sharename);
+                                       nt_printer_publish(tmp_ctx,
+                                                          session_info,
+                                                          msg_ctx,
+                                                          pinfo2,
+                                                          DSPRINT_UNPUBLISH);
+                                       r->guid = talloc_strdup(mem_ctx, "");
+                                       r->action = DSPRINT_UNPUBLISH;
+
+                                       if (r->guid == NULL) {
+                                               werr = WERR_NOT_ENOUGH_MEMORY;
+                                       } else {
+                                               werr = WERR_OK;
+                                       }
+                               }
                                goto out_tmp_free;
                        }
 


-- 
Samba Shared Repository

Reply via email to