by rbanffy · 16y ago · 0 comments
Ouch!
Say for instance you have a dev server, so security isn't as big a deal* used by a team of people, all of whom would want access to the same basic packages. It seems that /usr/local/ or some other world-visible place would be the location for this stuff.
That you don't have to be root is the same way that you don't necessarily have to be root to install programs in the usual MacOS way of running a GUI installer. If you are part of admin, you're already privileged to sudo anyway, so the protection you get is primarily psychological; you type 'sudo', and it triggers the part of your brain that pays much closer attention to what you put on the command-line.
But as I mentioned to rbanffy, it is very possible I am missing a key risk that makes this a very bad thing to do. I am open to enlightenment. ;-)
I'm actually pretty excited to try out homebrew and install everything in ~/ with my new MBP which I'll purchase as soon as the next refresh comes. Currently I'm still on 10.5 with a system that has been forward ported via Time Machine backups and account copy-on-install going back to a 2004 PowerBook. The prospect of having a completely vanilla system with all customizations isolated to my home directory is pretty exciting.
Then again, making /usr/local writable by admins goes along with the OS X convention of giving admins write permission to /Applications but I'm not a fan of that either.
This becomes a much larger problem if something runs things from /usr/local with increased privileges -- something from launchd run as root, for instance.
I was originally thinking just from the perspective of the active user, but a lot of things get run without the logged in user's knowledge, and with a varying level of privilege.
Ok, yeah, I agree with the original poster of this thread: yikes, time to start chmodding things.
(For non-average users, the hacked binaries will secretly steal your personal information, so that's bad. But this only happens in real life... well, never.)
However the suggested step is suggested because:
1. On OS X /usr/local isn't even there on a fresh install, so nothing that should run as root is there by default.
2. Mostly people use Homebrew to install a few tools that are missing, these tools don't need to run as root, so they are as vulnerable as TextMate is (because you dragged it from the DMG to /Applications and it installed as your user).
Now you can argue that you should thus install to ~. And you can of course. However I've found over the last eight months that a great deal of build systems have bugs and don't find dependencies if you install the deps outside of /usr or /usr/local. So for a trouble free life we suggest /usr/local.
Finally sudo is dangerous. You should only use it with tools you trust. Do you really trust a half baked Makefile made by a developer who doesn't really know how to write Makefiles?
All in all I think depriviledging /usr/local is safe and the least hassle for Homebrew on OS X.
I suspect that there are security implications regarding this when done on more of a server-style environment. Perhaps that is what you were saying 'Ouch!' about?
Or maybe you were thinking of another pain point that isn't occurring to me right now?
But… don't sudo!
Homebrew can be used with or without sudo, but, OS X was designed to minimise sudo use, you only need it occasionally. For example, as long as your user is in the admin group, this just works:
cpan -i MP3::Info
Using sudo all the time is annoying, but far worse — it conditions you to type in your root password without thinking about it. Homebrew compliments OS X so you are unlikely to install anything that really needs to be chown:root. Let this be your last sudo for some time:
sudo chown -R `whoami` /usr/local
NOTE: If you already installed, eg. MySQL into /usr/local then the recursive chown may break it. Fixing MySQL should be as simple as:
sudo chown -R mysql:mysql /usr/local/mysql
Also 'inane blogspam' seems a bit much, no?
You don't have to sudo
It's up to you
I didn't say that the README insists on not using sudo. I was responding to a claim that the Engine Yard blogger made up the method of reassigning /usr/local to a regular user. That's simply not true.