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));
False);
break;
default:
- DEBUG(0,( "Unsupported mode %d", local_state->mode));
+ d_printf("Unsupported mode %d\n", local_state->mode);
return;
}
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;
}
True);
break;
default:
- DEBUG(0,( "Unsupported file mode %d", local_state->mode));
+ d_printf("Unsupported file mode %d\n", local_state->mode);
return;
}
}
+/**
+ * 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)
*
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",
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 */
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, "\\*");