[SCM] Samba Shared Repository - branch v4-0-test updated

Karolin Seeger kseeger at samba.org
Sat Feb 22 20:58:05 MST 2014


The branch, v4-0-test has been updated
       via  68c6cb5 s3: printing: Fix problem with server taking too long to respond to a MSG_PRINTER_DRVUPGRADE message.
       via  23bec26 librpc/nbt: increase MAX_COMPONENTS limit for nbt_names.
       via  4d857a9 dfs: always call create_conn_struct with root privileges
       via  4bc4ab9 smbd: Fix calls to create_conn_struct_cwd to be correctly indented.
       via  d534964 smbd: Split create_conn_struct into a fn that does not change the working dir
      from  20d7ec8 VERSION: Bump version number up to 4.0.15...

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-0-test


- Log -----------------------------------------------------------------
commit 68c6cb5a6909f50c6d016803881695809ccd1fbb
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Feb 12 10:13:19 2014 -0800

    s3: printing: Fix problem with server taking too long to respond to a MSG_PRINTER_DRVUPGRADE message.
    
    Receiving a MSG_PRINTER_DRVUPGRADE causes
    smbd to iterate over all printers looking
    for ones that uses the driver. This is a very
    expensive operation requiring a read of all
    registry printer parameters.
    
    On a system with a large number of printers,
    this causes the clients to timeout (smbd
    can take longer than 60 seconds to respond).
    
    This patch fixes the problem by forwarding
    the MSG_PRINTER_DRVUPGRADE to the background
    lpq queue updater process and allowing it to
    take care of the updating of the changeid
    in the registry, allowing the smbd connected
    to the client to return to processing requests
    immediately.
    
    https://bugzilla.samba.org/show_bug.cgi?id=9942
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Tue Feb 18 17:48:30 CET 2014 on sn-devel-104
    
    (cherry picked from commit cd655715b8ee0a4e681d67b3996f71017b941401)
    
    Autobuild-User(v4-0-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-0-test): Sun Feb 23 04:57:30 CET 2014 on sn-devel-104

commit 23bec26d78547e5a82c79fc3f1fc1f41c0d785da
Author: Günther Deschner <gd at samba.org>
Date:   Tue Feb 4 16:38:46 2014 +0100

    librpc/nbt: increase MAX_COMPONENTS limit for nbt_names.
    
    domains with more then 10 subdomains are not so uncommon.
    
    https://bugzilla.samba.org/show_bug.cgi?id=10439
    
    Guenther
    
    Signed-off-by: Günther Deschner <gd at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Günther Deschner <gd at samba.org>
    Autobuild-Date(master): Thu Feb 13 16:30:50 CET 2014 on sn-devel-104
    
    (cherry picked from commit 4e05bad0d18e351cb2a2db74860e77adea727c79)
    Signed-off-by: Andreas Schneider <asn at samba.org>

commit 4d857a92aa798448525db50c72327cfa5befc075
Author: Garming Sam <garming at catalyst.net.nz>
Date:   Thu Dec 19 09:55:44 2013 +1300

    dfs: always call create_conn_struct with root privileges
    
    This fixes a bug in dfs_samba4 identified by Daniel Müller.
    
    create_conn_struct calls SMB_VFS_CONNECT which requires root privileges.
    SMB_VFS_CONNECT in turn calls dfs_samba4_connect which connects to samdb.
    
    Calls were made to this function without ever becoming root (notably via setup_dfs_referral)
    which resulted in an error and the VFS connect failing. This happens when you have an active
    directory domain controller with host msdfs = yes in smb.conf and dfs links in place.
    
    Signed-off-by: Garming Sam <garming at catalyst.net.nz>
    Reviewed-by: Bjoern Baumbach <bb at sernet.de>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Jan 10 20:11:03 CET 2014 on sn-devel-104
    
    (cherry picked from commit 24a687642de21ce872d25f16b3525003844d05f9)
    
    Fix bug #10378 - dfs: always call create_conn_struct with root privileges.

commit 4bc4ab90deb9265dc506abc9c3d854909c68dccf
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Jan 8 09:29:48 2013 +1100

    smbd: Fix calls to create_conn_struct_cwd to be correctly indented.
    
    These are whitespace changes only, left out of the previous commit to preserve clarity.
    
    Andrew Bartlett.
    
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 5a3e915d20bb11984c42081bf25ce09baa58e04e)

