svn commit: samba r16892 - in trunk/source: include smbd torture

vlendec at samba.org vlendec at samba.org
Sun Jul 9 12:17:16 GMT 2006


Author: vlendec
Date: 2006-07-09 12:17:15 +0000 (Sun, 09 Jul 2006)
New Revision: 16892

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16892

Log:
When we want more flexibility in configuring Samba, I think that we need to
get rid of the global share array in loadparm.c. Even right now with
usershares this is a little awkward.

Step zero in a looong way there: This encapsulates the service number in
connection_struct into a 'struct share_params'. I want to get rid of the use
of anything like an index number for a share outside of loadparm.c. Inside
loadparm.c it can be organized as an array if necessary, but the rest of Samba
should only see share names and struct share_params where we can then hide the
current share definitions or some dynamic backend or whatever.

Does this sound like a reasonable plan?

Volker

Modified:
   trunk/source/include/smb.h
   trunk/source/include/smb_macros.h
   trunk/source/smbd/conn.c
   trunk/source/smbd/msdfs.c
   trunk/source/smbd/open.c
   trunk/source/smbd/posix_acls.c
   trunk/source/smbd/service.c
   trunk/source/smbd/uid.c
   trunk/source/torture/cmd_vfs.c


Changeset:
Modified: trunk/source/include/smb.h
===================================================================
--- trunk/source/include/smb.h	2006-07-09 09:57:05 UTC (rev 16891)
+++ trunk/source/include/smb.h	2006-07-09 12:17:15 UTC (rev 16892)
@@ -540,11 +540,15 @@
 
 struct dptr_struct;
 
+struct share_params {
+	int service;
+};
+
 typedef struct connection_struct {
 	struct connection_struct *next, *prev;
 	TALLOC_CTX *mem_ctx;
 	unsigned cnum; /* an index passed over the wire */
-	int service;
+	struct share_params *params;
 	BOOL force_user;
 	BOOL force_group;
 	struct vuid_cache vuid_cache;

Modified: trunk/source/include/smb_macros.h
===================================================================
--- trunk/source/include/smb_macros.h	2006-07-09 09:57:05 UTC (rev 16891)
+++ trunk/source/include/smb_macros.h	2006-07-09 12:17:15 UTC (rev 16892)
@@ -124,7 +124,7 @@
 /* the service number for the [globals] defaults */ 
 #define GLOBAL_SECTION_SNUM	(-1)
 /* translates a connection number into a service number */
-#define SNUM(conn)         	((conn)?(conn)->service:GLOBAL_SECTION_SNUM)
+#define SNUM(conn)         	((conn)?(conn)->params->service:GLOBAL_SECTION_SNUM)
 
 
 /* access various service details */
@@ -135,10 +135,10 @@
 #define GUEST_OK(snum)     (VALID_SNUM(snum) && lp_guest_ok(snum))
 #define GUEST_ONLY(snum)   (VALID_SNUM(snum) && lp_guest_only(snum))
 #define CAN_SETDIR(snum)   (!lp_no_set_dir(snum))
-#define CAN_PRINT(conn)    ((conn) && lp_print_ok((conn)->service))
-#define MAP_HIDDEN(conn)   ((conn) && lp_map_hidden((conn)->service))
-#define MAP_SYSTEM(conn)   ((conn) && lp_map_system((conn)->service))
-#define MAP_ARCHIVE(conn)   ((conn) && lp_map_archive((conn)->service))
+#define CAN_PRINT(conn)    ((conn) && lp_print_ok(SNUM(conn)))
+#define MAP_HIDDEN(conn)   ((conn) && lp_map_hidden(SNUM(conn)))
+#define MAP_SYSTEM(conn)   ((conn) && lp_map_system(SNUM(conn)))
+#define MAP_ARCHIVE(conn)   ((conn) && lp_map_archive(SNUM(conn)))
 #define IS_HIDDEN_PATH(conn,path)  ((conn) && is_in_path((path),(conn)->hide_list,(conn)->case_sensitive))
 #define IS_VETO_PATH(conn,path)  ((conn) && is_in_path((path),(conn)->veto_list,(conn)->case_sensitive))
 #define IS_VETO_OPLOCK_PATH(conn,path)  ((conn) && is_in_path((path),(conn)->veto_oplock_list,(conn)->case_sensitive))

Modified: trunk/source/smbd/conn.c
===================================================================
--- trunk/source/smbd/conn.c	2006-07-09 09:57:05 UTC (rev 16891)
+++ trunk/source/smbd/conn.c	2006-07-09 12:17:15 UTC (rev 16892)
@@ -57,7 +57,7 @@
 {
 	connection_struct *conn;
 	for (conn=Connections;conn;conn=conn->next) {
-		if (conn->service == snum) {
+		if (conn->params->service == snum) {
 			return(True);
 		}
 	}
@@ -136,8 +136,10 @@
 		return NULL;
 	}
 
-	if ((conn=TALLOC_ZERO_P(mem_ctx, connection_struct))==NULL) {
+	if (!(conn=TALLOC_ZERO_P(mem_ctx, connection_struct)) ||
+	    !(conn->params = TALLOC_P(mem_ctx, struct share_params))) {
 		DEBUG(0,("talloc_zero() failed!\n"));
+		TALLOC_FREE(mem_ctx);
 		return NULL;
 	}
 	conn->mem_ctx = mem_ctx;
@@ -314,7 +316,7 @@
 
 	for (conn=Connections;conn;conn=next) {
 		next=conn->next;
-		if (strequal(lp_servicename(conn->service), sharename)) {
+		if (strequal(lp_servicename(SNUM(conn)), sharename)) {
 			DEBUG(1,("Forcing close of share %s cnum=%d\n",
 				 sharename, conn->cnum));
 			close_cnum(conn, (uint16)-1);

Modified: trunk/source/smbd/msdfs.c
===================================================================
--- trunk/source/smbd/msdfs.c	2006-07-09 09:57:05 UTC (rev 16891)
+++ trunk/source/smbd/msdfs.c	2006-07-09 12:17:15 UTC (rev 16892)
@@ -135,7 +135,6 @@
 
 	ZERO_STRUCTP(conn);
 
-	conn->service = snum;
 	pstrcpy(connpath, path);
 	pstring_sub(connpath , "%S", lp_servicename(snum));
 
@@ -145,7 +144,14 @@
                 DEBUG(0,("talloc_init(connection_struct) failed!\n"));
                 return False;
         }
+
+	if (!(conn->params = TALLOC_P(conn->mem_ctx, struct share_params))) {
+		DEBUG(0, ("TALLOC failed\n"));
+		return False;
+	}
 	
+	conn->params->service = snum;
+	
 	set_conn_connectpath(conn, connpath);
 
 	if (!smbd_vfs_init(conn)) {

Modified: trunk/source/smbd/open.c
===================================================================
--- trunk/source/smbd/open.c	2006-07-09 09:57:05 UTC (rev 16891)
+++ trunk/source/smbd/open.c	2006-07-09 12:17:15 UTC (rev 16892)
@@ -1472,7 +1472,7 @@
 
 				/* this is a hack to speed up torture tests
 				   in 'make test' */
-				timeout_usecs = lp_parm_int(conn->service,
+				timeout_usecs = lp_parm_int(SNUM(conn),
 							    "smbd","sharedelay",
 							    SHARING_VIOLATION_USEC_WAIT);
 

Modified: trunk/source/smbd/posix_acls.c
===================================================================
--- trunk/source/smbd/posix_acls.c	2006-07-09 09:57:05 UTC (rev 16891)
+++ trunk/source/smbd/posix_acls.c	2006-07-09 12:17:15 UTC (rev 16892)
@@ -4235,12 +4235,19 @@
 	pstring filename;
 	
 	ZERO_STRUCT( conn );
-	conn.service = -1;
 	
 	if ( !(conn.mem_ctx = talloc_init( "novfs_get_nt_acl" )) ) {
 		DEBUG(0,("get_nt_acl_no_snum: talloc() failed!\n"));
 		return NULL;
 	}
+
+	if (!(conn.params = TALLOC_P(conn.mem_ctx, struct share_params))) {
+		DEBUG(0,("get_nt_acl_no_snum: talloc() failed!\n"));
+		TALLOC_FREE(conn.mem_ctx);
+		return NULL;
+	}
+
+	conn.params->service = -1;
 	
 	pstrcpy( path, "/" );
 	set_conn_connectpath(&conn, path);

Modified: trunk/source/smbd/service.c
===================================================================
--- trunk/source/smbd/service.c	2006-07-09 09:57:05 UTC (rev 16891)
+++ trunk/source/smbd/service.c	2006-07-09 12:17:15 UTC (rev 16892)
@@ -623,7 +623,7 @@
 		    sizeof(conn->client_address)-1);
 	conn->num_files_open = 0;
 	conn->lastused = conn->lastused_count = time(NULL);
-	conn->service = snum;
+	conn->params->service = snum;
 	conn->used = True;
 	conn->printer = (strncmp(dev,"LPT",3) == 0);
 	conn->ipc = ( (strncmp(dev,"IPC",3) == 0) ||
@@ -649,7 +649,7 @@
 	string_set(&conn->dirpath,"");
 	string_set(&conn->user,user);
 
-	conn->read_only = lp_readonly(conn->service);
+	conn->read_only = lp_readonly(SNUM(conn));
 	conn->admin_user = False;
 
 	/*

Modified: trunk/source/smbd/uid.c
===================================================================
--- trunk/source/smbd/uid.c	2006-07-09 09:57:05 UTC (rev 16891)
+++ trunk/source/smbd/uid.c	2006-07-09 12:17:15 UTC (rev 16892)
@@ -102,7 +102,7 @@
 
 	readonly_share = is_share_read_only_for_token(vuser->user.unix_name,
 						      vuser->nt_user_token,
-						      conn->service);
+						      SNUM(conn));
 
 	if (!readonly_share &&
 	    !share_access_check(conn, snum, vuser, FILE_WRITE_DATA)) {
@@ -129,7 +129,7 @@
 
 	ent->admin_user = token_contains_name_in_list(
 		vuser->user.unix_name, NULL, vuser->nt_user_token,
-		lp_admin_users(conn->service));
+		lp_admin_users(SNUM(conn)));
 
 	conn->read_only = ent->read_only;
 	conn->admin_user = ent->admin_user;

Modified: trunk/source/torture/cmd_vfs.c
===================================================================
--- trunk/source/torture/cmd_vfs.c	2006-07-09 09:57:05 UTC (rev 16891)
+++ trunk/source/torture/cmd_vfs.c	2006-07-09 12:17:15 UTC (rev 16892)
@@ -94,7 +94,7 @@
 
 static NTSTATUS cmd_connect(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
 {
-	SMB_VFS_CONNECT(vfs->conn, lp_servicename(vfs->conn->service), "vfstest");
+	SMB_VFS_CONNECT(vfs->conn, lp_servicename(SNUM(vfs->conn)), "vfstest");
 	return NT_STATUS_OK;
 }
 



More information about the samba-cvs mailing list