mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
Revert "nspawn-patch-uid: try fchmodat2() to restore mode of symlink"
This reverts commit 30462563b1.
fchmodat2(), while accepting AT_SYMLINK_NOFOLLOW as a valid flag,
always returns EOPNOTSUPP when operating on a symlink. The Linux kernel
simply doesn't support changing the mode of a symlink.
Fixes #30157
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
#include "fileio.h"
|
||||
#include "fs-util.h"
|
||||
#include "missing_magic.h"
|
||||
#include "missing_syscall.h"
|
||||
#include "nspawn-def.h"
|
||||
#include "nspawn-patch-uid.h"
|
||||
#include "stat-util.h"
|
||||
@@ -240,18 +239,14 @@ static int patch_fd(int fd, const char *name, const struct stat *st, uid_t shift
|
||||
|
||||
/* The Linux kernel alters the mode in some cases of chown(). Let's undo this. */
|
||||
if (name) {
|
||||
/* It looks like older glibc (before 2016) did not support AT_SYMLINK_NOFOLLOW. */
|
||||
if (!S_ISLNK(st->st_mode))
|
||||
r = RET_NERRNO(fchmodat(fd, name, st->st_mode, 0));
|
||||
else {
|
||||
r = RET_NERRNO(fchmodat2(fd, name, st->st_mode, AT_SYMLINK_NOFOLLOW));
|
||||
if (IN_SET(r, -ENOSYS, -EPERM))
|
||||
r = 0;
|
||||
}
|
||||
r = fchmodat(fd, name, st->st_mode, 0);
|
||||
else /* AT_SYMLINK_NOFOLLOW is not available for fchmodat() */
|
||||
r = 0;
|
||||
} else
|
||||
r = RET_NERRNO(fchmod(fd, st->st_mode));
|
||||
r = fchmod(fd, st->st_mode);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return -errno;
|
||||
|
||||
changed = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user