commit d534964ea9741cc79f7cd7c2f7e9ed0a3a79d8dc
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Oct 10 13:47:49 2012 +1100

    smbd: Split create_conn_struct into a fn that does not change the working dir
    
    The python bindings do not want the current working directory changed
    during operations, so we provide two functions, one providing the
    original behaviour, and other providing the python bindings with just
    the memory allocation and initilisation stuff.
    
    Andrew Bartlett
    
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 6c80cf747d75e648a1d88d477bcf476e6874c4b3)

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

Summary of changes:
 librpc/ndr/ndr_nbt.c                        |    2 +-
 source3/printing/nt_printing.c              |   71 +++++++++++-----
 source3/printing/queue_process.c            |    6 ++
 source3/rpc_server/spoolss/srv_spoolss_nt.c |    1 +
 source3/rpc_server/srvsvc/srv_srvsvc_nt.c   |   24 +++---
 source3/smbd/msdfs.c                        |  121 ++++++++++++++++++++-------
 source3/smbd/proto.h                        |   11 ++-
 7 files changed, 167 insertions(+), 69 deletions(-)


Changeset truncated at 500 lines:

diff --git a/librpc/ndr/ndr_nbt.c b/librpc/ndr/ndr_nbt.c
index f2a1ca3..842e972 100644
--- a/librpc/ndr/ndr_nbt.c
+++ b/librpc/ndr/ndr_nbt.c
@@ -27,7 +27,7 @@
 #include "../libcli/netlogon/netlogon.h"
 
 /* don't allow an unlimited number of name components */
-#define MAX_COMPONENTS 10
+#define MAX_COMPONENTS 128
 
 /**
   print a nbt string
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 5050a5d..c472d41 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -75,6 +75,31 @@ static const struct print_architecture_table_node archi_table[]= {
 };
 
 /****************************************************************************
+ Forward a MSG_PRINTER_DRVUPGRADE message from another smbd to the
+ background lpq updater.
+****************************************************************************/
+
+static void forward_drv_upgrade_printer_msg(struct messaging_context *msg,
+				void *private_data,
+				uint32_t msg_type,
+				struct server_id server_id,
+				DATA_BLOB *data)
+{
+	extern pid_t background_lpq_updater_pid;
+
+	if (background_lpq_updater_pid == -1) {
+		DEBUG(3,("no background lpq queue updater\n"));
+		return;
+	}
+
+	messaging_send_buf(msg,
+			pid_to_procid(background_lpq_updater_pid),
+			MSG_PRINTER_DRVUPGRADE,
+			data->data,
+			data->length);
+}
+
+/****************************************************************************
  Open the NT printing tdbs. Done once before fork().
 ****************************************************************************/
 
@@ -88,10 +113,10 @@ bool nt_printing_init(struct messaging_context *msg_ctx)
 
 	/*
 	 * register callback to handle updating printers as new
-	 * drivers are installed
+	 * drivers are installed. Forwards to background lpq updater.
 	 */
 	messaging_register(msg_ctx, NULL, MSG_PRINTER_DRVUPGRADE,
-			   do_drv_upgrade_printer);
+			forward_drv_upgrade_printer_msg);
 
 	/* of course, none of the message callbacks matter if you don't
 	   tell messages.c that you interested in receiving PRINT_GENERAL
@@ -616,13 +641,13 @@ static uint32 get_correct_cversion(struct auth_session_info *session_info,
 		return -1;
 	}
 
-	nt_status = create_conn_struct(talloc_tos(),
-				       server_event_context(),
-				       server_messaging_context(),
-				       &conn,
-				       printdollar_snum,
-				       lp_pathname(talloc_tos(), printdollar_snum),
-				       session_info, &oldcwd);
+	nt_status = create_conn_struct_cwd(talloc_tos(),
+					   server_event_context(),
+					   server_messaging_context(),
+					   &conn,
+					   printdollar_snum,
+					   lp_pathname(talloc_tos(), printdollar_snum),
+					   session_info, &oldcwd);
 	if (!NT_STATUS_IS_OK(nt_status)) {
 		DEBUG(0,("get_correct_cversion: create_conn_struct "
 			 "returned %s\n", nt_errstr(nt_status)));
@@ -1003,13 +1028,13 @@ WERROR move_driver_to_download_area(struct auth_session_info *session_info,
 		return WERR_NO_SUCH_SHARE;
 	}
 
-	nt_status = create_conn_struct(talloc_tos(),
-				       server_event_context(),
-				       server_messaging_context(),
-				       &conn,
-				       printdollar_snum,
-				       lp_pathname(talloc_tos(), printdollar_snum),
-				       session_info, &oldcwd);
+	nt_status = create_conn_struct_cwd(talloc_tos(),
+					   server_event_context(),
+					   server_messaging_context(),
+					   &conn,
+					   printdollar_snum,
+					   lp_pathname(talloc_tos(), printdollar_snum),
+					   session_info, &oldcwd);
 	if (!NT_STATUS_IS_OK(nt_status)) {
 		DEBUG(0,("move_driver_to_download_area: create_conn_struct "
 			 "returned %s\n", nt_errstr(nt_status)));
@@ -1539,13 +1564,13 @@ bool delete_driver_files(const struct auth_session_info *session_info,
 		return false;
 	}
 
-	nt_status = create_conn_struct(talloc_tos(),
-				       server_event_context(),
-				       server_messaging_context(),
-				       &conn,
-				       printdollar_snum,
-				       lp_pathname(talloc_tos(), printdollar_snum),
-				       session_info, &oldcwd);
+	nt_status = create_conn_struct_cwd(talloc_tos(),
+					   server_event_context(),
+					   server_messaging_context(),
+					   &conn,
+					   printdollar_snum,
+					   lp_pathname(talloc_tos(), printdollar_snum),
+					   session_info, &oldcwd);
 	if (!NT_STATUS_IS_OK(nt_status)) {
 		DEBUG(0,("delete_driver_files: create_conn_struct "
 			 "returned %s\n", nt_errstr(nt_status)));
diff --git a/source3/printing/queue_process.c b/source3/printing/queue_process.c
index 3d142dd..0969c7b 100644
--- a/source3/printing/queue_process.c
+++ b/source3/printing/queue_process.c
@@ -31,6 +31,7 @@
 #include "smbd/smbd.h"
 #include "rpc_server/rpc_config.h"
 #include "printing/load.h"
+#include "rpc_server/spoolss/srv_spoolss_nt.h"
 
 extern pid_t start_spoolssd(struct event_context *ev_ctx,
 			    struct messaging_context *msg_ctx);
@@ -311,6 +312,11 @@ pid_t start_background_queue(struct tevent_context *ev,
 				   bq_smb_conf_updated);
 		messaging_register(msg_ctx, NULL, MSG_PRINTER_UPDATE,
 				   print_queue_receive);
+		/* Remove previous forwarder message set in parent. */
+		messaging_deregister(msg_ctx, MSG_PRINTER_DRVUPGRADE, NULL);
+
+		messaging_register(msg_ctx, NULL, MSG_PRINTER_DRVUPGRADE,
+				   do_drv_upgrade_printer);
 
 		fde = tevent_add_fd(ev, ev, pause_pipe[1], TEVENT_FD_READ,
 				    printing_pause_fd_handler,
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index 3703349..c878679 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -1513,6 +1513,7 @@ void srv_spoolss_cleanup(void)
 /**********************************************************************
  callback to receive a MSG_PRINTER_DRVUPGRADE message and interate
  over all printers, upgrading ones as necessary
+ This is now *ONLY* called inside the background lpq updater. JRA.
  **********************************************************************/
 
 void do_drv_upgrade_printer(struct messaging_context *msg,
diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
index a6472a6..2d58466 100644
--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
@@ -2037,12 +2037,12 @@ WERROR _srvsvc_NetGetFileSecurity(struct pipes_struct *p,
 		goto error_exit;
 	}
 
-	nt_status = create_conn_struct(talloc_tos(),
-				       server_event_context(),
-				       server_messaging_context(),
-				       &conn,
-				       snum, lp_pathname(talloc_tos(), snum),
-				       p->session_info, &oldcwd);
+	nt_status = create_conn_struct_cwd(talloc_tos(),
+					   server_event_context(),
+					   server_messaging_context(),
+					   &conn,
+					   snum, lp_pathname(talloc_tos(), snum),
+					   p->session_info, &oldcwd);
 	if (!NT_STATUS_IS_OK(nt_status)) {
 		DEBUG(10, ("create_conn_struct failed: %s\n",
 			   nt_errstr(nt_status)));
@@ -2184,12 +2184,12 @@ WERROR _srvsvc_NetSetFileSecurity(struct pipes_struct *p,
 		goto error_exit;
 	}
 
-	nt_status = create_conn_struct(talloc_tos(),
-				       server_event_context(),
-				       server_messaging_context(),
-				       &conn,
-				       snum, lp_pathname(talloc_tos(), snum),
-				       p->session_info, &oldcwd);
+	nt_status = create_conn_struct_cwd(talloc_tos(),
+					   server_event_context(),
+					   server_messaging_context(),
+					   &conn,
+					   snum, lp_pathname(talloc_tos(), snum),
+					   p->session_info, &oldcwd);
 	if (!NT_STATUS_IS_OK(nt_status)) {
 		DEBUG(10, ("create_conn_struct failed: %s\n",
 			   nt_errstr(nt_status)));
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
index ccbd89c..8a88634 100644
--- a/source3/smbd/msdfs.c
+++ b/source3/smbd/msdfs.c
@@ -218,22 +218,23 @@ static NTSTATUS parse_dfs_path(connection_struct *conn,
 }
 
 /********************************************************
- Fake up a connection struct for the VFS layer.
- Note: this performs a vfs connect and CHANGES CWD !!!! JRA.
+ Fake up a connection struct for the VFS layer, for use in
+ applications (such as the python bindings), that do not want the
+ global working directory changed under them.
+
+ SMB_VFS_CONNECT requires root privileges.
 *********************************************************/
 
-NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
+static NTSTATUS create_conn_struct_as_root(TALLOC_CTX *ctx,
 			    struct tevent_context *ev,
 			    struct messaging_context *msg,
 			    connection_struct **pconn,
 			    int snum,
 			    const char *path,
-			    const struct auth_session_info *session_info,
-			    char **poldcwd)
+			    const struct auth_session_info *session_info)
 {
 	connection_struct *conn;
 	char *connpath;
-	char *oldcwd;
 	const char *vfs_user;
 
 	conn = talloc_zero(ctx, connection_struct);
@@ -247,9 +248,9 @@ NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
 		return NT_STATUS_NO_MEMORY;
 	}
 	connpath = talloc_string_sub(conn,
-				connpath,
-				"%S",
-				lp_servicename(talloc_tos(), snum));
+				     connpath,
+				     "%S",
+				     lp_servicename(talloc_tos(), snum));
 	if (!connpath) {
 		TALLOC_FREE(conn);
 		return NT_STATUS_NO_MEMORY;
@@ -341,6 +342,64 @@ NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
 	}
 
 	conn->fs_capabilities = SMB_VFS_FS_CAPABILITIES(conn, &conn->ts_res);
+	*pconn = conn;
+
+	return NT_STATUS_OK;
+}
+
+/********************************************************
+ Fake up a connection struct for the VFS layer, for use in
+ applications (such as the python bindings), that do not want the
+ global working directory changed under them.
+
+ SMB_VFS_CONNECT requires root privileges.
+*********************************************************/
+
+NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
+			    struct tevent_context *ev,
+			    struct messaging_context *msg,
+			    connection_struct **pconn,
+			    int snum,
+			    const char *path,
+			    const struct auth_session_info *session_info)
+{
+	NTSTATUS status;
+	become_root();
+	status = create_conn_struct_as_root(ctx, ev,
+					    msg, pconn,
+					    snum, path,
+					    session_info);
+	unbecome_root();
+
+	return status;
+}
+
+/********************************************************
+ Fake up a connection struct for the VFS layer.
+ Note: this performs a vfs connect and CHANGES CWD !!!! JRA.
+
+ The old working directory is returned on *poldcwd, allocated on ctx.
+*********************************************************/
+
+NTSTATUS create_conn_struct_cwd(TALLOC_CTX *ctx,
+				struct tevent_context *ev,
+				struct messaging_context *msg,
+				connection_struct **pconn,
+				int snum,
+				const char *path,
+				const struct auth_session_info *session_info,
+				char **poldcwd)
+{
+	connection_struct *conn;
+	char *oldcwd;
+
+	NTSTATUS status = create_conn_struct(ctx, ev,
+					     msg, &conn,
+					     snum, path,
+					     session_info);
+	if (!NT_STATUS_IS_OK(status)) {
+		return status;
+	}
 
 	/*
 	 * Windows seems to insist on doing trans2getdfsreferral() calls on
@@ -350,14 +409,14 @@ NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
 
 	oldcwd = vfs_GetWd(ctx, conn);
 	if (oldcwd == NULL) {
-		NTSTATUS status = map_nt_error_from_unix(errno);
+		status = map_nt_error_from_unix(errno);
 		DEBUG(3, ("vfs_GetWd failed: %s\n", strerror(errno)));
 		conn_free(conn);
 		return status;
 	}
 
 	if (vfs_ChDir(conn,conn->connectpath) != 0) {
-		NTSTATUS status = map_nt_error_from_unix(errno);
+		status = map_nt_error_from_unix(errno);
 		DEBUG(3,("create_conn_struct: Can't ChDir to new conn path %s. "
 			"Error was %s\n",
 			conn->connectpath, strerror(errno) ));
@@ -981,11 +1040,11 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
 		return NT_STATUS_OK;
 	}
 
-	status = create_conn_struct(ctx,
-				    server_event_context(),
-				    server_messaging_context(),
-				    &conn, snum,
-				    lp_pathname(talloc_tos(), snum), NULL, &oldpath);
+	status = create_conn_struct_cwd(ctx,
+					server_event_context(),
+					server_messaging_context(),
+					&conn, snum,
+					lp_pathname(talloc_tos(), snum), NULL, &oldpath);
 	if (!NT_STATUS_IS_OK(status)) {
 		TALLOC_FREE(pdp);
 		return status;
@@ -1173,11 +1232,11 @@ static bool junction_to_local_path(const struct junction_map *jucn,
 	if(snum < 0) {
 		return False;
 	}
-	status = create_conn_struct(talloc_tos(),
-				    server_event_context(),
-				    server_messaging_context(),
-				    conn_out,
-				    snum, lp_pathname(talloc_tos(), snum), NULL, oldpath);
+	status = create_conn_struct_cwd(talloc_tos(),
+					server_event_context(),
+					server_messaging_context(),
+					conn_out,
+					snum, lp_pathname(talloc_tos(), snum), NULL, oldpath);
 	if (!NT_STATUS_IS_OK(status)) {
 		return False;
 	}
@@ -1338,11 +1397,11 @@ static int count_dfs_links(TALLOC_CTX *ctx, int snum)
 	 * Fake up a connection struct for the VFS layer.
 	 */
 
-	status = create_conn_struct(talloc_tos(),
-				    server_event_context(),
-				    server_messaging_context(),
-				    &conn,
-				    snum, connect_path, NULL, &cwd);
+	status = create_conn_struct_cwd(talloc_tos(),
+					server_event_context(),
+					server_messaging_context(),
+					&conn,
+					snum, connect_path, NULL, &cwd);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(3, ("create_conn_struct failed: %s\n",
 			  nt_errstr(status)));
@@ -1414,11 +1473,11 @@ static int form_junctions(TALLOC_CTX *ctx,
 	 * Fake up a connection struct for the VFS layer.
 	 */
 
-	status = create_conn_struct(ctx,
-				    server_event_context(),
-				    server_messaging_context(),
-				    &conn, snum, connect_path, NULL,
-				    &cwd);
+	status = create_conn_struct_cwd(ctx,
+					server_event_context(),
+					server_messaging_context(),
+					&conn, snum, connect_path, NULL,
+					&cwd);
 	if (!NT_STATUS_IS_OK(status)) {
 		DEBUG(3, ("create_conn_struct failed: %s\n",
 			  nt_errstr(status)));
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index b4f4501..b89015b 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -495,8 +495,15 @@ NTSTATUS create_conn_struct(TALLOC_CTX *ctx,
 			    connection_struct **pconn,
 			    int snum,
 			    const char *path,
-			    const struct auth_session_info *session_info,
-			    char **poldcwd);
+			    const struct auth_session_info *session_info);
+NTSTATUS create_conn_struct_cwd(TALLOC_CTX *ctx,
+				struct tevent_context *ev,
+				struct messaging_context *msg,
+				connection_struct **pconn,
+				int snum,
+				const char *path,
+				const struct auth_session_info *session_info,
+				char **poldcwd);
 
 /* The following definitions come from smbd/negprot.c  */
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list