Keep setup runtime parents user-writable

This commit is contained in:
Nick Sweeting 2026-08-01 03:43:03 -07:00
parent 7aaf4dabaf
commit 3cf5123664
No known key found for this signature in database
2 changed files with 14 additions and 0 deletions

View File

@ -21,6 +21,13 @@ def test_setup_script_never_recursively_chowns_collection_data():
assert "chown -R" not in "\n".join(line for line in script.splitlines() if "archivebox/data" in line)
def test_setup_script_gives_archivebox_user_ownership_of_runtime_parent_dirs():
script = SETUP_SCRIPT.read_text()
assert 'for path in "$HOME/.local" "$HOME/.local/share" "$HOME/.cache" "$HOME/.cache/archivebox"; do' in script
assert 'chown "$ARCHIVEBOX_SYSTEM_UID:$ARCHIVEBOX_SYSTEM_GID" "$path"' in script
def test_setup_script_bootstraps_locked_abxpkg_version():
script = SETUP_SCRIPT.read_text()

View File

@ -102,6 +102,13 @@ fix_root_install_ownership() {
return 0
fi
# Keep shared runtime parents writable after ArchiveBox drops privileges.
for path in "$HOME/.local" "$HOME/.local/share" "$HOME/.cache" "$HOME/.cache/archivebox"; do
if [ -e "$path" ]; then
chown "$ARCHIVEBOX_SYSTEM_UID:$ARCHIVEBOX_SYSTEM_GID" "$path"
fi
done
for path in "$HOME/.local/bin" "$HOME/.local/share/uv" "$HOME/.cache/uv" "$ABXPKG_LIB_DIR"; do
if [ -e "$path" ]; then
chown -R "$ARCHIVEBOX_SYSTEM_UID:$ARCHIVEBOX_SYSTEM_GID" "$path"