Welcome to the Pacman bug tracker. Please search the current bugs and feature requests before filing a new one! Use advanced search and select "Search in Comments".

* Please select the correct category and version.
* Write a descriptive summary, background info, and provide a reproducible test case whenever possible.

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
Task Type Bug Report
Category Scripts & Tools
Status Closed
Assigned To Andrew Gregory (andrewgregory)
Architecture All
Severity Medium
Priority Normal
Reported Version 4.2.1
Due in Version 5.1.0
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


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.

"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
Comment by Allan McRae (Allan) - Thursday, 30 July 2015, 03:23 GMT
@Andrew: are you still intending to add pacconf to the codebase?
Comment by Allan McRae (Allan) - Thursday, 30 July 2015, 03:23 GMT
@Mika: you forgot the attachment.
Comment by Mika Norén (SysGhost) - Thursday, 30 July 2015, 15:11 GMT
@Allan: Sorry about that. It fell of somehow. Those paperclips aren't sturdy enough.

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

- eval $(awk '/DBPath/ {print $1$2$3}' /etc/pacman.conf)
+ eval "DBPath="$(pacconf DBPath)
if [[ ! -d "${pac_db}" ]]; then
error "unable to read pacman database %s". "${pac_db}"
Comment by Allan McRae (Allan) - Tuesday, 11 October 2016, 12:15 GMT
While many of these scripts have moved to a separate project, pacman-key and pacman-db-upgrade could still benefit from pacconf being added.