libalpm: don't chown download dir if not root

Commit 7bc5d55b56 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.
This commit is contained in:
morganamilo 2025-05-11 00:52:01 +01:00
parent af54cd4ee1
commit 3370dd586a
No known key found for this signature in database
GPG key ID: E48D0A8326DE47C5

View file

@ -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);
}