We should whine if we're running as root. #725
Labels
No Label
0.2.0
0.3.0
0.4.0
0.5.0
0.5.1
0.6.0
0.6.1
0.7.0
0.8.0
0.9.0
1.0.0
1.1.0
1.10.0
1.10.1
1.10.2
1.10a2
1.11.0
1.12.0
1.12.1
1.13.0
1.14.0
1.15.0
1.15.1
1.2.0
1.3.0
1.4.1
1.5.0
1.6.0
1.6.1
1.7.0
1.7.1
1.7β
1.8.0
1.8.1
1.8.2
1.8.3
1.8β
1.9.0
1.9.0-s3branch
1.9.0a1
1.9.0a2
1.9.0b1
1.9.1
1.9.2
1.9.2a1
LeastAuthority.com automation
blocker
cannot reproduce
cloud-branch
code
code-dirnodes
code-encoding
code-frontend
code-frontend-cli
code-frontend-ftp-sftp
code-frontend-magic-folder
code-frontend-web
code-mutable
code-network
code-nodeadmin
code-peerselection
code-storage
contrib
critical
defect
dev-infrastructure
documentation
duplicate
enhancement
fixed
invalid
major
minor
n/a
normal
operational
packaging
somebody else's problem
supercritical
task
trivial
unknown
was already fixed
website
wontfix
worksforme
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Reference: tahoe-lafs/trac-2024-07-25#725
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
Just spent some time unravelling a problem at ScanCafe where nodes were refusing to start because they couldn't open storage/shares/incoming.
It turns out that directory was owned by root. I'm guessing that someone tried to run the nodes as root, thus hosing things up. Not sure why that was the only thing affected, but it seemed to be.
We should complain if we think we're running as root, possibly with a commandline switch or config entry to force it... or possibly not. :)
Good idea. Also, should storage servers be more loud and explicit about the fact that they are having a problem with "storage/shares/incoming", or are they already good on that?
No, that error is pretty explicit. The slient failure that annoys me is if we can't bind to one of our many ports (manhole seems to get me most often). That's a different, ticket, though. :)
So what is the criterion for runnning as root?
os.getuid() == 0
and does not throw an exception?No, should be
os.geteuid()
(being setuid root is just as bad).Attachment 725.patch (1093 bytes) added
I think that alerting the user about running as root should instead be addressed as a security concern. It makes sense that initially running as root would mess with the file permissions, but I believe the issue is generalized to first running as X user and then as Y user, not just root. Anyways, here is the patch I wrote.
os.geteuid
isn't available in native-Windows Python:Perhaps "
if hasattr(os, 'geteuid') and os.geteuid() == 0:
".In principle you also shouldn't run as Administrator on Windows, but that's probably too common (and Windows security is beyond fixing anyway) to be worth warning about.
That's a very good suggestion - I forgot to consider if the user is running on a Windows system. I also agree with not warning the user on Windows systems. I've found that non-Administrator users still have quite enough access to cause significant harm anyways, so it's probably a moot point to restrict it. I updated the patch.
Attachment 725.2.2.patch (1092 bytes) added
Updated patch, considers Windows users
I'm in the process of writing tests, and zooko and I came across the question of whether or not the '--quiet' flag should suppress the "running as root" error. It should also be known that the error is going to be printed out to STDERR, not STDOUT. What do you guys think?
Hi! I think that the
--quiet
flag should suppress the warning, and also that the warning should go tostderr
, notstdout
. Want more help writing tests? Let's get together on IRC for that.We also need a test that mocks os.geteuid to return 0, and checks that the warning is printed (also, that it is not printed when
--quiet
is used).Hey mcoppola: still interested? If you don't indicate interest on this ticket soon, I'll feel free to let someone else do it.
Hey, sorry about the lapse. Thanks for giving me a kick in the behind. I'll try to finish it up.
EDIT: Some guidance with how to navigate and add units to the testing utility in Tahoe would be appreciated, though.
mcoppola: great!
Let's get together on IRC sometime to walk you through how to write these tests. In the meantime, you can see other tests which do similar things, such as [test_error_on_old_config_files]source:trunk/src/allmydata/test/test_client.py?rev=5143#L33.
Looks like I'm busier than I thought. I'd still love to help out with the project, but for the sake of this bug someone else should take care of it. Sorry 'bout that.
On tahoe-dev, davidsarah wrote:
The error message needs to be printed to stderr.
i like making it an error, makes sense for unprivileged users.