X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/861c20b43d4d3b06ed3dbe0fd0195450e12e5274..6574b4f7d938a90a158ba31c03942f8170452df4:/main.c diff --git a/main.c b/main.c index 7cef4344..09e0ef33 100644 --- a/main.c +++ b/main.c @@ -47,6 +47,9 @@ int one_file_system=0; int remote_version=0; int sparse_files=0; int do_compression=0; +int am_root=0; +int orig_umask=0; +int relative_paths=0; extern int csum_length; @@ -132,6 +135,8 @@ static void server_options(char **args,int *argc) argstr[x++] = 'C'; if (ignore_times) argstr[x++] = 'I'; + if (relative_paths) + argstr[x++] = 'R'; if (one_file_system) argstr[x++] = 'x'; if (sparse_files) @@ -174,11 +179,20 @@ int do_cmd(char *cmd,char *machine,char *user,char *path,int *f_in,int *f_out) args[argc++] = tok; } +#if HAVE_REMSH + /* remsh (on HPUX) takes the arguments the other way around */ + args[argc++] = machine; + if (user) { + args[argc++] = "-l"; + args[argc++] = user; + } +#else if (user) { args[argc++] = "-l"; args[argc++] = user; } args[argc++] = machine; +#endif } args[argc++] = rsync_path; @@ -188,9 +202,12 @@ int do_cmd(char *cmd,char *machine,char *user,char *path,int *f_in,int *f_out) if (path && *path) { char *dir = strdup(path); p = strrchr(dir,'/'); - if (p) { + if (p && !relative_paths) { *p = 0; - args[argc++] = dir; + if (!dir[0]) + args[argc++] = "/"; + else + args[argc++] = dir; p++; } else { args[argc++] = "."; @@ -226,7 +243,7 @@ static char *get_local_name(struct file_list *flist,char *name) if (stat(name,&st) == 0) { if (S_ISDIR(st.st_mode)) { if (chdir(name) != 0) { - fprintf(FERROR,"chdir %s : %s\n",name,strerror(errno)); + fprintf(FERROR,"chdir %s : %s (1)\n",name,strerror(errno)); exit_cleanup(1); } return NULL; @@ -244,15 +261,15 @@ static char *get_local_name(struct file_list *flist,char *name) if (!name) return NULL; - if (mkdir(name,0777) != 0) { - fprintf(FERROR,"mkdir %s : %s\n",name,strerror(errno)); + if (mkdir(name,0777 & ~orig_umask) != 0) { + fprintf(FERROR,"mkdir %s : %s (1)\n",name,strerror(errno)); exit_cleanup(1); } else { fprintf(FINFO,"created directory %s\n",name); } if (chdir(name) != 0) { - fprintf(FERROR,"chdir %s : %s\n",name,strerror(errno)); + fprintf(FERROR,"chdir %s : %s (2)\n",name,strerror(errno)); exit_cleanup(1); } @@ -271,8 +288,8 @@ void do_server_sender(int argc,char *argv[]) if (verbose > 2) fprintf(FERROR,"server_sender starting pid=%d\n",(int)getpid()); - if (chdir(dir) != 0) { - fprintf(FERROR,"chdir %s: %s\n",dir,strerror(errno)); + if (!relative_paths && chdir(dir) != 0) { + fprintf(FERROR,"chdir %s: %s (3)\n",dir,strerror(errno)); exit_cleanup(1); } argc--; @@ -280,6 +297,8 @@ void do_server_sender(int argc,char *argv[]) if (strcmp(dir,".")) { int l = strlen(dir); + if (strcmp(dir,"/") == 0) + l = 0; for (i=0;i 3) fprintf(FERROR,"file list sent\n"); send_files(flist,f_out,f_in);