[SCM] Samba Shared Repository - branch v3-4-stable updated

Karolin Seeger kseeger at samba.org
Tue Aug 23 11:46:16 MDT 2011


The branch, v3-4-stable has been updated
       via  cd6c0af WHATSNEW: Prepare release notes for 3.4.15.
       via  7f49539 s3/swat: use strlcat instead of strncat to fix build on old Linux distros
       via  8473536 s3:web/swat: use strtoll() instead of atoi/atol/atoll
       via  d919234 s3:nmbd_packets: return the used number of sockets in create_listen_fdset() (bug #8276)
       via  38ccc2d s3: increase the log level for missing PIDs on SIGCHLD
       via  39ec5c1 s3-libnet: fix bug #6364: Pull realm from supplied username on libnet join (cherry picked from commit 9a172dcd2e7bf91d78885325bce7a19e937b48af)
       via  deb939d s3-printing: remove duplicate cups response processing code
       via  75d9ea6 s3-printing: use printcap IDL for IPC
       via  95fbe86 idl: define printcap IPC message format
       via  15942c9 s3-printing: an empty cups printer list is treated as an error
       via  4bfaf8c s3-printing: remove pcap_cache_loaded asserts
       via  004564c Revert "Revert "s3-printing: update parent smbd pcap cache""
       via  41792ec Revert "Revert "s3-printing: reload shares after pcap cache fill""
      from  999514b WHATSNEW: Start release notes for 3.4.15.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-4-stable


- Log -----------------------------------------------------------------
commit cd6c0af7aad6f92f2415f9e11c23f1b36ab077e9
Author: Karolin Seeger <kseeger at samba.org>
Date:   Thu Aug 18 21:39:52 2011 +0200

    WHATSNEW: Prepare release notes for 3.4.15.
    
    Karolin
    (cherry picked from commit 3777f31f377e97e09d6cbe9c65c4c4b79b637da2)

commit 7f49539a70767da0bf456efa22a8f2fe3bc2f366
Author: Björn Jacke <bj at sernet.de>
Date:   Thu Aug 4 16:25:08 2011 +0200

    s3/swat: use strlcat instead of strncat to fix build on old Linux distros
    
    SLES 9's glibc for example had weird macros where the use of strncat resulted
    in the use of strcat which we don't allow.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User: Björn Jacke <bj at sernet.de>
    Autobuild-Date: Thu Aug  4 17:50:24 CEST 2011 on sn-devel-104
    (cherry picked from commit d3b4d75364210e2d2a4a1cd806f28b0021f22909)
    
    Fix bug #8362 (build issue on old glibc systems).
    (cherry picked from commit 87fa72a5202fe3780d4a61289bf755027cd078f4)
    (cherry picked from commit 552ccc6588b0744ae9b3731b1406749baea03d5a)
    (cherry picked from commit b941edf9c20bd6a92aec2a62be5b830db1194ce8)

commit 84735368921211d4b29d3b80ea747f692a2f1f91
Author: Stefan Metzmacher <metze at samba.org>
Date:   Fri Aug 5 19:48:38 2011 +0200

    s3:web/swat: use strtoll() instead of atoi/atol/atoll
    
    This is more portable, as we have a strtoll replacement
    in lib/replace.
    
    metze
    
    Autobuild-User: Stefan Metzmacher <metze at samba.org>
    Autobuild-Date: Sat Aug  6 11:55:45 CEST 2011 on sn-devel-104
    (cherry picked from commit a6be0820d09b3f3eabfbb5f4356add303aa8a494)
    
    Fix bug #8347 (CVE-2011-2522 regression for HP-UX, AIX and OSF).
    (cherry picked from commit ac5d8c0148e10a3a0af9e1dc0849bb6920c26ad7)

commit d9192349311c59e7ec5b58747fa8c393af5f9d3d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jun 30 09:56:06 2011 +0200

    s3:nmbd_packets: return the used number of sockets in create_listen_fdset() (bug #8276)
    
    Fix bug #7949 (DoS in Winbind and smbd with many file descriptors open)
    (commit feb3fcd0fa4bda0967b881315595d7702f4d1752) changed the bahavior,
    so that we skipped some sockets.
    
    This should work for v3-4-test.
    
    metze
    (cherry picked from commit 11b4dec29c9306531e73d5f4c12f89934dd538b4)

commit 38ccc2d665bb3f80fcb46a21b7646f3e0a09b7c9
Author: David Disseldorp <ddiss at suse.de>
Date:   Wed Feb 16 17:23:25 2011 +0100

    s3: increase the log level for missing PIDs on SIGCHLD
    
    Since the fix for bso#7836, the parent smbd is responsible for
    maintaining an up-to-date printcap cache. It does this by forking a
    child process to asynchronously fetch printcap data from CUPS.
    
    When the child process exits after fetching all printcap data, the
    parent smbd is sent SIGCHLD. This triggers smbd_sig_chld_handler() which
    looks for the exited process PID on a "children" list.
    Child smbd process PIDs are added to the "children" list to ensure
    cleanup on unclean shutdown and log level change notification messages.
    
    Printcap update process PIDs are not added to the list as they do not
    maintain any state that requires cleanup, nor do they wait on tevent for
    messages.
    
    Autobuild-User: Volker Lendecke <vlendec at samba.org>
    Autobuild-Date: Thu Feb 17 11:11:45 CET 2011 on sn-devel-104
    (cherry picked from commit 9c12232f1ae36e00d04114ad73edd8ba3c2c6a5c)
    
    Fix bug #8269 (smbd spams log with "Could not find child X -- ignoring"
    messages).
    (cherry picked from commit ba118ac287d49267dd2f346d4ddd2e590ebbe653)
    (cherry picked from commit c943af7ff13c64343e5246b27a7416627bffd365)

commit 39ec5c1a7c4074586b47a3abafaa331dfaab93df
Author: Jim McDonough <jmcd at samba.org>
Date:   Thu May 26 20:30:33 2011 +0200

    s3-libnet: fix bug #6364: Pull realm from supplied username on libnet join
    (cherry picked from commit 9a172dcd2e7bf91d78885325bce7a19e937b48af)

commit deb939d77acfcd03f07435d9268bedb6b9ddb8b6
Author: David Disseldorp <ddiss at suse.de>
Date:   Tue May 24 11:50:12 2011 +0200

    s3-printing: remove duplicate cups response processing code
    
    There is currently a lot of duplicate code included for processing
    responses to CUPS_GET_PRINTERS and CUPS_GET_CLASSES requests. This
    change splits this code into a separate function.
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    (cherry picked from commit a3635edc96e481f1125db1c26e33cae5b22a01a4)

commit 75d9ea6bdbd3d858d4648faa8a98fbf3e6ae7208
Author: David Disseldorp <ddiss at suse.de>
Date:   Tue May 24 11:46:25 2011 +0200

    s3-printing: use printcap IDL for IPC
    
    Use printcap IDL for marshalling and unmarshalling messages between cups
    child and parent smbd processes. This simplifies the IPC and ensures
    the parent is notified of cups errors encountered by the child.
    
    https://bugzilla.samba.org/show_bug.cgi?id=7994
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    (cherry picked from commit e5a0ac40d7467bb6ce07d942fdadb43f1ec81bfc)

commit 95fbe86b3a6f2351f787f802db7fd15bbae81570
Author: David Disseldorp <ddiss at suse.de>
Date:   Tue May 24 11:41:27 2011 +0200

    idl: define printcap IPC message format
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    (cherry picked from commit 9a107d2d65d3080aebe441b8b93cf17abeb092f7)

commit 15942c91032c2722a0f15c3eb953f6fe30b4ae5d
Author: David Disseldorp <ddiss at suse.de>
Date:   Tue May 24 11:34:59 2011 +0200

    s3-printing: an empty cups printer list is treated as an error
    
    cups_async_callback() is called to receive new printcap data from a
    child process which requests the information from cupsd.
    Newly received printcap information is stored in a temporary printcap
    cache (tmp_pcap_cache). Once the child process closes the printcap IPC
    file descriptor, the system printcap cache is replaced with the newly
    populated tmp_pcap_cache, however this only occurs if tmp_pcap_cache is
    non null (has at least one printer).
    
    If the printcap cache is empty, which is the case when cups is not
    exporting any printers, the printcap cache is not replaced resulting in
    stale data.
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    (cherry picked from commit 52bac5ffeea8ecbd2a5ecca023b3e2014c1350da)

commit 4bfaf8cb4702f77bb546d3739bbacd5ac5187e33
Author: David Disseldorp <ddiss at suse.de>
Date:   Mon Jan 17 16:09:32 2011 +0100

    s3-printing: remove pcap_cache_loaded asserts
    
    pcap_cache_loaded() assertions were added to the (re)load_printers()
    functions, to ensure the caller had called pcap_cache_reload() prior to
    reloading printer shares.
    
    The problem is, pcap_cache_loaded() returns false if the the pcap_cache
    contains no printer entries. i.e. pcap_cache_reload() has run but not
    detected any printers.
    
    Remove these assertions, correct call ordering is already enforced.
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    
    The last 3 patches address bug #7836 (A newly added printer isn't visbile to
    clients).
    (cherry picked from commit da9b2d9d58193ed3da36c2f8ff1e41a1e743ba07)

