From: Lennart Poettering Date: Sat, 25 Jun 2016 04:04:43 +0000 (+0200) Subject: nspawn: fix uid patching logic (#3599) X-Git-Tag: v231~118 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c6aeb4609f619328b9dcf8d8d815bd06e412ac5;p=platform%2Fupstream%2Fsystemd.git nspawn: fix uid patching logic (#3599) An incorrectly set if/else chain caused aus to apply the access mode of a symlink to the directory it is located in. Yuck. Fixes: #3547 --- diff --git a/src/nspawn/nspawn-patch-uid.c b/src/nspawn/nspawn-patch-uid.c index cc79597..ded5866 100644 --- a/src/nspawn/nspawn-patch-uid.c +++ b/src/nspawn/nspawn-patch-uid.c @@ -263,9 +263,12 @@ static int patch_fd(int fd, const char *name, const struct stat *st, uid_t shift return -errno; /* The Linux kernel alters the mode in some cases of chown(). Let's undo this. */ - if (name && !S_ISLNK(st->st_mode)) - r = fchmodat(fd, name, st->st_mode, 0); - else + if (name) { + if (!S_ISLNK(st->st_mode)) + r = fchmodat(fd, name, st->st_mode, 0); + else /* AT_SYMLINK_NOFOLLOW is not available for fchmodat() */ + r = 0; + } else r = fchmod(fd, st->st_mode); if (r < 0) return -errno;