Skip to content

Commit

Permalink
utils: ignore ENOTSUP when chmod a symlink
Browse files Browse the repository at this point in the history
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: #1308

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Sep 22, 2023
1 parent 905552d commit 66d6cd7
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/libcrun/utils.c
Expand Up @@ -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 (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);
}
/* If the operation fails with ENOTSUP we are dealing with a symlink, so ignore it. */
if (ret < 0 && errno == ENOTSUP)
return 0;

if (UNLIKELY (ret < 0))
return crun_make_error (err, errno, "chmod `%s/%s`", destname, de->d_name);
Expand Down

0 comments on commit 66d6cd7

Please sign in to comment.