From 3370dd586a81d9adb21beee7777bf3601ef003e3 Mon Sep 17 00:00:00 2001 From: morganamilo Date: Sun, 11 May 2025 00:52:01 +0100 Subject: [PATCH] libalpm: don't chown download dir if not root Commit 7bc5d55b56f41518e0a53eed13d4c523aea848e5 disbaled the chown after downloading if the current user is not root. It only makes sense for us to do the same on this side otherwise files would end up stuck as the download user. This is also important for other alpm tools that configure themselves via pacman.conf but download to user directories. --- lib/libalpm/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 7877b17a..00cc3734 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -955,10 +955,11 @@ const char *_alpm_filecache_setup(alpm_handle_t *handle) */ char *_alpm_temporary_download_dir_setup(const char *dir, const char *user) { + uid_t myuid = getuid(); struct passwd const *pw = NULL; ASSERT(dir != NULL, return NULL); - if(user != NULL) { + if(myuid == 0 && user != NULL) { ASSERT((pw = getpwnam(user)) != NULL, return NULL); }