summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorLars Müller <lmuelle@samba.org>2005-06-15 14:24:11 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:57:16 -0500
commit7cbd740c62238406e64819e3594caeca341a25c9 (patch)
treeec18f0346ff0a19118ba0bcc155d0a1cc2eafe11 /source3/utils
parent95ce7e65eb325d64f821e87f479b4898e577bc75 (diff)
downloadsamba-7cbd740c62238406e64819e3594caeca341a25c9.tar.gz
samba-7cbd740c62238406e64819e3594caeca341a25c9.tar.bz2
samba-7cbd740c62238406e64819e3594caeca341a25c9.zip
r7609: 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 (This used to be commit 2c68568e5232c057d4f76f4bb044c54d18272602)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net.h1
-rw-r--r--source3/utils/net_rpc.c80
-rw-r--r--source3/utils/net_rpc_printer.c3
3 files changed, 57 insertions, 27 deletions
diff --git a/source3/utils/net.h b/source3/utils/net.h
index ebabf605dd..c67786cf9e 100644
--- a/source3/utils/net.h
+++ b/source3/utils/net.h
@@ -31,7 +31,6 @@ typedef struct copy_clistate {
struct cli_state *cli_share_src;
struct cli_state *cli_share_dst;
char *cwd;
- BOOL top_level_dir;
uint16 attribute;
int mode;
}copy_clistate;
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c
index 9d1eece9f7..614f19c803 100644
--- a/source3/utils/net_rpc.c
+++ b/source3/utils/net_rpc.c
@@ -2798,13 +2798,7 @@ static void copy_fn(const char *mnt, file_info *f, const char *mask, void *state
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 @@ static void copy_fn(const char *mnt, file_info *f, const char *mask, void *state
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 @@ static void copy_fn(const char *mnt, file_info *f, const char *mask, void *state
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, "\\*");
-
- 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;
-
+ /* 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;
+
return;
}
@@ -2877,7 +2868,7 @@ static void copy_fn(const char *mnt, file_info *f, const char *mask, void *state
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 @@ BOOL sync_files(struct copy_clistate *cp_clistate, pstring mask)
}
+/**
+ * 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 @@ rpc_share_migrate_files_internals(const DOM_SID *domain_sid, const char *domain_
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 @@ rpc_share_migrate_files_internals(const DOM_SID *domain_sid, const char *domain_
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 @@ rpc_share_migrate_files_internals(const DOM_SID *domain_sid, const char *domain_
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, "\\*");
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c
index 840688be9a..f1f82a5cea 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -292,8 +292,7 @@ static void display_reg_value(const char *subkey, REGISTRY_VALUE value)
*
* @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,