From 7ccf316ceb767ddbd2c967a529551a8c1a78a53e Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Thu, 9 Jan 2025 10:58:28 +1000 Subject: [PATCH] Provide a default sandboxuser If sandboxuser is not set, pacman/libalpm does not handle moving incomplete download files out of the temporary download directories and into the cache. This leave download_XXXXXX directories in the cache that cause warnings on -Sc operations. Initialise the sandboxuser with the username of UID 0 (root on most systems). Fixes #209. Signed-off-by: Allan McRae --- lib/libalpm/alpm.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c index e71cb02a..6753692f 100644 --- a/lib/libalpm/alpm.c +++ b/lib/libalpm/alpm.c @@ -25,6 +25,9 @@ #include #endif +#include +#include + /* libalpm */ #include "alpm.h" #include "alpm_list.h" @@ -39,6 +42,7 @@ alpm_handle_t SYMEXPORT *alpm_initialize(const char *root, const char *dbpath, const char *lf = "db.lck"; char *hookdir; size_t hookdirlen, lockfilelen; + struct passwd const *pw = NULL; alpm_handle_t *myhandle = _alpm_handle_new(); if(myhandle == NULL) { @@ -78,6 +82,10 @@ alpm_handle_t SYMEXPORT *alpm_initialize(const char *root, const char *dbpath, myhandle->parallel_downloads = 1; + /* set default sandboxuser */ + ASSERT((pw = getpwuid(0)) != NULL, myerr = errno; goto cleanup); + STRDUP(myhandle->sandboxuser, pw->pw_name, goto nomem); + #ifdef ENABLE_NLS bindtextdomain("libalpm", LOCALEDIR); #endif