summaryrefslogtreecommitdiff
path: root/rpmpopt.in
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2022-01-21 10:39:52 +0200
committerPanu Matilainen <pmatilai@redhat.com>2022-02-03 13:47:28 +0200
commit2a8d89a1c390e6ca1de0ece49aa11012b1d0ff89 (patch)
treebcc1442c1e07cbbff589e5ee03c1701914f6b6f6 /rpmpopt.in
parent99f8997082637889e6ef08c7893d583cfaea2f04 (diff)
downloadrpm-2a8d89a1c390e6ca1de0ece49aa11012b1d0ff89.tar.gz
Reimplement --restore as a transaction element, obsolete --setperms & co
--setperms, --setugids and --setcaps were fun demos of alias capabilities in the nineties, but they can be downright dangerous when used separately, are blisfully unaware of all state in rpm yet try to duplicate functionality existing in C, and thus are a constant source of bugs that are between hard to impossible to fix in the alias space. Add a new transaction element type for the restore operation, wire through all the necessary places. In places (like ordering) this is an overkill but otherwise it seems like a natural thing to be able to process restore alongside package install/remove. The restore operation is a cross between install and erase codepath-wise so touches some funny places, but FA_TOUCH does just the thing, and now all the regular disablers like --nocontext and --nocaps can be used if necessary, plugins get to do their work and also timestamps are restored. Remove the dangerous shell implementations of things and just make them aliases to --restore. Fixes: #965
Diffstat (limited to 'rpmpopt.in')
-rw-r--r--rpmpopt.in34
1 files changed, 4 insertions, 30 deletions
diff --git a/rpmpopt.in b/rpmpopt.in
index d5a6b140b..4409a04f6 100644
--- a/rpmpopt.in
+++ b/rpmpopt.in
@@ -43,36 +43,10 @@ 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" \
- --POPTdesc=$"set permissions of files in a package"
-
-rpm alias --setugids -q --qf \
- '[ch %{FILEUSERNAME:shescape} %{FILEGROUPNAME:shescape} %{FILENAMES:shescape} %{FILEFLAGS}\n]' \
- --pipe "(echo 'ch() { ( \[ $(($4 & 2#1001000)) != 0 \] && \[ ! -e \"$3\" \] ) || \
- (chown -h -- \"$1\" \"$3\";chgrp -h -- \"$2\" \"$3\";) }'; \
- grep '^ch '|grep -v \(none\))|sh" \
- --POPTdesc=$"set user/group ownership of files in a package"
-
-rpm alias --setcaps -q --qf \
- "[if \[ -f %{FILENAMES:shescape} -a ! -L %{FILENAMES:shescape} \]; then\n\
-%|FILECAPS?{ if \[ -n %{FILECAPS:shescape} \]; then\n\
- setcap %{FILECAPS:shescape} %{FILENAMES:shescape}\n\
- el}:{ }|if \[ -n \"\$(getcap %{FILENAMES:shescape})\" \]; then\n\
- setcap -r %{FILENAMES:shescape}\n\
- fi\n\
-fi\n]" \
- --pipe "sh" \
- --POPTdesc=$"set capabilities of files in a package"
-
-rpm alias --restore -q --qf \
- '[ rpm --setugids %{NAME:shescape}; \
- rpm --setperms %{NAME:shescape}; \
- rpm --setcaps %{NAME:shescape}; \n]' --pipe "sh" \
- --POPTdesc=$"restore file/directory permissions"
+# obsolete
+rpm alias --setperms --restore
+rpm alias --setugids --restore
+rpm alias --setcaps --restore
rpm alias --conflicts --qf \
"[%|VERBOSE?{%{CONFLICTFLAGS:deptype}: }:{}|%{CONFLICTNEVRS}\n]" \