FS#45831 - Improper parsing of pacman.conf in pacman's various scripts.
Attached to Project:
Pacman
Opened by Mika Norén (SysGhost) - Wednesday, 29 July 2015, 18:54 GMT
Last edited by Allan McRae (Allan) - Friday, 19 January 2018, 04:21 GMT
Opened by Mika Norén (SysGhost) - Wednesday, 29 July 2015, 18:54 GMT
Last edited by Allan McRae (Allan) - Friday, 19 January 2018, 04:21 GMT
|
Details
Summary and Info:
pacman's various scripts, such as pacdiff, parses /etc/pacman.conf in such a way, it can confuse comments and other stuff mentioning variables by their name with actual variables. It can cause confusion if one uses custom values in pacman.conf's variables. Steps to Reproduce: Have custom variables in pacman.conf, such as DBPath. (i.e. DBPath="/mnt/Storage/.pacman/db/" ) Have the original line commented out for future reference, in a line before the real variable. (i.e. #DBPath="/var/lib/pacman/"), or any other lines containing the variable name. Result: "pacdiff" for instance, on line 191: eval $(awk '/DBPath/ {print $1$2$3}' /etc/pacman.conf) This line will pick out all lines it finds that contains "DBPath", no matter if it's commented out or not, resulting in eval to fail. This will leave DBPath within the script empty, despite it being set in /etc/pacman.conf, and rest of the scripts reverts back to the default path. To fix: I've created a simple patch for pacdiff: pacdiff.patch See attached files. The other scripts using the same eval-awk parsing method should also be updated. It would be preferred if the pacman.conf parsing was done with pacconf instead. |
This task depends upon
Closed by Allan McRae (Allan)
Friday, 19 January 2018, 04:21 GMT
Reason for closing: Fixed
Additional comments about closing: git commit d9eda13fc6
Friday, 19 January 2018, 04:21 GMT
Reason for closing: Fixed
Additional comments about closing: git commit d9eda13fc6
Here it is:
--- /usr/bin/pacdiff 2015-07-24 03:53:28.000000000 +0200
+++ /home/sysghost/bin/pacdiff 2015-07-29 20:53:01.516892731 +0200
@@ -188,7 +188,7 @@
usage; exit 1
fi
- eval $(awk '/DBPath/ {print $1$2$3}' /etc/pacman.conf)
+ eval "DBPath="$(pacconf DBPath)
pac_db="${DBPath:-/var/lib/pacman/}local"
if [[ ! -d "${pac_db}" ]]; then
error "unable to read pacman database %s". "${pac_db}"