]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/patches/samba/samba-3.6.99-nt_printer_unpublish_fix.patch
Merge branch 'core110'
[people/pmueller/ipfire-2.x.git] / src / patches / samba / samba-3.6.99-nt_printer_unpublish_fix.patch
1 From cd3082b03487eaeddb0105807b5ad39b47aa65f1 Mon Sep 17 00:00:00 2001
2 From: Andreas Schneider <asn@samba.org>
3 Date: Tue, 8 Nov 2016 12:20:41 +0100
4 Subject: [PATCH] s3-spoolss: Remove printer from registry if it is unpublished
5
6 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11665
7
8 Signed-off-by: Andreas Schneider <asn@samba.org>
9 Reviewed-by: Guenther Deschner <gd@samba.org>
10 ---
11 source3/rpc_server/spoolss/srv_spoolss_nt.c | 34 ++++++++++++++++++++++++-----
12 1 file changed, 29 insertions(+), 5 deletions(-)
13
14 diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
15 index 556cd4f..f1ab3fb 100644
16 --- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
17 +++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
18 @@ -4194,6 +4194,7 @@ static WERROR construct_printer_info7(TALLOC_CTX *mem_ctx,
19 int snum)
20 {
21 struct auth_serversupplied_info *session_info;
22 + struct spoolss_PrinterInfo2 *pinfo2 = NULL;
23 char *printer;
24 NTSTATUS status;
25 WERROR werr;
26 @@ -4218,7 +4219,7 @@ static WERROR construct_printer_info7(TALLOC_CTX *mem_ctx,
27 }
28
29 if (is_printer_published(tmp_ctx, session_info, msg_ctx,
30 - servername, printer, NULL)) {
31 + servername, printer, &pinfo2)) {
32 struct GUID guid;
33 werr = nt_printer_guid_get(tmp_ctx, session_info, msg_ctx,
34 printer, &guid);
35 @@ -4230,10 +4231,33 @@ static WERROR construct_printer_info7(TALLOC_CTX *mem_ctx,
36 werr = nt_printer_guid_retrieve(tmp_ctx, printer,
37 &guid);
38 if (!W_ERROR_IS_OK(werr)) {
39 - DEBUG(1, ("Failed to retrieve GUID for "
40 - "printer [%s] from AD - "
41 - "Is the the printer still "
42 - "published ?\n", printer));
43 + DEBUG(3, ("Failed to retrieve GUID for "
44 + "printer [%s] from AD - %s\n",
45 + printer,
46 + win_errstr(werr)));
47 + if (W_ERROR_EQUAL(werr, WERR_FILE_NOT_FOUND)) {
48 + /*
49 + * If we did not find it in AD, then it
50 + * is unpublished and we should reflect
51 + * this in the registry and return
52 + * success.
53 + */
54 + DEBUG(1, ("Unpublish printer [%s]\n",
55 + pinfo2->sharename));
56 + nt_printer_publish(tmp_ctx,
57 + session_info,
58 + msg_ctx,
59 + pinfo2,
60 + DSPRINT_UNPUBLISH);
61 + r->guid = talloc_strdup(mem_ctx, "");
62 + r->action = DSPRINT_UNPUBLISH;
63 +
64 + if (r->guid == NULL) {
65 + werr = WERR_NOT_ENOUGH_MEMORY;
66 + } else {
67 + werr = WERR_OK;
68 + }
69 + }
70 goto out_tmp_free;
71 }
72
73 --
74 2.10.1
75