FS#43304 - [makepkg] DLAGENTS parsing/splitting does not respect quote escaping

Attached to Project: Pacman
Opened by zopieux (Zopieux) - Friday, 02 January 2015, 14:47 GMT
Last edited by Allan McRae (Allan) - Sunday, 31 January 2016, 03:51 GMT
Task Type Bug Report
Category General
Status Closed
Assigned To Allan McRae (Allan)
Architecture All
Severity Low
Priority Normal
Reported Version 4.2.1
Due in Version 5.0.0
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:
When downloading, makepkg invokes the dl-agent but shell argument splitting does not respect single quote escaping.

Before system upgrade (pacman <4.2.0-5), this used to work fine.

Additional info:
* core/pacman (for /usr/bin/makepkg) 4.2.0-5

Steps to reproduce:

Using the following makepkg.conf configuration:

DLAGENTS=( "ftp::/usr/bin/aria2c -U 'Mozilla/5.0 (compatible)' -o %o %u"
"http::/usr/bin/aria2c -U 'Mozilla/5.0 (compatible)' -o %o %u"
"https::/usr/bin/aria2c -U 'Mozilla/5.0 (compatible)' -o %o %u"
'rsync::/usr/bin/rsync -z %u %o'
'scp::/usr/bin/scp -C %u %o')

When strace'ing makepkg on eg. https download, we can see that it invokes the dl-agent with the following:

26946 execve("/usr/bin/aria2c", ["/usr/bin/aria2c", "-U", "'Mozilla/5.0", "(compatible)'", "-o", "pew-0.1.14.tar.gz.part", "https://pypi.python.org/packages/source/p/pew/pew-0.1.14.tar.gz"], [/* 74 vars */]) = 0

Note the wrongly splitted -U argument. It should be ["-U", "Mozilla/5.0 (compatible)"].
As a result, aria2c tries to download the URL "(compatible)", which fails, of course.

A possible user fix is to escape spaces using backslashes as in:

"https::/usr/bin/aria2c -U Mozilla/5.0\ (compatible) -o %o %u"
This task depends upon

Closed by  Allan McRae (Allan)
Sunday, 31 January 2016, 03:51 GMT
Reason for closing:  Fixed
Additional comments about closing:  Documented in git commit 18d00097
Comment by zopieux (Zopieux) - Saturday, 03 January 2015, 14:33 GMT
A quick note: double quotes don't work neither, ie. 'https::/usr/bin/aria2c -U "Mozilla/5.0 (compatible)"' fails the same way.
Comment by Dave Reisner (falconindy) - Saturday, 03 January 2015, 15:39 GMT
> A possible user fix is to escape spaces using backslashes
This is the intended solution:

https://projects.archlinux.org/pacman.git/commit/?id=ee207d7c7b34ca
Comment by zopieux (Zopieux) - Sunday, 04 January 2015, 14:37 GMT
Oh I see. Thanks, I guess this can be closed then.
Comment by Allan McRae (Allan) - Sunday, 04 January 2015, 14:47 GMT
We should add a note in the makepkg.conf man page.

Loading...