From 57262a2710c83fa08767f0ce3ba7a80993515bb2 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Fri, 22 Sep 2023 11:34:19 +0200 Subject: [PATCH] utils: ignore ENOTSUP when chmod a symlink commit 5d1f903f75a80daa4dfb3d84e114ec8ecbf29956 in the kernel, present in a release since Linux 6.6 doesn't allow anymore to change the mode of a symlink, so just ignore the failure. Closes: https://github.com/containers/crun/issues/1308 Signed-off-by: Giuseppe Scrivano --- src/libcrun/utils.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/libcrun/utils.c b/src/libcrun/utils.c index 1b7104a4b2..dfe5f03c37 100644 --- a/src/libcrun/utils.c +++ b/src/libcrun/utils.c @@ -2079,19 +2079,9 @@ copy_recursive_fd_to_fd (int srcdirfd, int dfd, const char *srcname, const char ret = fchmodat (destdirfd, de->d_name, mode & ALLPERMS, AT_SYMLINK_NOFOLLOW); if (UNLIKELY (ret < 0)) { + /* If the operation fails with ENOTSUP we are dealing with a symlink, so ignore it. */ if (errno == ENOTSUP) - { - proc_fd_path_t proc_path; - cleanup_close int fd = -1; - - fd = openat (destdirfd, de->d_name, O_PATH | O_NOFOLLOW); - if (UNLIKELY (fd < 0)) - return crun_make_error (err, errno, "open `%s/%s`", destname, de->d_name); - - get_proc_self_fd_path (proc_path, fd); - - ret = chmod (proc_path, mode & ALLPERMS); - } + return 0; if (UNLIKELY (ret < 0)) return crun_make_error (err, errno, "chmod `%s/%s`", destname, de->d_name);