mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-13 06:34:25 -04:00
try creating shared libs as 777 when running as root
This commit is contained in:
parent
35c7019772
commit
1888691ee8
5 changed files with 26 additions and 11 deletions
|
@ -95,6 +95,10 @@ def get_LIB_DIR():
|
||||||
if IS_ROOT:
|
if IS_ROOT:
|
||||||
# make sure lib dir is owned by the archivebox user, not root
|
# make sure lib dir is owned by the archivebox user, not root
|
||||||
with SudoPermission(uid=0):
|
with SudoPermission(uid=0):
|
||||||
|
if ARCHIVEBOX_USER == 0:
|
||||||
|
# print(f'[yellow]:warning: Waring: Creating SYSTEM_LIB_DIR {lib_dir} with mode 777 so that non-root archivebox users can share it.[/yellow] (caches shared libs used by archivebox for performance)', file=sys.stderr)
|
||||||
|
os.system(f'chmod -R 777 "{lib_dir}"')
|
||||||
|
else:
|
||||||
os.system(f'chown {ARCHIVEBOX_USER}:{ARCHIVEBOX_GROUP} "{lib_dir}"')
|
os.system(f'chown {ARCHIVEBOX_USER}:{ARCHIVEBOX_GROUP} "{lib_dir}"')
|
||||||
else:
|
else:
|
||||||
raise PermissionError()
|
raise PermissionError()
|
||||||
|
@ -129,6 +133,10 @@ def get_TMP_DIR():
|
||||||
if not dir_is_writable(run_dir):
|
if not dir_is_writable(run_dir):
|
||||||
if IS_ROOT:
|
if IS_ROOT:
|
||||||
with SudoPermission(uid=0, fallback=False):
|
with SudoPermission(uid=0, fallback=False):
|
||||||
|
if ARCHIVEBOX_USER == 0:
|
||||||
|
# print(f'[yellow]:warning: Waring: Creating SYSTEM_TMP_DIR {run_dir} with mode 777 so that non-root archivebox users can access it.[/yellow]', file=sys.stderr)
|
||||||
|
os.system(f'chmod -R 777 "{run_dir}"')
|
||||||
|
else:
|
||||||
os.system(f'chown {ARCHIVEBOX_USER}:{ARCHIVEBOX_GROUP} "{run_dir}"')
|
os.system(f'chown {ARCHIVEBOX_USER}:{ARCHIVEBOX_GROUP} "{run_dir}"')
|
||||||
else:
|
else:
|
||||||
raise PermissionError()
|
raise PermissionError()
|
||||||
|
@ -148,6 +156,10 @@ def get_TMP_DIR():
|
||||||
if not dir_is_writable(run_dir):
|
if not dir_is_writable(run_dir):
|
||||||
if IS_ROOT:
|
if IS_ROOT:
|
||||||
with SudoPermission(uid=0):
|
with SudoPermission(uid=0):
|
||||||
|
if ARCHIVEBOX_USER == 0:
|
||||||
|
# print(f'[yellow]:warning: Waring: Creating SYSTEM_TMP_DIR {run_dir} with mode 777 so that non-root archivebox users can access it.[/yellow]', file=sys.stderr)
|
||||||
|
os.system(f'chmod -R 777 "{run_dir}"')
|
||||||
|
else:
|
||||||
os.system(f'chown {ARCHIVEBOX_USER}:{ARCHIVEBOX_GROUP} "{run_dir}"')
|
os.system(f'chown {ARCHIVEBOX_USER}:{ARCHIVEBOX_GROUP} "{run_dir}"')
|
||||||
else:
|
else:
|
||||||
raise PermissionError()
|
raise PermissionError()
|
||||||
|
|
|
@ -85,7 +85,7 @@ except Exception:
|
||||||
#############################################################################################
|
#############################################################################################
|
||||||
|
|
||||||
def drop_privileges():
|
def drop_privileges():
|
||||||
"""If running as root, drop privileges to the user that owns the data dir (or PUID, or default=911)"""
|
"""If running as root, drop privileges to the user that owns the data dir (or PUID)"""
|
||||||
|
|
||||||
# always run archivebox as the user that owns the data dir, never as root
|
# always run archivebox as the user that owns the data dir, never as root
|
||||||
if os.getuid() == 0:
|
if os.getuid() == 0:
|
||||||
|
|
|
@ -573,11 +573,14 @@ def printable_folder_status(name: str, folder: Dict) -> str:
|
||||||
|
|
||||||
if folder['path']:
|
if folder['path']:
|
||||||
if os.access(folder['path'], os.R_OK):
|
if os.access(folder['path'], os.R_OK):
|
||||||
|
try:
|
||||||
num_files = (
|
num_files = (
|
||||||
f'{len(os.listdir(folder["path"]))} files'
|
f'{len(os.listdir(folder["path"]))} files'
|
||||||
if Path(folder['path']).is_dir() else
|
if os.path.isdir(folder['path']) else
|
||||||
printable_filesize(Path(folder['path']).stat().st_size)
|
printable_filesize(Path(folder['path']).stat().st_size)
|
||||||
)
|
)
|
||||||
|
except PermissionError:
|
||||||
|
num_files = 'error'
|
||||||
else:
|
else:
|
||||||
num_files = 'missing'
|
num_files = 'missing'
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[project]
|
[project]
|
||||||
name = "archivebox"
|
name = "archivebox"
|
||||||
version = "0.8.5rc11"
|
version = "0.8.5rc12"
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
description = "Self-hosted internet archiving solution."
|
description = "Self-hosted internet archiving solution."
|
||||||
authors = [{name = "Nick Sweeting", email = "pyproject.toml@archivebox.io"}]
|
authors = [{name = "Nick Sweeting", email = "pyproject.toml@archivebox.io"}]
|
||||||
|
|
2
uv.lock
generated
2
uv.lock
generated
|
@ -41,7 +41,7 @@ wheels = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "archivebox"
|
name = "archivebox"
|
||||||
version = "0.8.5rc11"
|
version = "0.8.5rc12"
|
||||||
source = { editable = "." }
|
source = { editable = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "atomicwrites" },
|
{ name = "atomicwrites" },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue