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: containers#1308

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Sep 22, 2023
1 parent 905552d commit 57262a2
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/libcrun/utils.c
Original file line number Diff line number Diff line change
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 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);
Expand Down

0 comments on commit 57262a2

Please sign in to comment.