From 42479fe6351a0d5f8c233c157010a66fed43cc70 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 19 Aug 2019 16:02:31 +0200 Subject: Fix chmod of symlinks in restore_fstree We can't change the mod of symlinks and hence AT_SYMLINK_NOFOLLOW is not supported by chmod(2 -> RTFM!). The solution is to not use that flag and simply skip symlinks. Signed-off-by: David Oberhollenzer --- unpack/restore_fstree.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/unpack/restore_fstree.c b/unpack/restore_fstree.c index 4e763cb..21bae3f 100644 --- a/unpack/restore_fstree.c +++ b/unpack/restore_fstree.c @@ -157,9 +157,8 @@ static int set_attribs(fstree_t *fs, tree_node_t *n, int flags) } } - if (flags & UNPACK_CHMOD) { - if (fchmodat(AT_FDCWD, n->name, n->mode, - AT_SYMLINK_NOFOLLOW)) { + if (flags & UNPACK_CHMOD && !S_ISLNK(n->mode)) { + if (fchmodat(AT_FDCWD, n->name, n->mode, 0)) { fprintf(stderr, "chmod %s: %s\n", n->name, strerror(errno)); return -1; -- cgit v1.2.3