version 1.7, 2019/02/14 18:29:08 |
version 1.8, 2019/02/14 18:30:11 |
|
|
rsync_set_metadata(struct sess *sess, int newfile, |
rsync_set_metadata(struct sess *sess, int newfile, |
int fd, const struct flist *f, const char *path) |
int fd, const struct flist *f, const char *path) |
{ |
{ |
uid_t uid; |
uid_t uid = (uid_t)-1; |
gid_t gid; |
gid_t gid = (gid_t)-1; |
struct timespec tv[2]; |
struct timespec tv[2]; |
|
|
/* |
/* |
|
|
* group identifier. |
* group identifier. |
*/ |
*/ |
|
|
if (sess->opts->preserve_gids || |
if (getuid() == 0 && sess->opts->preserve_uids) |
sess->opts->preserve_uids) { |
uid = f->st.uid; |
uid = sess->opts->preserve_uids ? f->st.uid : -1; |
if (sess->opts->preserve_gids) |
gid = sess->opts->preserve_gids ? f->st.gid : -1; |
gid = f->st.gid; |
|
|
|
if (uid != (uid_t)-1 || gid != (gid_t)-1) { |
if (fchown(fd, uid, gid) == -1) { |
if (fchown(fd, uid, gid) == -1) { |
if (errno != EPERM) { |
if (errno != EPERM) { |
ERR(sess, "%s: fchown", path); |
ERR(sess, "%s: fchown", path); |