Skip to content

Commit

Permalink
Skip recorded symlinks in --setperms (RhBug:1900662)
Browse files Browse the repository at this point in the history
If a package contains a symlink in the buildroot which is declared as a
ghost or config file but is a regular file or directory on the system
where it's installed, a --setperms call will reset its permissions to
those of a symlink (777 on Linux), which almost certainly is not the
correct thing to do.

To fix that, just skip files that were recorded as symlinks.

This is a special case of a general issue in --setperms; since file
permission semantics may change depending on the file type, to stay on
the safe side, any (ghost or config) file whose type changes after
installation should probably be skipped.  However, symlinks are the most
prominent case here, so let's just focus on that now and avoid adding
too much cleverness to a popt alias (this got us into trouble not too
long ago, see commits 38c2f6e and 0d83637).  We may revisit this in the
eventual C implementation.
  • Loading branch information
dmnks authored and pmatilai committed Jan 21, 2022
1 parent c624966 commit ed07a18
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions rpmpopt.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ rpm alias --scripts --qf '\
--POPTdesc=$"list install/erase scriptlets from package(s)"

rpm alias --setperms -q --qf '[\[ -L %{FILENAMES:shescape} \] || \
\[ -n %{FILELINKTOS:shescape} \] || \
( \[ $((%{FILEFLAGS} & 2#1001000)) != 0 \] && \[ ! -e %{FILENAMES:shescape} \] ) || \
chmod %7{FILEMODES:octal} %{FILENAMES:shescape}\n]' \
--pipe "grep -v \(none\) | grep '^. -L ' | sed 's/chmod .../chmod /' | sh" \
Expand Down

0 comments on commit ed07a18

Please sign in to comment.