commit 004564cd754fc471d0954b79e8d9ba970bceba0e
Author: David Disseldorp <ddiss at suse.de>
Date:   Thu May 19 11:29:12 2011 +0200

    Revert "Revert "s3-printing: update parent smbd pcap cache""
    
    This reverts commit ad450870eacb114b3f15941a4478ba25701e035a.
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    (cherry picked from commit ee094b53d7fd9c46bca57b9815993282c63af00c)

commit 41792ec4f1cf6f90724aa8fc65cecdaa5566fdcf
Author: David Disseldorp <ddiss at suse.de>
Date:   Thu May 19 11:26:18 2011 +0200

    Revert "Revert "s3-printing: reload shares after pcap cache fill""
    
    This reverts commit 36ea03bbe28122ce03de4969e254dd276cfe5a79.
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    (cherry picked from commit 3e1969d229dff2921b43189969dfbe522b167cc2)

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

Summary of changes:
 WHATSNEW.txt                          |   23 ++-
 source3/Makefile.in                   |    5 +-
 source3/include/local.h               |    1 +
 source3/include/proto.h               |    4 +-
 source3/libnet/libnet_join.c          |    7 +
 source3/librpc/gen_ndr/ndr_printcap.c |  168 ++++++++++++
 source3/librpc/gen_ndr/ndr_printcap.h |   14 +
 source3/librpc/gen_ndr/printcap.h     |   21 ++
 source3/librpc/idl/printcap.idl       |   17 ++
 source3/nmbd/nmbd_packets.c           |    2 +-
 source3/printing/load.c               |    5 +-
 source3/printing/pcap.c               |   18 +-
 source3/printing/print_cups.c         |  448 +++++++++++++++------------------
 source3/smbd/process.c                |    4 +-
 source3/smbd/server.c                 |   31 ++-
 source3/web/swat.c                    |   31 ++-
 16 files changed, 515 insertions(+), 284 deletions(-)
 create mode 100644 source3/librpc/gen_ndr/ndr_printcap.c
 create mode 100644 source3/librpc/gen_ndr/ndr_printcap.h
 create mode 100644 source3/librpc/gen_ndr/printcap.h
 create mode 100644 source3/librpc/idl/printcap.idl


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 890d002..4f86dc5 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -1,19 +1,34 @@
                    ==============================
                    Release Notes for Samba 3.4.15
