mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-04 17:47:03 +03:00
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
This commit is contained in:
parent
d946fb596f
commit
0c6aeb4609
@ -263,9 +263,12 @@ static int patch_fd(int fd, const char *name, const struct stat *st, uid_t shift
|
|||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
/* The Linux kernel alters the mode in some cases of chown(). Let's undo this. */
|
/* The Linux kernel alters the mode in some cases of chown(). Let's undo this. */
|
||||||
if (name && !S_ISLNK(st->st_mode))
|
if (name) {
|
||||||
r = fchmodat(fd, name, st->st_mode, 0);
|
if (!S_ISLNK(st->st_mode))
|
||||||
else
|
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);
|
r = fchmod(fd, st->st_mode);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user