[pacman-dev] [PATCH] Removed root necessity for DOWNLOADONLY

Harley W harleyw at hotmail.com
Thu May 25 02:16:26 UTC 2017

Signed-off-by: DestructiveReasoning <harleyw at hotmail.com>

This is in response to bug #33369 on Flyspray - "pacman asks for root password
for -w option (download only)". I was looking into this tonight and ultimately
encountered an issue that the lock file is (by default) stored under /usr,
making it not writable for the average user. I am very new to C and
concurrency (and pacman-dev ;) so I do not fully understand why the
lockfile is necessary for a download-only operation, but assuming
it is necessary, the only option I can think of to resolve the
reported bug involves changing the permissions on the lockfile.
I've included the very simple patch below that, in conjunction with
changing the permissions on the lockfile, seem to fix the problem
described in the bug. The only notable change of functionality that
I've seen is that executing "$ pacman -Sw <package>" without
modifying the cache directory will, since it cannot write to the
default, write to /tmp rather than asking for a root password.
However, now it is possible to execute "$ pacman -Sw <package>
--cachedir=$HOME", for example, without being prompted for the root
password. Please let me know what you think about this or if I've
missed a much prettier alternative (which is likely).

Harley Wiltzer

 src/pacman/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/pacman/util.c b/src/pacman/util.c
index ae8a74d3..f7f397fa 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -115,7 +115,7 @@ int needs_root(void)
 		case PM_OP_SYNC:
 			return (config->op_s_clean || config->op_s_sync ||
 					(!config->group && !config->op_s_info && !config->op_q_list &&
-					 !config->op_s_search && !config->print));
+					 !config->op_s_search && !config->print && !config->op_s_downloadonly));
 		case PM_OP_FILES:
 			return config->op_s_sync;

More information about the pacman-dev mailing list