-			   , 2011
+			   August 23, 2011
                    ==============================
 
 
 This is the latest stable release of Samba 3.4.
 
-Major enhancements in Samba 3.4.15 include:
-
 
 Changes since 3.4.14
 --------------------
 
 
-o   
+o   David Disseldorp <ddiss at suse.de>
+    * BUG 7836: Make newly added printers visible to clients,
+    * BUG 7994: Make cups async printcap retrieval notify parent smbd of error	      status.
+    * BUG 8269: Stop spamming log with "Could not find child X -- ignoring"
+      messages.
+
+
+o   Björn Jacke <bj at sernet.de>
+    * BUG 8362: Fix build issue on old glibc systems.
+
+
+o   Jim McDonough <jmcd at samba.org>
+    * BUG 6364: Pull realm from supplied username on libnet join.
+
+
+o   Stefan Metzmacher <metze at samba.org>
+    * BUG 8276: Return the used number of sockets in create_listen_fdset().
+    * BUG 8347: Fix CVE-2011-2522 regression for HP-UX, AIX and OSF.
 
 
 ######################################################################
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 82e108a..ca5eaaf 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -755,7 +755,7 @@ SMBD_OBJ_BASE = $(PARAM_WITHOUT_REG_OBJ) $(SMBD_OBJ_SRV) $(LIBSMB_OBJ) \
 PRINTING_OBJ = printing/pcap.o printing/print_svid.o printing/print_aix.o \
                printing/print_cups.o printing/print_generic.o \
                printing/lpq_parse.o printing/load.o \
