[SCM] Samba Shared Repository - branch master updated - f340ed1348ca5f514dcd85a273559ecb9ff1615f

Volker Lendecke vlendec at samba.org
Mon Nov 24 10:34:37 GMT 2008


The branch, master has been updated
       via  f340ed1348ca5f514dcd85a273559ecb9ff1615f (commit)
       via  907f126d3e84b7acddf70f8da12010d6b22d8e99 (commit)
       via  6f840dd678f8f19b84c042816e75e85d1077904e (commit)
       via  c25f5c778acd7918551a6234d749854a0e8ea562 (commit)
       via  cb4f8573ba5fe7164be8adee8af7fbec9ec18ab0 (commit)
       via  783ab0480b7c1454a95cdb414d3277a8fa543e9a (commit)
      from  798b9e1ad6bbdcf873285d0e1c5008e566744162 (commit)

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


- Log -----------------------------------------------------------------
commit f340ed1348ca5f514dcd85a273559ecb9ff1615f
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Nov 24 08:56:46 2008 +0100

    Fix nonempty blank lines

commit 907f126d3e84b7acddf70f8da12010d6b22d8e99
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Nov 23 23:48:17 2008 +0100

    Get rid of pipes_struct->pipe_user, we have server_info now --- YESSS!

commit 6f840dd678f8f19b84c042816e75e85d1077904e
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Nov 23 23:14:39 2008 +0100

    Remove unused make_connection_with_chdir()

commit c25f5c778acd7918551a6234d749854a0e8ea562
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Nov 23 23:13:11 2008 +0100

    Convert delete_driver_files to use create_conn_struct
    
    Jerry, please check!

commit cb4f8573ba5fe7164be8adee8af7fbec9ec18ab0
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Nov 23 23:01:24 2008 +0100

    Convert get_correct_cversion to use create_conn_struct
    
    Jerry, please check!

commit 783ab0480b7c1454a95cdb414d3277a8fa543e9a
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Nov 23 22:46:08 2008 +0100

    Convert move_driver_to_download_area to use create_conn_struct
    
    This removes a use of struct current_user and the vuid
    
    The become_user() here is unnecessary, within the spoolss handling code we have
    switched to the authenticated pipe user anyway.
    
    Jerry, please check!

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

Summary of changes:
 source3/include/ntdomain.h           |   40 +++----
 source3/include/proto.h              |   20 ++--
 source3/printing/nt_printing.c       |  213 +++++++++++++++++-----------------
 source3/rpc_server/srv_dfs_nt.c      |    4 +-
 source3/rpc_server/srv_eventlog_nt.c |    4 +-
 source3/rpc_server/srv_lsa_nt.c      |   42 ++++---
 source3/rpc_server/srv_ntsvcs_nt.c   |    3 +-
 source3/rpc_server/srv_pipe.c        |   50 +--------
 source3/rpc_server/srv_pipe_hnd.c    |   10 --
 source3/rpc_server/srv_samr_nt.c     |   74 ++++++------
 source3/rpc_server/srv_spoolss_nt.c  |   56 +++++----
 source3/rpc_server/srv_srvsvc_nt.c   |   48 +++-----
 source3/rpc_server/srv_svcctl_nt.c   |   20 ++-
 source3/rpc_server/srv_winreg_nt.c   |   10 +-
 source3/rpc_server/srv_wkssvc_nt.c   |    4 +-
 source3/smbd/service.c               |   32 -----
 source3/smbd/uid.c                   |    6 +-
 17 files changed, 272 insertions(+), 364 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h
index e6c97c6..cc99ad7 100644
--- a/source3/include/ntdomain.h
+++ b/source3/include/ntdomain.h
@@ -5,17 +5,17 @@
    Copyright (C) Luke Kenneth Casson Leighton 1996-1997
    Copyright (C) Paul Ashton 1997
    Copyright (C) Jeremy Allison 2000-2004
-   
+
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -27,7 +27,7 @@
  * A bunch of stuff that was put into smb.h
  * in the NTDOM branch - it didn't belong there.
  */
- 
+
 typedef struct _prs_struct {
 	bool io; /* parsing in or out of data stream */
 	/* 
@@ -138,7 +138,7 @@ struct dcinfo {
 	struct netr_Credential seed_chal;
 	struct netr_Credential clnt_chal; /* Client credential */
 	struct netr_Credential srv_chal;  /* Server credential */
- 
+
 	unsigned char  sess_key[16]; /* Session key - 8 bytes followed by 8 zero bytes */
 	unsigned char  mach_pw[16];   /* md4(machine password) */
 
@@ -154,13 +154,13 @@ struct dcinfo {
 typedef struct pipe_rpc_fns {
 
 	struct pipe_rpc_fns *next, *prev;
-	
+
 	/* RPC function table associated with the current rpc_bind (associated by context) */
-	
+
 	const struct api_struct *cmds;
 	int n_cmds;
 	uint32 context_id;
-	
+
 } PIPE_RPC_FNS;
 
 /*
@@ -217,12 +217,12 @@ typedef struct pipes_struct {
 
 	fstring name;
 	fstring pipe_srv_name;
-	
+
 	/* linked list of rpc dispatch tables associated 
 	   with the open rpc contexts */
-	   
+
 	PIPE_RPC_FNS *contexts;
-	
+
 	RPC_HDR hdr; /* Incoming RPC header. */
 	RPC_HDR_REQ hdr_req; /* Incoming request header. */
 
@@ -231,21 +231,15 @@ typedef struct pipes_struct {
 	struct dcinfo *dc; /* Keeps the creds data from netlogon. */
 
 	/*
-	 * Unix user name and credentials used when a pipe is authenticated.
-	 */
-
-	struct current_user pipe_user;
- 
-	/*
 	 * Set to true when an RPC bind has been done on this pipe.
 	 */
-	
+
 	bool pipe_bound;
-	
+
 	/*
 	 * Set to true when we should return fault PDU's for everything.
 	 */
-	
+
 	bool fault_state;
 
 	/*
@@ -259,13 +253,13 @@ typedef struct pipes_struct {
 	 */
 
 	bool rng_fault_state;
-	
+
 	/*
 	 * Set to RPC_BIG_ENDIAN when dealing with big-endian PDU's
 	 */
-	
+
 	bool endian;
-	
+
 	/*
 	 * Struct to deal with multiple pdu inputs.
 	 */
diff --git a/source3/include/proto.h b/source3/include/proto.h
index a024d68..a026723 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -4773,10 +4773,12 @@ bool delete_a_form(nt_forms_struct **list, UNISTR2 *del_name, int *count, WERROR
 void update_a_form(nt_forms_struct **list, const FORM *form, int count);
 int get_ntdrivers(fstring **list, const char *architecture, uint32 version);
 const char *get_short_archi(const char *long_archi);
-WERROR clean_up_driver_struct(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
-							  uint32 level, struct current_user *user);
-WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract, uint32 level, 
-				  struct current_user *user, WERROR *perr);
+WERROR clean_up_driver_struct(struct pipes_struct *rpc_pipe,
+			      NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
+			      uint32 level);
+WERROR move_driver_to_download_area(struct pipes_struct *p,
+				    NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
+				    uint32 level, WERROR *perr);
 int pack_devicemode(NT_DEVICEMODE *nt_devmode, uint8 *buf, int buflen);
 uint32 del_a_printer(const char *sharename);
 NT_DEVICEMODE *construct_nt_devicemode(const fstring default_devicename);
@@ -4819,8 +4821,9 @@ WERROR get_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32 level,
 uint32 free_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level);
 bool printer_driver_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3 );
 bool printer_driver_files_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info );
-WERROR delete_printer_driver( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3, struct current_user *user,
-                              uint32 version, bool delete_files );
+WERROR delete_printer_driver(struct pipes_struct *rpc_pipe,
+			     NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3,
+			     uint32 version, bool delete_files );
 WERROR nt_printing_setsec(const char *sharename, SEC_DESC_BUF *secdesc_ctr);
 bool nt_printing_getsec(TALLOC_CTX *ctx, const char *sharename, SEC_DESC_BUF **secdesc_ctr);
 void map_printer_permissions(SEC_DESC *sd);
@@ -6963,7 +6966,6 @@ bool api_pipe_alter_context(pipes_struct *p, prs_struct *rpc_in_p);
 bool api_pipe_ntlmssp_auth_process(pipes_struct *p, prs_struct *rpc_in,
 					uint32 *p_ss_padding_len, NTSTATUS *pstatus);
 bool api_pipe_schannel_process(pipes_struct *p, prs_struct *rpc_in, uint32 *p_ss_padding_len);
-struct current_user *get_current_user(struct current_user *user, pipes_struct *p);
 void free_pipe_rpc_context( PIPE_RPC_FNS *list );
 bool api_pipe_request(pipes_struct *p);
 
@@ -8419,10 +8421,6 @@ bool set_current_service(connection_struct *conn, uint16 flags, bool do_chdir);
 void load_registry_shares(void);
 int add_home_service(const char *service, const char *username, const char *homedir);
 int find_service(fstring service);
-connection_struct *make_connection_with_chdir(const char *service_in,
-					      DATA_BLOB password, 
-					      const char *dev, uint16 vuid,
-					      NTSTATUS *status);
 connection_struct *make_connection(const char *service_in, DATA_BLOB password, 
 				   const char *pdev, uint16 vuid,
 				   NTSTATUS *status);
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 1137027..244b3ae 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -1454,18 +1454,21 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr
 /****************************************************************************
 Determine the correct cVersion associated with an architecture and driver
 ****************************************************************************/
-static uint32 get_correct_cversion(const char *architecture, fstring driverpath_in,
-				   struct current_user *user, WERROR *perr)
+static uint32 get_correct_cversion(struct pipes_struct *p,
+				   const char *architecture,
+				   fstring driverpath_in,
+				   WERROR *perr)
 {
 	int               cversion;
 	NTSTATUS          nt_status;
  	char *driverpath = NULL;
-	DATA_BLOB         null_pw;
-	fstring           res_type;
 	files_struct      *fsp = NULL;
 	SMB_STRUCT_STAT   st;
-	connection_struct *conn;
+	connection_struct *conn = NULL;
 	NTSTATUS status;
+	char *oldcwd;
+	fstring printdollar;
+	int printdollar_snum;
 
 	SET_STAT_INVALID(st);
 
@@ -1485,28 +1488,21 @@ static uint32 get_correct_cversion(const char *architecture, fstring driverpath_
 		return 3;
 	}
 
-	/*
-	 * Connect to the print$ share under the same account as the user connected
-	 * to the rpc pipe. Note we must still be root to do this.
-	 */
-
-	/* Null password is ok - we are already an authenticated user... */
-	null_pw = data_blob_null;
-	fstrcpy(res_type, "A:");
- 	become_root();
-	conn = make_connection_with_chdir("print$", null_pw, res_type, user->vuid, &nt_status);
-	unbecome_root();
+	fstrcpy(printdollar, "print$");
 
-	if (conn == NULL) {
-		DEBUG(0,("get_correct_cversion: Unable to connect\n"));
-		*perr = ntstatus_to_werror(nt_status);
+	printdollar_snum = find_service(printdollar);
+	if (printdollar_snum == -1) {
+		*perr = WERR_NO_SUCH_SHARE;
 		return -1;
 	}
 
-	/* We are temporarily becoming the connection user. */
-	if (!become_user(conn, user->vuid)) {
-		DEBUG(0,("get_correct_cversion: Can't become user!\n"));
-		*perr = WERR_ACCESS_DENIED;
+	nt_status = create_conn_struct(talloc_tos(), &conn, printdollar_snum,
+				       lp_pathname(printdollar_snum),
+				       p->server_info, &oldcwd);
+	if (!NT_STATUS_IS_OK(nt_status)) {
+		DEBUG(0,("get_correct_cversion: create_conn_struct "
+			 "returned %s\n", nt_errstr(nt_status)));
+		*perr = ntstatus_to_werror(nt_status);
 		return -1;
 	}
 
@@ -1583,27 +1579,28 @@ static uint32 get_correct_cversion(const char *architecture, fstring driverpath_
 	DEBUG(10,("get_correct_cversion: Driver file [%s] cversion = %d\n",
 		driverpath, cversion));
 
-	close_file(NULL, fsp, NORMAL_CLOSE);
-	close_cnum(conn, user->vuid);
-	unbecome_user();
-	*perr = WERR_OK;
-	return cversion;
-
-
-  error_exit:
+	goto done;
 
-	if(fsp)
+ error_exit:
+	cversion = -1;
+ done:
+	if (fsp != NULL) {
 		close_file(NULL, fsp, NORMAL_CLOSE);
-
-	close_cnum(conn, user->vuid);
-	unbecome_user();
-	return -1;
+	}
+	if (conn != NULL) {
+		vfs_ChDir(conn, oldcwd);
+		conn_free_internal(conn);
+	}
+	if (cversion != -1) {
+		*perr = WERR_OK;
+	}
+	return cversion;
 }
 
 /****************************************************************************
 ****************************************************************************/
-static WERROR clean_up_driver_struct_level_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 *driver,
-											 struct current_user *user)
+static WERROR clean_up_driver_struct_level_3(struct pipes_struct *rpc_pipe,
+					     NT_PRINTER_DRIVER_INFO_LEVEL_3 *driver)
 {
 	const char *architecture;
 	fstring new_name;
@@ -1661,7 +1658,9 @@ static WERROR clean_up_driver_struct_level_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 *dri
 	 *	NT 4: cversion=2
 	 *	NT2K: cversion=3
 	 */
-	if ((driver->cversion = get_correct_cversion( architecture, driver->driverpath, user, &err)) == -1)
+	if ((driver->cversion = get_correct_cversion(rpc_pipe, architecture,
+						     driver->driverpath,
+						     &err)) == -1)
 		return err;
 
 	return WERR_OK;
@@ -1669,7 +1668,8 @@ static WERROR clean_up_driver_struct_level_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 *dri
 	
 /****************************************************************************
 ****************************************************************************/
-static WERROR clean_up_driver_struct_level_6(NT_PRINTER_DRIVER_INFO_LEVEL_6 *driver, struct current_user *user)
+static WERROR clean_up_driver_struct_level_6(struct pipes_struct *rpc_pipe,
+					     NT_PRINTER_DRIVER_INFO_LEVEL_6 *driver)
 {
 	const char *architecture;
 	fstring new_name;
@@ -1728,7 +1728,9 @@ static WERROR clean_up_driver_struct_level_6(NT_PRINTER_DRIVER_INFO_LEVEL_6 *dri
 	 *	NT2K: cversion=3
 	 */
 
-	if ((driver->version = get_correct_cversion(architecture, driver->driverpath, user, &err)) == -1)
+	if ((driver->version = get_correct_cversion(rpc_pipe, architecture,
+						    driver->driverpath,
+						    &err)) == -1)
 			return err;
 
 	return WERR_OK;
@@ -1736,21 +1738,24 @@ static WERROR clean_up_driver_struct_level_6(NT_PRINTER_DRIVER_INFO_LEVEL_6 *dri
 
 /****************************************************************************
 ****************************************************************************/
-WERROR clean_up_driver_struct(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
-							  uint32 level, struct current_user *user)
+WERROR clean_up_driver_struct(struct pipes_struct *rpc_pipe,
+			      NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
+			      uint32 level)
 {
 	switch (level) {
 		case 3:
 		{
 			NT_PRINTER_DRIVER_INFO_LEVEL_3 *driver;
 			driver=driver_abstract.info_3;
-			return clean_up_driver_struct_level_3(driver, user);
+			return clean_up_driver_struct_level_3(rpc_pipe,
+							      driver);
 		}
 		case 6:
 		{
 			NT_PRINTER_DRIVER_INFO_LEVEL_6 *driver;
 			driver=driver_abstract.info_6;
-			return clean_up_driver_struct_level_6(driver, user);
+			return clean_up_driver_struct_level_6(rpc_pipe,
+							      driver);
 		}
 		default:
 			return WERR_INVALID_PARAM;
@@ -1796,8 +1801,9 @@ static char* ffmt(unsigned char *c){
 
 /****************************************************************************
 ****************************************************************************/
-WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract, uint32 level, 
-				  struct current_user *user, WERROR *perr)
+WERROR move_driver_to_download_area(struct pipes_struct *p,
+				    NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
+				    uint32 level, WERROR *perr)
 {
 	NT_PRINTER_DRIVER_INFO_LEVEL_3 *driver;
 	NT_PRINTER_DRIVER_INFO_LEVEL_3 converted_driver;
@@ -1805,14 +1811,15 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract
 	char *new_dir = NULL;
 	char *old_name = NULL;
 	char *new_name = NULL;
-	DATA_BLOB null_pw;
-	connection_struct *conn;
+	connection_struct *conn = NULL;
 	NTSTATUS nt_status;
-	fstring res_type;
 	SMB_STRUCT_STAT st;
 	int i;
 	TALLOC_CTX *ctx = talloc_tos();
 	int ver = 0;
+	char *oldcwd;
+	fstring printdollar;
+	int printdollar_snum;
 
 	*perr = WERR_OK;
 
@@ -1831,38 +1838,24 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract
 		return WERR_UNKNOWN_PRINTER_DRIVER;
 	}
 
-	/*
-	 * Connect to the print$ share under the same account as the user connected to the rpc pipe.
-	 * Note we must be root to do this.
-	 */
-
-	null_pw = data_blob_null;
-	fstrcpy(res_type, "A:");
-	become_root();
-	conn = make_connection_with_chdir("print$", null_pw, res_type, user->vuid, &nt_status);
-	unbecome_root();
+	fstrcpy(printdollar, "print$");
 
-	if (conn == NULL) {
-		DEBUG(0,("move_driver_to_download_area: Unable to connect\n"));
-		*perr = ntstatus_to_werror(nt_status);
+	printdollar_snum = find_service(printdollar);
+	if (printdollar_snum == -1) {
+		*perr = WERR_NO_SUCH_SHARE;
 		return WERR_NO_SUCH_SHARE;
 	}
 
-	/*
-	 * Save who we are - we are temporarily becoming the connection user.
-	 */
-
-	if (!become_user(conn, conn->vuid)) {
-		DEBUG(0,("move_driver_to_download_area: Can't become user!\n"));
-		return WERR_ACCESS_DENIED;
+	nt_status = create_conn_struct(talloc_tos(), &conn, printdollar_snum,
+				       lp_pathname(printdollar_snum),
+				       p->server_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)));
+		*perr = ntstatus_to_werror(nt_status);
+		return *perr;
 	}
 
-	/* WE ARE NOW RUNNING AS USER conn->vuid !!!!! */
-
-	/*
-	 * make the directories version and version\driver_name
-	 * under the architecture directory.
-	 */
 	DEBUG(5,("Creating first directory\n"));
 	new_dir = talloc_asprintf(ctx,
 				"%s/%d",
@@ -2092,8 +2085,10 @@ WERROR move_driver_to_download_area(NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract
 
   err_exit:
 
-	close_cnum(conn, user->vuid);
-	unbecome_user();
+	if (conn != NULL) {
+		vfs_ChDir(conn, oldcwd);
+		conn_free_internal(conn);
+	}
 
 	if (W_ERROR_EQUAL(*perr, WERR_OK)) {
 		return WERR_OK;
@@ -5201,49 +5196,44 @@ bool printer_driver_files_in_use ( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info )
   this.
 ****************************************************************************/
 
-static bool delete_driver_files( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3, struct current_user *user )
+static bool delete_driver_files(struct pipes_struct *rpc_pipe,
+				NT_PRINTER_DRIVER_INFO_LEVEL_3 *info_3)
 {
 	int i = 0;
 	char *s;
 	const char *file;
 	connection_struct *conn;
-	DATA_BLOB null_pw;
 	NTSTATUS nt_status;
-	fstring res_type;
 	SMB_STRUCT_STAT  st;
+	char *oldcwd;
+	fstring printdollar;
+	int printdollar_snum;
+	bool ret = false;
 
 	if ( !info_3 )
 		return False;
 
 	DEBUG(6,("delete_driver_files: deleting driver [%s] - version [%d]\n", info_3->name, info_3->cversion));
 
-	/*
-	 * Connect to the print$ share under the same account as the
-	 * user connected to the rpc pipe. Note we must be root to
-	 * do this.
-	 */
+	fstrcpy(printdollar, "print$");
 
-	null_pw = data_blob_null;
-	fstrcpy(res_type, "A:");
-	become_root();
-        conn = make_connection_with_chdir( "print$", null_pw, res_type, user->vuid, &nt_status );
-	unbecome_root();
+	printdollar_snum = find_service(printdollar);
+	if (printdollar_snum == -1) {
+		return false;
+	}
 
-	if ( !conn ) {
-		DEBUG(0,("delete_driver_files: Unable to connect\n"));
-		return False;
+	nt_status = create_conn_struct(talloc_tos(), &conn, printdollar_snum,
+				       lp_pathname(printdollar_snum),
+				       rpc_pipe->server_info, &oldcwd);
+	if (!NT_STATUS_IS_OK(nt_status)) {
+		DEBUG(0,("delete_driver_files: create_conn_struct "
+			 "returned %s\n", nt_errstr(nt_status)));
+		return false;
 	}
 
 	if ( !CAN_WRITE(conn) ) {
 		DEBUG(3,("delete_driver_files: Cannot delete print driver when [print$] is read-only\n"));
-		return False;
-	}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list