Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
damn, I had implicitly assumed signed characters when writing the
[rsync/rsync.git]
/
main.c
diff --git
a/main.c
b/main.c
index
930f823
..
936fdb9
100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-47,6
+47,8
@@
int one_file_system=0;
int remote_version=0;
int sparse_files=0;
int do_compression=0;
int remote_version=0;
int sparse_files=0;
int do_compression=0;
+int am_root=0;
+int orig_umask=0;
extern int csum_length;
extern int csum_length;
@@
-174,11
+176,20
@@
int do_cmd(char *cmd,char *machine,char *user,char *path,int *f_in,int *f_out)
args[argc++] = tok;
}
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;
if (user) {
args[argc++] = "-l";
args[argc++] = user;
}
args[argc++] = machine;
+#endif
}
args[argc++] = rsync_path;
}
args[argc++] = rsync_path;
@@
-190,7
+201,10
@@
int do_cmd(char *cmd,char *machine,char *user,char *path,int *f_in,int *f_out)
p = strrchr(dir,'/');
if (p) {
*p = 0;
p = strrchr(dir,'/');
if (p) {
*p = 0;
- args[argc++] = dir;
+ if (!dir[0])
+ args[argc++] = "/";
+ else
+ args[argc++] = dir;
p++;
} else {
args[argc++] = ".";
p++;
} else {
args[argc++] = ".";
@@
-244,7
+258,7
@@
static char *get_local_name(struct file_list *flist,char *name)
if (!name)
return NULL;
if (!name)
return NULL;
- if (mkdir(name,0777) != 0) {
+ if (mkdir(name,0777
& ~orig_umask
) != 0) {
fprintf(FERROR,"mkdir %s : %s\n",name,strerror(errno));
exit_cleanup(1);
} else {
fprintf(FERROR,"mkdir %s : %s\n",name,strerror(errno));
exit_cleanup(1);
} else {
@@
-280,6
+294,8
@@
void do_server_sender(int argc,char *argv[])
if (strcmp(dir,".")) {
int l = strlen(dir);
if (strcmp(dir,".")) {
int l = strlen(dir);
+ if (strcmp(dir,"/") == 0)
+ l = 0;
for (i=0;i<argc;i++)
argv[i] += l+1;
}
for (i=0;i<argc;i++)
argv[i] += l+1;
}
@@
-452,7
+468,7
@@
static struct option long_options[] = {
int main(int argc,char *argv[])
{
int main(int argc,char *argv[])
{
- int pid, status
, status2
;
+ int pid, status
= 0, status2 = 0
;
int opt;
int option_index;
char *shell_cmd = NULL;
int opt;
int option_index;
char *shell_cmd = NULL;
@@
-465,6
+481,11
@@
int main(int argc,char *argv[])
char *local_name = NULL;
starttime = time(NULL);
char *local_name = NULL;
starttime = time(NULL);
+ am_root = (getuid() == 0);
+
+ /* we set a 0 umask so that correct file permissions can be
+ carried across */
+ orig_umask = umask(0);
while ((opt = getopt_long(argc, argv,
short_options, long_options, &option_index))
while ((opt = getopt_long(argc, argv,
short_options, long_options, &option_index))
@@
-545,12
+566,7
@@
int main(int argc,char *argv[])
break;
case 'o':
break;
case 'o':
- if (getuid() == 0) {
- preserve_uid=1;
- } else {
- fprintf(FERROR,"-o only allowed for root\n");
- exit_cleanup(1);
- }
+ preserve_uid=1;
break;
case 'g':
break;
case 'g':
@@
-558,12
+574,7
@@
int main(int argc,char *argv[])
break;
case 'D':
break;
case 'D':
- if (getuid() == 0) {
- preserve_devices=1;
- } else {
- fprintf(FERROR,"-D only allowed for root\n");
- exit_cleanup(1);
- }
+ preserve_devices=1;
break;
case 't':
break;
case 't':
@@
-586,10
+597,10
@@
int main(int argc,char *argv[])
preserve_perms=1;
preserve_times=1;
preserve_gid=1;
preserve_perms=1;
preserve_times=1;
preserve_gid=1;
- if (
getuid() == 0
) {
+ if (
am_root
) {
preserve_devices=1;
preserve_uid=1;
preserve_devices=1;
preserve_uid=1;
- }
+ }
break;
case OPT_SERVER:
break;
case OPT_SERVER: