What exactly did homebrew do to my permissions on these directories?
As far as I can tell, Homebrew lets your user own
/usr/local, with the group set to
staff). This applies to all subdirectories created through Homebrew within that directory. By default, I believe
/usr/localis owned by the
The other directories in
/usr/local (i.e. non-Homebrew) will probably be owned by your user but might have other group ownerships (e.g.
wheel). See: What is the difference between default groups on Mac OS X?
Finally, to see what permissions Homebrew works best with (or ships with?), check out this Gist: Fix permissions on /usr/local for Homebrew.
Is it safe to leave them changed, or does leaving them changed pose a security risk?
/usr/local isn't used for anything on OS X.
You can safely leave it owned by your user and the
admin group. When other installers put files and directories there, you'd be prompted for root access if they needed it, but this is unlikely to happen and would somewhat defeat the purpose of having a user-owned directory.
It's definitely not a security risk.
Is it perhaps advantageous to leave them changed, so that so that other package managers work more smoothly?
If a package manager needed to change permissions to be installed or work smoothly, it'd prompt you to. Even Homebrew checks the permissions and should warn you if they don't match certain criteria. You can confirm this by calling
MacPorts for example won't even use
/usr/local, but will install everything under
/opt/local by default. Of course you can put it in
/usr/local as well, but the MacPorts installer should take care of the permissions here. I'm fairly certain it would change ownership to
root here, whereas Homebrew works without elevated privileges.
Oh, and running MacPorts alongside a package manager that lives in
/usr/local is not a terribly good idea. See the MacPorts FAQ.
Fink again uses
/sw instead of any of the former directories and violates the Filesystem Hierarchy Standard in some way. It can also be installed to
/usr/local, and the same things as for MacPorts apply here as well.