Commit 667e72a1 authored by Andrew Tridgell's avatar Andrew Tridgell

change the order of chmod and chown calls so that setuid bits don't

get removed by chown calls.
parent e1b3d5c4
...@@ -291,18 +291,6 @@ static int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st, ...@@ -291,18 +291,6 @@ static int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
} }
} }
#ifdef HAVE_CHMOD
if (preserve_perms && !S_ISLNK(st->st_mode) &&
st->st_mode != file->mode) {
updated = 1;
if (do_chmod(fname,file->mode) != 0) {
rprintf(FERROR,"failed to set permissions on %s : %s\n",
fname,strerror(errno));
return 0;
}
}
#endif
if ((am_root || !am_daemon) && if ((am_root || !am_daemon) &&
((am_root && preserve_uid && st->st_uid != file->uid) || ((am_root && preserve_uid && st->st_uid != file->uid) ||
(preserve_gid && st->st_gid != file->gid))) { (preserve_gid && st->st_gid != file->gid))) {
...@@ -311,14 +299,27 @@ static int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st, ...@@ -311,14 +299,27 @@ static int set_perms(char *fname,struct file_struct *file,STRUCT_STAT *st,
preserve_gid?file->gid:-1) != 0) { preserve_gid?file->gid:-1) != 0) {
if (preserve_uid && st->st_uid != file->uid) if (preserve_uid && st->st_uid != file->uid)
updated = 1; updated = 1;
if (verbose>1 || preserve_uid) if (verbose>1 || preserve_uid) {
rprintf(FERROR,"chown %s : %s\n", rprintf(FERROR,"chown %s : %s\n",
fname,strerror(errno)); fname,strerror(errno));
return updated; return 0;
}
} }
updated = 1; updated = 1;
} }
#ifdef HAVE_CHMOD
if (preserve_perms && !S_ISLNK(st->st_mode) &&
st->st_mode != file->mode) {
updated = 1;
if (do_chmod(fname,file->mode) != 0) {
rprintf(FERROR,"failed to set permissions on %s : %s\n",
fname,strerror(errno));
return 0;
}
}
#endif
if (verbose > 1 && report) { if (verbose > 1 && report) {
if (updated) if (updated)
rprintf(FINFO,"%s\n",fname); rprintf(FINFO,"%s\n",fname);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment