-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reconsider usage of sudo in uarch-bench.sh #55
Comments
@zingaburga - yup, the root thing bothers me a bit too. In fact, you can run About the use of The other purpose of the behavior is that it only runs the minimal, necessary amount of stuff as root. In particular, it doesn't run the So I'm not totally sure how to proceed here without loosing the benefits above. One option would be to, as you suggest, just use the existing root-or-not status of the script without using sudo internally. If sudo was needed, it could fail with a message, and an option like @zingaburga what do you think? |
You would, because the binary could be calling I wouldn't bother thinking about it too much. I'm sure anyone who uses this is smart enough to figure out how to get it working. It's just that if sudo isn't installed, you either have to install it (may be undesirable), or edit the script to remove all instances of it (which isn't too hard I suppose, but feels a little hacky). Just changing Thanks for the response! |
@zingaburga You raise a really good point and one I hadn't considered in my day-to-day usage of the terminal and So on Debian systems without |
I'm not sure what's typical, but I personally just run everything as root. Others may say that's a bad idea, but my opinion on it is probably something like this. The tool runs without root anyway - someone really worried about it will probably just run the changes (setting CPU governor etc) manually and then invoke the binary. For the rest, there's always a certain amount of trust involved - I think you're already upfront about it so I don't see much to worry about it. Nonetheless, I think calling sudo is a nice way to do things, but it can be avoided if the user already is root. |
Something like #!/bin/sh
if [ $(id -u) != 0 ]; then
if [ "x$SUDO" = "x" ]; then
SUDO="$(which sudo 2>/dev/null)"
if [ $? != 0 ]; then
echo "WARNING: sudo not found. Please set the $SUDO environment variable" >&2
echo "or run this script as root." >&2
fi
fi
fi
$SUDO do_something
? |
@nemequ - yup, that's approximately the direction I'm leading. Basically it should have the following attributes:
This still doesn't solve the thing that uarch-bench runs with a sudo ticket and could potentially elevate itself via sudo if it wanted. I'm not sure of a good solution there: I don't want to invalidate the ticket since the user might have gotten that themselves on the terminal and they wouldn't expect that to just disapear when they run uarch-bench.sh. Maybe I'm over-thinking this. |
I guess you could prompt to see if it's okay to run stuff via sudo, but TBH that seems a bit silly. If there is an open sudo ticket and uarch-bench were malicious it could exploit that… if you care about security you can't run untrusted code with an open sudo ticket, and there's nothing uarch-bench can do about that. What might be more sensible is to ask permission before each task (e.g., If you're trying to protect against malicious benchmarks but do trust uarch-bench, then I guess you could
I think so. |
uarch-bench.sh contains multiple calls to
sudo
, which obviously won't work if the system doesn't havesudo
installed (Debian minimal doesn't come installed with sudo). You could test to see if the script is already running as root and not callsudo
, though, to be quite honest, I'd just remove all instances of it altogether and instruct the user to run the script as root, using their own preferred method (and you could check for this at the beginning of the script and exit if not root).As an aside, the readme should probably mention that linux kernel headers are needed to build the libpfc kernel module.
Also, I'm not sure how hard it would be, but being able to build a static binary could be useful for running tests on machines without the necessary build environment.
Thanks!
The text was updated successfully, but these errors were encountered: