svn commit: samba r7609 - in branches/SAMBA_3_0/source/utils: .

lmuelle at samba.org lmuelle at samba.org
Wed Jun 15 14:24:12 GMT 2005


Author: lmuelle
Date: 2005-06-15 14:24:11 +0000 (Wed, 15 Jun 2005)
New Revision: 7609

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

Log:
Move top level dir handling in from of the loop.  This makes the code
much straither.

copy_top_level_perms() is jra's work.

I modified the copy_top_level_perms() function to use the copy_clistate.

And I don't forget trunk.

Lars

Modified:
   branches/SAMBA_3_0/source/utils/net.h
   branches/SAMBA_3_0/source/utils/net_rpc.c
   branches/SAMBA_3_0/source/utils/net_rpc_printer.c


Changeset:
Modified: branches/SAMBA_3_0/source/utils/net.h
===================================================================
--- branches/SAMBA_3_0/source/utils/net.h	2005-06-15 13:01:39 UTC (rev 7608)
+++ branches/SAMBA_3_0/source/utils/net.h	2005-06-15 14:24:11 UTC (rev 7609)
@@ -31,7 +31,6 @@
 	struct cli_state *cli_share_src;
 	struct cli_state *cli_share_dst;
 	char *cwd;
-	BOOL top_level_dir;
 	uint16 attribute;
 	int mode;
 }copy_clistate; 

Modified: branches/SAMBA_3_0/source/utils/net_rpc.c
===================================================================
--- branches/SAMBA_3_0/source/utils/net_rpc.c	2005-06-15 13:01:39 UTC (rev 7608)
+++ branches/SAMBA_3_0/source/utils/net_rpc.c	2005-06-15 14:24:11 UTC (rev 7609)
@@ -2798,13 +2798,7 @@
 	local_state = (struct copy_clistate *)state;
 	nt_status = NT_STATUS_UNSUCCESSFUL;
 
-	if (strequal(f->name, ".")) {
-		if (local_state->top_level_dir)
-			f->name[0] = '\0';
-		else
-			return;
-	}
-	if (strequal(f->name, ".."))
+	if (strequal(f->name, ".") || strequal(f->name, ".."))
 		return;
 
 	DEBUG(3,("got mask: %s, name: %s\n", mask, f->name));
@@ -2832,7 +2826,7 @@
 						  False);
 			break;
 		default:
-			DEBUG(0,( "Unsupported mode %d", local_state->mode));
+			d_printf("Unsupported mode %d\n", local_state->mode);
 			return;
 		}
 
@@ -2840,19 +2834,16 @@
 			printf("could not handle dir %s: %s\n", 
 				dir, nt_errstr(nt_status));
 
-		if (!local_state->top_level_dir) {
-			/* search below that directory */
-			fstrcpy(new_mask, dir);
-			fstrcat(new_mask, "\\*");
+		/* search below that directory */
+		fstrcpy(new_mask, dir);
+		fstrcat(new_mask, "\\*");
 
-			old_dir = local_state->cwd;
-                        local_state->cwd = dir;
-			if (!sync_files(local_state, new_mask))
-				printf("could not handle files\n");
-			local_state->cwd = old_dir;
-		} else
-			local_state->top_level_dir = False;
-			
+		old_dir = local_state->cwd;
+		local_state->cwd = dir;
+		if (!sync_files(local_state, new_mask))
+			printf("could not handle files\n");
+		local_state->cwd = old_dir;
+
 		return;
 	}
 
@@ -2877,7 +2868,7 @@
 					  True);
 		break;
 	default:
-		DEBUG(0,( "Unsupported file mode %d", local_state->mode));
+		d_printf("Unsupported file mode %d\n", local_state->mode);
 		return;
 	}
 
@@ -2911,6 +2902,43 @@
 }
 
 
+/**
+ * Set the top level directory permissions before we do any further copies.
+ * Should set up ACL inheritance.
+ **/
+
+BOOL copy_top_level_perms(struct copy_clistate *cp_clistate, 
+				const char *sharename)
+{
+	NTSTATUS nt_status;
+
+	switch (cp_clistate->mode) {
+	case NET_MODE_SHARE_MIGRATE:
+		DEBUG(3,("calling net_copy_fileattr for '.' directory in share %s\n", sharename));
+		nt_status = net_copy_fileattr(cp_clistate->mem_ctx,
+						cp_clistate->cli_share_src, 
+						cp_clistate->cli_share_dst,
+						"\\", "\\",
+						opt_acls? True : False, 
+						opt_attrs? True : False,
+						opt_timestamps? True: False,
+						False);
+		break;
+	default:
+		d_printf("Unsupported mode %d\n", cp_clistate->mode);
+		break;
+	}
+
+	if (!NT_STATUS_IS_OK(nt_status))  {
+		printf("Could handle directory attributes for top level directory of share %s. Error %s\n", 
+			sharename, nt_errstr(nt_status));
+		return False;
+	}
+
+	return True;
+}
+
+
 /** 
  * Sync all files inside a remote share to another share (over smb)
  *
@@ -3005,7 +3033,7 @@
 			printf("syncing");
 			break;
 		default:
-			DEBUG(0,("Unsupported mode %d", cp_clistate.mode));
+			d_printf("Unsupported mode %d\n", cp_clistate.mode);
 			break;
 		}
 		printf("    [%s] files and directories %s ACLs, %s DOS Attributes %s\n", 
@@ -3018,7 +3046,6 @@
 		cp_clistate.cli_share_src = NULL;
 		cp_clistate.cli_share_dst = NULL;
 		cp_clistate.cwd = NULL;
-		cp_clistate.top_level_dir = True;
 		cp_clistate.attribute = aSYSTEM | aHIDDEN | aDIR;
 
 	        /* open share source */
@@ -3040,6 +3067,11 @@
 			got_dst_share = True;
 		}
 
+		if (!copy_top_level_perms(&cp_clistate, netname)) {
+			d_printf("Could not handle the top level directory permissions for the share: %s\n", netname);
+			nt_status = NT_STATUS_UNSUCCESSFUL;
+			goto done;
+		}
 
 		/* now call the filesync */
 		pstrcpy(mask, "\\*");

Modified: branches/SAMBA_3_0/source/utils/net_rpc_printer.c
===================================================================
--- branches/SAMBA_3_0/source/utils/net_rpc_printer.c	2005-06-15 13:01:39 UTC (rev 7608)
+++ branches/SAMBA_3_0/source/utils/net_rpc_printer.c	2005-06-15 14:24:11 UTC (rev 7609)
@@ -292,8 +292,7 @@
  *
  * @return Normal NTSTATUS return.
  **/ 
-static NTSTATUS 
-net_copy_fileattr(TALLOC_CTX *mem_ctx,
+NTSTATUS net_copy_fileattr(TALLOC_CTX *mem_ctx,
 		  struct cli_state *cli_share_src,
 		  struct cli_state *cli_share_dst, 
 		  const char *src_name, const char *dst_name,



More information about the samba-cvs mailing list