-               printing/print_iprint.o
+               printing/print_iprint.o librpc/gen_ndr/ndr_printcap.o
 
 PRINTBASE_OBJ = printing/notify.o printing/printing_db.o
 PRINTBACKEND_OBJ = printing/printing.o printing/nt_printing.o $(PRINTBASE_OBJ)
@@ -1272,7 +1272,8 @@ samba3-idl::
 	 srcdir="$(srcdir)" ../librpc/build_idl.sh ../librpc/idl/*.idl
 	@PIDL_OUTPUTDIR="librpc/gen_ndr" PIDL_ARGS="$(PIDL_ARGS)" CPP="$(CPP)" PIDL="../pidl/pidl" \
 	 srcdir="$(srcdir)" $(srcdir)/script/build_idl.sh \
-	 	librpc/idl/messaging.idl librpc/idl/libnetapi.idl librpc/idl/notify.idl
+		librpc/idl/messaging.idl librpc/idl/libnetapi.idl librpc/idl/notify.idl \
+		librpc/idl/printcap.idl
 
 #####################################################################
 
diff --git a/source3/include/local.h b/source3/include/local.h
index a88b17b..d65cc00 100644
--- a/source3/include/local.h
+++ b/source3/include/local.h
@@ -148,6 +148,7 @@
 #define LPQ_LOCK_TIMEOUT (5)
 #define NMBD_INTERFACES_RELOAD (120)
 #define NMBD_UNEXPECTED_TIMEOUT (15)
+#define SMBD_HOUSEKEEPING_INTERVAL SMBD_SELECT_TIMEOUT
 
 /* the following are in milliseconds */
 #define LOCK_RETRY_TIMEOUT (100)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 7c2893b..46ed4ab 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -4869,7 +4869,7 @@ void pcap_cache_destroy_specific(struct pcap_cache **ppcache);
 bool pcap_cache_add(const char *name, const char *comment);
 bool pcap_cache_loaded(void);
 void pcap_cache_replace(const struct pcap_cache *cache);
-void pcap_cache_reload(void);
+void pcap_cache_reload(void (*post_cache_fill_fn)(void));
 bool pcap_printername_ok(const char *printername);
 void pcap_printer_fn_specific(const struct pcap_cache *, void (*fn)(const char *, const char *, void *), void *);
 void pcap_printer_fn(void (*fn)(const char *, const char *, void *), void *);
@@ -4880,7 +4880,7 @@ bool aix_cache_reload(void);
 
 /* The following definitions come from printing/print_cups.c  */
 
