mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-04-25 17:16:00 +03:00
[GH-ISSUE #1584] Bug: setup.sh continues even if creating ~/archivebox/data fails, causing chown of contents of dir the script is run from #2456
Labels
No labels
expected: maybe someday
expected: next release
expected: release after next
expected: unlikely unless contributed
good first ticket
help wanted
pull-request
scope: all users
scope: windows users
size: easy
size: hard
size: medium
size: medium
status: backlog
status: blocked
status: done
status: idea-phase
status: needs followup
status: wip
status: wontfix
touches: API/CLI/Spec
touches: configuration
touches: data/schema/architecture
touches: dependencies/packaging
touches: docs
touches: js
touches: views/replayers/html/css
why: correctness
why: functionality
why: performance
why: security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/ArchiveBox#2456
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @1over137 on GitHub (Nov 3, 2024).
Original GitHub issue: https://github.com/ArchiveBox/ArchiveBox/issues/1584
Originally assigned to: @pirate on GitHub.
Not a security vulnerability (at least in a way I can think of)
I assume I'm just very unlucky today and I triggered a somewhat dangerous bug in https://github.com/ArchiveBox/ArchiveBox/blob/dev/bin/setup.sh.
Preconditions
docker run -v ~/archivebox:/data -it -d -p 8000:8000 --name=archivebox archivebox/archivebox:latest init --setupNotice that this chown's ~/archivebox, resulting in permission denied if you try to cd in it. This sets the stage for the bug.
Bug
Going through setup.sh, starting at line 52
github.com/ArchiveBox/ArchiveBox@1148cadd7a/bin/setup.sh (L53)This fails, but the script continues.
github.com/ArchiveBox/ArchiveBox@1148cadd7a/bin/setup.sh (L54)This fails, but the script keeps running. We are still in the user's home!
github.com/ArchiveBox/ArchiveBox@1148cadd7a/bin/setup.sh (L58)This fails, but the script keeps running. We are still in the user's home!
github.com/ArchiveBox/ArchiveBox@1148cadd7a/bin/setup.sh (L59)This fails because it will refuse to init if folder is non-empty. We are still in the user's home!
github.com/ArchiveBox/ArchiveBox@1148cadd7a/bin/setup.sh (L62)This runs in the user's home. Many files get chown'd to the user ID 911, including the user's home directory itself. This renders the user unable to access his own files, and requires root to recover.
Some general advice
In general, any commands that can possibly fail in a shell script, when it fails unexpectedly (like the first mkdir -p command) should terminate the entire script. You might want to include a
diefunction and usemkdir -p ~/archivebox/data || die, then it would have killed the script instead of letting it keep going.Reference: https://stackoverflow.com/questions/7868818/in-bash-is-there-an-equivalent-of-die-error-msg
Questions
What does the program do after that command runs besides chown'ing the files? I'm considering recovering from a backup in case it changed any files.
@pirate commented on GitHub (Nov 4, 2024):
setup.shis completely deprecated as ofv0.8.6rc0. I'm about to remove it entirely as an install option because I really dont likecurl | shas an install method and have been wanting to remove it for years.With the new versions you can just do:
archivebox installstarts with aninit, so it should die properly before attempting to chown anything.Also note the new docker container versions for v0.8.5 and above will autodetect the existing ownership of any passed data dir, so it shouldn't force 911 anymore if you pass it a dir that you've already created.
@pirate commented on GitHub (Nov 4, 2024):
I've updated
setup.shin the meantime:github.com/ArchiveBox/ArchiveBox@fd89de5b91To see what else the Docker container does on startup to the data dir you can read this script:
https://github.com/ArchiveBox/ArchiveBox/blob/dev/bin/docker_entrypoint.sh
And the
initsource code here:github.com/ArchiveBox/ArchiveBox@c1fd2cfa42/archivebox/main.py (L308)It creates a chowns a few subdirectories, but nothing dangerous that should warrant having to restore your entire
~from a backup. There are no deletions or edits of files other thanArchiveBox.conf, only creation andchowning.@1over137 commented on GitHub (Nov 4, 2024):
That's what I figured. The only observable effect seems to be the creation of a logs directory under ~. The chown'ing quickly killed my compositor and the shell which the command runs on, so it probably didn't get to the rest of script.
@pirate commented on GitHub (Nov 4, 2024):
There just a couple others to check for depending on how far it got:
./logs./crontabs./archive@1over137 commented on GitHub (Nov 4, 2024):
Only logs was created. Also not everything was chown'd, so most likely it got killed in the middle of that
findcommand@pirate commented on GitHub (Nov 4, 2024):
I've added an extra step that prevents this at the docker level even if a user doesn't use
setup.sh:github.com/ArchiveBox/ArchiveBox@99ed97836f@1over137 commented on GitHub (Nov 4, 2024):
I would check for something like .bashrc/.zshrc. Many servers do not have Documents and some do not have a .config