-bool cups_cache_reload(void);
+bool cups_cache_reload(void (*post_cache_fill_fn)(void));
 bool cups_pull_comment_location(NT_PRINTER_INFO_LEVEL_2 *printer);
 
 /* The following definitions come from printing/print_generic.c  */
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
index 03832cf..6489126 100644
--- a/source3/libnet/libnet_join.c
+++ b/source3/libnet/libnet_join.c
@@ -100,6 +100,7 @@ static ADS_STATUS libnet_connect_ads(const char *dns_domain_name,
 {
 	ADS_STATUS status;
 	ADS_STRUCT *my_ads = NULL;
+	char *cp;
 
 	my_ads = ads_init(dns_domain_name,
 			  netbios_domain_name,
@@ -111,6 +112,12 @@ static ADS_STATUS libnet_connect_ads(const char *dns_domain_name,
 	if (user_name) {
 		SAFE_FREE(my_ads->auth.user_name);
 		my_ads->auth.user_name = SMB_STRDUP(user_name);
+		if ((cp = strchr_m(my_ads->auth.user_name, '@'))!=0) {
+			*cp++ = '\0';
+			SAFE_FREE(my_ads->auth.realm);
+			my_ads->auth.realm = smb_xstrdup(cp);
+			strupper_m(my_ads->auth.realm);
+		}
 	}
 
 	if (password) {
diff --git a/source3/librpc/gen_ndr/ndr_printcap.c b/source3/librpc/gen_ndr/ndr_printcap.c
new file mode 100644
index 0000000..b6c7ba6
--- /dev/null
+++ b/source3/librpc/gen_ndr/ndr_printcap.c
@@ -0,0 +1,168 @@
+/* parser auto-generated by pidl */
+
+#include "includes.h"
+#include "librpc/gen_ndr/ndr_printcap.h"
+
+static enum ndr_err_code ndr_push_pcap_printer(struct ndr_push *ndr, int ndr_flags, const struct pcap_printer *r)
+{
+	if (ndr_flags & NDR_SCALARS) {
+		NDR_CHECK(ndr_push_align(ndr, 4));
+		NDR_CHECK(ndr_push_unique_ptr(ndr, r->name));
+		NDR_CHECK(ndr_push_unique_ptr(ndr, r->info));
+	}
+	if (ndr_flags & NDR_BUFFERS) {
+		if (r->name) {
+			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->name, CH_UTF8)));
+			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->name, CH_UTF8)));
+			NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->name, ndr_charset_length(r->name, CH_UTF8), sizeof(uint8_t), CH_UTF8));
+		}
+		if (r->info) {
+			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->info, CH_UTF8)));
+			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
+			NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, ndr_charset_length(r->info, CH_UTF8)));
+			NDR_CHECK(ndr_push_charset(ndr, NDR_SCALARS, r->info, ndr_charset_length(r->info, CH_UTF8), sizeof(uint8_t), CH_UTF8));
+		}
+	}
+	return NDR_ERR_SUCCESS;
+}
+
+static enum ndr_err_code ndr_pull_pcap_printer(struct ndr_pull *ndr, int ndr_flags, struct pcap_printer *r)
+{
+	uint32_t _ptr_name;
+	TALLOC_CTX *_mem_save_name_0;
+	uint32_t _ptr_info;
+	TALLOC_CTX *_mem_save_info_0;
+	if (ndr_flags & NDR_SCALARS) {
+		NDR_CHECK(ndr_pull_align(ndr, 4));
+		NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_name));
+		if (_ptr_name) {
+			NDR_PULL_ALLOC(ndr, r->name);
+		} else {
+			r->name = NULL;
+		}
+		NDR_CHECK(ndr_pull_generic_ptr(ndr, &_ptr_info));
+		if (_ptr_info) {
+			NDR_PULL_ALLOC(ndr, r->info);
+		} else {
+			r->info = NULL;
+		}
+	}
+	if (ndr_flags & NDR_BUFFERS) {
+		if (r->name) {
+			_mem_save_name_0 = NDR_PULL_GET_MEM_CTX(ndr);
+			NDR_PULL_SET_MEM_CTX(ndr, r->name, 0);
+			NDR_CHECK(ndr_pull_array_size(ndr, &r->name));
+			NDR_CHECK(ndr_pull_array_length(ndr, &r->name));
+			if (ndr_get_array_length(ndr, &r->name) > ndr_get_array_size(ndr, &r->name)) {
+				return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->name), ndr_get_array_length(ndr, &r->name));
+			}
+			NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->name), sizeof(uint8_t)));
+			NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->name, ndr_get_array_length(ndr, &r->name), sizeof(uint8_t), CH_UTF8));
+			NDR_PULL_SET_MEM_CTX(ndr, _mem_save_name_0, 0);
+		}
+		if (r->info) {
+			_mem_save_info_0 = NDR_PULL_GET_MEM_CTX(ndr);
+			NDR_PULL_SET_MEM_CTX(ndr, r->info, 0);
+			NDR_CHECK(ndr_pull_array_size(ndr, &r->info));
+			NDR_CHECK(ndr_pull_array_length(ndr, &r->info));
+			if (ndr_get_array_length(ndr, &r->info) > ndr_get_array_size(ndr, &r->info)) {
+				return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "Bad array size %u should exceed array length %u", ndr_get_array_size(ndr, &r->info), ndr_get_array_length(ndr, &r->info));
+			}
+			NDR_CHECK(ndr_check_string_terminator(ndr, ndr_get_array_length(ndr, &r->info), sizeof(uint8_t)));
+			NDR_CHECK(ndr_pull_charset(ndr, NDR_SCALARS, &r->info, ndr_get_array_length(ndr, &r->info), sizeof(uint8_t), CH_UTF8));
+			NDR_PULL_SET_MEM_CTX(ndr, _mem_save_info_0, 0);
+		}
+	}
+	return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_pcap_printer(struct ndr_print *ndr, const char *name, const struct pcap_printer *r)
+{
+	ndr_print_struct(ndr, name, "pcap_printer");
+	ndr->depth++;
+	ndr_print_ptr(ndr, "name", r->name);
+	ndr->depth++;
+	if (r->name) {
+		ndr_print_string(ndr, "name", r->name);
+	}
+	ndr->depth--;
+	ndr_print_ptr(ndr, "info", r->info);
+	ndr->depth++;
+	if (r->info) {
+		ndr_print_string(ndr, "info", r->info);
+	}
+	ndr->depth--;
+	ndr->depth--;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_push_pcap_data(struct ndr_push *ndr, int ndr_flags, const struct pcap_data *r)
+{
+	uint32_t cntr_printers_0;
+	if (ndr_flags & NDR_SCALARS) {
+		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count));
+		NDR_CHECK(ndr_push_align(ndr, 4));
+		NDR_CHECK(ndr_push_NTSTATUS(ndr, NDR_SCALARS, r->status));
+		NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->count));
+		for (cntr_printers_0 = 0; cntr_printers_0 < r->count; cntr_printers_0++) {
+			NDR_CHECK(ndr_push_pcap_printer(ndr, NDR_SCALARS, &r->printers[cntr_printers_0]));
+		}
+	}
+	if (ndr_flags & NDR_BUFFERS) {
+		for (cntr_printers_0 = 0; cntr_printers_0 < r->count; cntr_printers_0++) {
+			NDR_CHECK(ndr_push_pcap_printer(ndr, NDR_BUFFERS, &r->printers[cntr_printers_0]));
+		}
+	}
+	return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_pull_pcap_data(struct ndr_pull *ndr, int ndr_flags, struct pcap_data *r)
+{
+	uint32_t cntr_printers_0;
+	TALLOC_CTX *_mem_save_printers_0;
+	if (ndr_flags & NDR_SCALARS) {
+		NDR_CHECK(ndr_pull_array_size(ndr, &r->printers));
+		NDR_CHECK(ndr_pull_align(ndr, 4));
+		NDR_CHECK(ndr_pull_NTSTATUS(ndr, NDR_SCALARS, &r->status));
+		NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->count));
+		NDR_PULL_ALLOC_N(ndr, r->printers, ndr_get_array_size(ndr, &r->printers));
+		_mem_save_printers_0 = NDR_PULL_GET_MEM_CTX(ndr);
+		NDR_PULL_SET_MEM_CTX(ndr, r->printers, 0);
+		for (cntr_printers_0 = 0; cntr_printers_0 < r->count; cntr_printers_0++) {
+			NDR_CHECK(ndr_pull_pcap_printer(ndr, NDR_SCALARS, &r->printers[cntr_printers_0]));
+		}
+		NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printers_0, 0);
+		if (r->printers) {
+			NDR_CHECK(ndr_check_array_size(ndr, (void*)&r->printers, r->count));
+		}
+	}
+	if (ndr_flags & NDR_BUFFERS) {
+		_mem_save_printers_0 = NDR_PULL_GET_MEM_CTX(ndr);
+		NDR_PULL_SET_MEM_CTX(ndr, r->printers, 0);
+		for (cntr_printers_0 = 0; cntr_printers_0 < r->count; cntr_printers_0++) {
+			NDR_CHECK(ndr_pull_pcap_printer(ndr, NDR_BUFFERS, &r->printers[cntr_printers_0]));
+		}
+		NDR_PULL_SET_MEM_CTX(ndr, _mem_save_printers_0, 0);
+	}
+	return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ void ndr_print_pcap_data(struct ndr_print *ndr, const char *name, const struct pcap_data *r)
+{
+	uint32_t cntr_printers_0;
+	ndr_print_struct(ndr, name, "pcap_data");
+	ndr->depth++;
+	ndr_print_NTSTATUS(ndr, "status", r->status);
+	ndr_print_uint32(ndr, "count", r->count);
+	ndr->print(ndr, "%s: ARRAY(%d)", "printers", (int)r->count);
+	ndr->depth++;
+	for (cntr_printers_0=0;cntr_printers_0<r->count;cntr_printers_0++) {
+		char *idx_0=NULL;
+		if (asprintf(&idx_0, "[%d]", cntr_printers_0) != -1) {
+			ndr_print_pcap_printer(ndr, "printers", &r->printers[cntr_printers_0]);
+			free(idx_0);
+		}
+	}
+	ndr->depth--;
+	ndr->depth--;
+}
diff --git a/source3/librpc/gen_ndr/ndr_printcap.h b/source3/librpc/gen_ndr/ndr_printcap.h
new file mode 100644
index 0000000..37589da
--- /dev/null
+++ b/source3/librpc/gen_ndr/ndr_printcap.h
@@ -0,0 +1,14 @@
+/* header auto-generated by pidl */
+
+#include "librpc/ndr/libndr.h"
+#include "librpc/gen_ndr/printcap.h"
+
+#ifndef _HEADER_NDR_printcap
+#define _HEADER_NDR_printcap
+
+#define NDR_PRINTCAP_CALL_COUNT (0)
+void ndr_print_pcap_printer(struct ndr_print *ndr, const char *name, const struct pcap_printer *r);
+enum ndr_err_code ndr_push_pcap_data(struct ndr_push *ndr, int ndr_flags, const struct pcap_data *r);
+enum ndr_err_code ndr_pull_pcap_data(struct ndr_pull *ndr, int ndr_flags, struct pcap_data *r);
+void ndr_print_pcap_data(struct ndr_print *ndr, const char *name, const struct pcap_data *r);
+#endif /* _HEADER_NDR_printcap */
diff --git a/source3/librpc/gen_ndr/printcap.h b/source3/librpc/gen_ndr/printcap.h
new file mode 100644
index 0000000..c8d6350
--- /dev/null
+++ b/source3/librpc/gen_ndr/printcap.h
@@ -0,0 +1,21 @@
+/* header auto-generated by pidl */
+
+#include <stdint.h>
+
+#include "libcli/util/ntstatus.h"
+
+#ifndef _HEADER_printcap
+#define _HEADER_printcap
+
+struct pcap_printer {
+	const char *name;/* [unique,charset(UTF8)] */
+	const char *info;/* [unique,charset(UTF8)] */
+};
+
+struct pcap_data {
+	NTSTATUS status;
+	uint32_t count;
+	struct pcap_printer *printers;/* [size_is(count)] */
+}/* [public] */;
+
+#endif /* _HEADER_printcap */
diff --git a/source3/librpc/idl/printcap.idl b/source3/librpc/idl/printcap.idl
new file mode 100644
index 0000000..5ab380c
--- /dev/null
+++ b/source3/librpc/idl/printcap.idl
@@ -0,0 +1,17 @@
+#include "idl_types.h"
+[
+	pointer_default(unique)
+]
+interface printcap
+{
+	typedef struct {
+		[charset(UTF8),string] uint8 *name;
+		[charset(UTF8),string] uint8 *info;
+	} pcap_printer;
+
+	typedef [public] struct {
+		NTSTATUS status;
+		uint32 count;
+		[size_is(count)] pcap_printer printers[];
+	} pcap_data;
+}
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
index 1c570ea..855f6af 100644
--- a/source3/nmbd/nmbd_packets.c
+++ b/source3/nmbd/nmbd_packets.c
@@ -1742,7 +1742,7 @@ only use %d.\n", (count*2) + 2, FD_SETSIZE));
 		*maxfd = MAX( *maxfd, subrec->dgram_sock);
 	}
 
-	*listen_number = (count*2) + 2;
+	*listen_number = num;
 
 	SAFE_FREE(*ppset);
 	SAFE_FREE(*psock_array);
diff --git a/source3/printing/load.c b/source3/printing/load.c
index 874f7f2..c80a479 100644
--- a/source3/printing/load.c
+++ b/source3/printing/load.c
@@ -53,13 +53,10 @@ static void add_auto_printers(void)
 }
 
 /***************************************************************************
-load automatic printer services
+load automatic printer services from pre-populated pcap cache
 ***************************************************************************/
 void load_printers(void)
 {
-	if (!pcap_cache_loaded())
-		pcap_cache_reload();
-
 	add_auto_printers();
 
 	/* load all printcap printers */
diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c
index a6bf52a..0d6480c 100644
--- a/source3/printing/pcap.c
+++ b/source3/printing/pcap.c
@@ -125,13 +125,14 @@ void pcap_cache_replace(const struct pcap_cache *pcache)
 	}
 }
 
-void pcap_cache_reload(void)
+void pcap_cache_reload(void (*post_cache_fill_fn)(void))
 {
 	const char *pcap_name = lp_printcapname();
 	bool pcap_reloaded = False;
 	struct pcap_cache *tmp_cache = NULL;
 	XFILE *pcap_file;
 	char *pcap_line;
+	bool post_cache_fill_fn_handled = false;
 
 	DEBUG(3, ("reloading printcap cache\n"));
 
@@ -146,7 +147,12 @@ void pcap_cache_reload(void)
 
 #ifdef HAVE_CUPS
 	if (strequal(pcap_name, "cups")) {
-		pcap_reloaded = cups_cache_reload();
+		pcap_reloaded = cups_cache_reload(post_cache_fill_fn);
+		/*
+		 * cups_cache_reload() is async and calls post_cache_fill_fn()
+		 * on successful completion
+		 */
+		post_cache_fill_fn_handled = true;
 		goto done;
 	}
 #endif
@@ -242,9 +248,13 @@ void pcap_cache_reload(void)
 done:
 	DEBUG(3, ("reload status: %s\n", (pcap_reloaded) ? "ok" : "error"));
 
-	if (pcap_reloaded)
+	if (pcap_reloaded) {
 		pcap_cache_destroy_specific(&tmp_cache);
-	else {
+		if ((post_cache_fill_fn_handled == false)
+		 && (post_cache_fill_fn != NULL)) {
+			post_cache_fill_fn();
+		}
+	} else {
 		pcap_cache_destroy_specific(&pcap_cache);
 		pcap_cache = tmp_cache;
 	}
diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c
index e2c8b7e..333d6f0 100644
--- a/source3/printing/print_cups.c
+++ b/source3/printing/print_cups.c
@@ -24,6 +24,7 @@
 
 #include "includes.h"
 #include "printing.h"
+#include "librpc/gen_ndr/ndr_printcap.h"
 
 #ifdef HAVE_CUPS
 #include <cups/cups.h>
@@ -106,60 +107,153 @@ static http_t *cups_connect(TALLOC_CTX *frame)
 	return http;
 }
 
-static void send_pcap_info(const char *name, const char *info, void *pd)
+static bool send_pcap_blob(DATA_BLOB *pcap_blob, int fd)
 {
-	int fd = *(int *)pd;
-	size_t namelen = name ? strlen(name)+1 : 0;
-	size_t infolen = info ? strlen(info)+1 : 0;
-
-	DEBUG(11,("send_pcap_info: writing namelen %u\n", (unsigned int)namelen));
-	if (sys_write(fd, &namelen, sizeof(namelen)) != sizeof(namelen)) {
-		DEBUG(10,("send_pcap_info: namelen write failed %s\n",
-			strerror(errno)));
-		return;
-	}
-	DEBUG(11,("send_pcap_info: writing infolen %u\n", (unsigned int)infolen));
-	if (sys_write(fd, &infolen, sizeof(infolen)) != sizeof(infolen)) {
-		DEBUG(10,("send_pcap_info: infolen write failed %s\n",
-			strerror(errno)));
-		return;
-	}
-	if (namelen) {
-		DEBUG(11,("send_pcap_info: writing name %s\n", name));
-		if (sys_write(fd, name, namelen) != namelen) {
-			DEBUG(10,("send_pcap_info: name write failed %s\n",
-				strerror(errno)));
-			return;
-		}
+	size_t ret;
+
+	ret = sys_write(fd, &pcap_blob->length, sizeof(pcap_blob->length));
+	if (ret != sizeof(pcap_blob->length)) {
+		return false;
+	}
+


-- 
Samba Shared Repository


More information about the samba-cvs mailing list