News for hackers. Stuff that matters.
Re:El Capitan and Homebrew by emanuelev on Thursday October 01, 2015 @07:44AM (#10310464)
I can't think of anything more standard than /usr/local/.
Re:El Capitan and Homebrew by quesera on Thursday October 01, 2015 @09:40AM (#10311003)
BSD and Linux use /usr/local, it's not universal.

But /usr/local has never been writable by non-privileged users.

Homebrew depends on that nonstandard and undesireable permissions model. Apple doesn't bend to accommodate an inappropriate use.

Hombrew doesn't want to use a location that is outside the default PATH, and they don't want to install with proper permissions, so they purposefully misinterpret the "standard".

Hijinks ensue, and people blame Apple, which is silly.

Re:El Capitan and Homebrew by DannyBee on Thursday October 01, 2015 @10:00AM (#10311155)
A. There is no real standard here B. Apple doesn't bend, period. They don't actually care whether the use is appropriate or inappropriate. C. Blaming this on homebrew is hilarious

Remind me again why i should need to reboot into recovery mode to create a directory?

Re:El Capitan and Homebrew by tptacek on Thursday October 01, 2015 @11:46AM (#10311955)
You need to boot into recovery mode to create /usr/local (or to disable SIP altogether) because /usr is immutable, so that code executing under an admin account can't inject itself into binaries (or into PATHs) under /usr.

I use Homebrew and will probably keep doing that because Homebrew is really convenient and just generally works better than MacPorts for me, but what Homebrew is demanding --- ownership over /usr/local --- is not in fact reasonable. It makes a lot of sense to me that OSX will want to keep perms on /usr/local (which is in everyone's PATH) locked down, and so it seems extra hacky that they're going to add a 'brew doctor' check to see if Software Update has "broken" those privileges.

The commenter upthread that suggested Homebrew should use ~/.homebrew or something by default is right.

Re:El Capitan and Homebrew by mzs on Thursday October 01, 2015 @02:47PM (#10313606)
And I contend that homebrew did not want to used ~/.homebrew because that would mean modifying files to add it to PATH and be additional testing for people that write recipes.
Re:El Capitan and Homebrew by tptacek on Thursday October 01, 2015 @03:04PM (#10313752)
And that's totally fine, and I let Homebrew own /usr/local too. What I'm not going to do is freak out when a totally sane and useful security feature breaks that install mode, especially when I could, if I cared that much about convenience, just take 30 seconds to disable the security feature.
Re:El Capitan and Homebrew by mzs on Thursday October 01, 2015 @03:35PM (#10314051)
I just want to make clear I'm not freaking out (and I know you're not either).

I would hope though that out of this someone would think, "Hmm... oh drat... yeah I guess this is just one of those things that nobody predicted at first. Shot I think it was a bad idea to have a user own /usr/local/. But you know, it's a good time to improve things... hmm... I know let's build and stage as nobody and then copy under /usr/local/! We still can have binary packages always work and nobody has to mess with PATH, man pages, or dynamic linker trivia. We might have to write something though that asks for a username and password, but whoa... OSX makes that surprisingly easy... I should do that!"

It's not going to be me cause I don't use homebrew, but that would be way better than these hacks that will ammount to people being encouraged to just disable SIP cause of the headache after ever software update.

Re:El Capitan and Homebrew by s73v3r on Thursday October 01, 2015 @05:09PM (#10314741)
Keep in mind that you can re-enable SIP right after you create the directory, if you had to create it at all.
Re:El Capitan and Homebrew by quesera on Thursday October 01, 2015 @10:23AM (#10311324)
A. /usr/local has never ever been writable by a nonprivileged user. Every standard that exists, including the principle of least surprise, is emphatic on that point. The security implications of "any other way" are massive.

B. If Linus or the FHS changed their ways in this, there would be outrage. It's inappropriate and just plain dumb. [edit: I shouldn't have said "dumb", please replace with "in violation of all guarantees of system integrity".]

C. See above.

You apparently have issues with SIP. That's a separate issue from the current thread, but OK. You should reboot to securely change nvram settings that will allow you to manipulate the protected zone of the file system (including /usr) because this concession to inconvenience saves you from privilege escalation attacks.

The real question is why you deleted /usr/local in the first place. It's standard OSX, and always has been. If you deleted it before SIP, but object to its absence now that SIP applies to the directory where it lives...I'm not sure how to help.

Re:El Capitan and Homebrew by DannyBee on Thursday October 01, 2015 @10:33AM (#10311392)
A. Single user systems are not the same as server systems, and plenty of single user systems have had the equivalent of /usr/local as writable. If you want to argue this security is worth it, that's a different argument. I suspect most people who just want to get shit done are going to find it a huge pain in the ass.

You can also argue these people are stupid.

As for standards, vendors follow FHS and friends exactly as far as it helps them justify whatever they want to do.

If you really want to argue from the perspective that "this is standard and that's the reason it's done", that seems awfully silly to me given the layout and other permissions of apple systems.

It's pretty non-FHS/etc to have /Applications be writable, for example.

B. let's be clear: there is outrage no matter what is changed and why, and the argument is always "it is inappropriate and dumb". So this statement is fairly independent of this change.

Re:El Capitan and Homebrew by quesera on Thursday October 01, 2015 @10:37AM (#10311425)
A. OSX is not a single user system. It inherits from various Unixes, and no Unix has ever had nonprivileged writability on any directory under /usr.

FHS does not apply to OSX in any way. Why do people think so?

Also, /Applications is not writable by nonprivileged users either!

Agreed on ~"changes yield outrage", but in this case, it's just a software application vendor violating obvious historical and specific guidelines from software OS vendor, and people blaming OS vendor when things break. This perplexes me.

Re:El Capitan and Homebrew by tptacek on Thursday October 01, 2015 @10:52AM (#10311515)
You might just as productively argue that there is no such thing as a modern single-user system, since Windows isn't that either. His point is pretty clear.

OTOH: The debate here is a little confusing. What SIP is doing w/r/t/ /usr/local isn't unprecedented; securelevels and the immutable flag could have the same effect on OpenBSD all the way back in the 1990s.

Re:El Capitan and Homebrew by quesera on Thursday October 01, 2015 @10:59AM (#10311574)
> You might just as productively argue that there is no such thing as a modern single-user system, since Windows isn't that either. His point is pretty clear.

Correct, and nonprivileged users can't install software globally on Windows either. Because it's now a modern OS, and that's how things are done. For very good reasons.

His point, as far as I can tell, amounts to: applications should be able to trash permissions on convenient directories and not have the OS complain or repair their damage.

Perhaps I'm being ungenerous here? I apologize if so.

On re read, I realize that tptacek is responding only to the SIP part of the discussion. OK, SIP is surprising to desktop computer users. But it's a good feature that requires a little adjustment to work with. But really not much, and none for the vast majority of users who don't muck with system directories.

Re:El Capitan and Homebrew by tptacek on Thursday October 01, 2015 @11:05AM (#10311630)
He's arguing that users should be able to elevate their privileges by supplying root's credentials and then create a simple directory without having to reboot.

I more agree with you than with him, but his argument seems pretty straightforward.

Re:El Capitan and Homebrew by quesera on Thursday October 01, 2015 @11:18AM (#10311731)
Well, if you unwind far enough, I think the original discussion was about why Homebrew has trouble using /usr/local. Where "using" means "owning, adding git repos to, changing permissions on, etc".

OSX suggests /usr/local as a good location to install software, but insists that the directory itself be owned by root, and protects the parent directory /usr under SIP.

My assertion is that Homebrew is using /usr/local incorrectly (and in contravention to all expectation), and that blaming Apple for the problems thereby created is inappropriate.

I also think SIP is a good thing.

Re:El Capitan and Homebrew by tptacek on Thursday October 01, 2015 @11:54AM (#10312049)
The "single user systems aren't the same as server systems" argument cuts both ways. It is also not a big deal to reboot a single-user systems.
Re:El Capitan and Homebrew by mzs on Thursday October 01, 2015 @03:00PM (#10313733)
I see what you are saying but please step back and take a wider view for a moment.

Even assuming OSX is a single user system (which is arguable), it is 2015 and should that single user be able to accidentally damage /usr/local? I think not, that by today an OS should help protect you from broken postinstall script or what not.

Moreover please think about this: homebrew is not wanting /usr/local/ root:admin but instead /usr/local/ `/usr/bin/whoami`:admin.

Further even on our laptops where there is just one user, I use a non-admin user. I have no problems using FUS, GUI prompted temporary admin permissions, or /usr/bin/login -p and sudo day-to-day, but homebrew has a problem with sudo.

Apple SIP has no problem with /usr/local/ 0:0 but homebrew does. Because of shortcuts homebrew has forced a number of poor decisions on it's users.

Re:El Capitan and Homebrew by alextgordon on Thursday October 01, 2015 @10:31AM (#10311372)
Where in FHS does it specify that system and user files should be put in

    /Applications
    /Library
    /Network
    /System
    /User Information
    /Users
    /Volumes

?
Re:El Capitan and Homebrew by quesera on Thursday October 01, 2015 @10:33AM (#10311394)
FHS does not apply to OSX. Never has, never will.
Re:El Capitan and Homebrew by tptacek on Thursday October 01, 2015 @10:52AM (#10311518)
He's asking because you brought FHS up.
Re:El Capitan and Homebrew by quesera on Thursday October 01, 2015 @11:04AM (#10311623)
Under B, as an example of standards by another vendor who would be pilloried if they allowed the same lackadaisical approach to preserving system permissions integrity. In response to the comment that Apple was being unreasonable.

Apologies if that was not clear.

Re:El Capitan and Homebrew by theptip on Thursday October 01, 2015 @12:21PM (#10312269)
There is a standard: http://news.stanford.edu/pr/2015/pr-worms-digest-plastics-09....

This is from RedHat. Not implemented by everyone, but modern OSes (e.g. CoreOS) seem to follow the patterns. CoreOS also do everything in their power to prevent you from mounting /usr as writeable.

Perhaps that doesn't pass your bar for 'real' though since it's not globally implemented ;)

Re:El Capitan and Homebrew by duskwuff on Thursday October 01, 2015 @12:36PM (#10312435)
I think that's the wrong link? (It's to a press release from Stanford's engineering department about plastic-eating worms...)
Re:El Capitan and Homebrew by Steuard on Thursday October 01, 2015 @09:55AM (#10311105)
It's been a while since I looked into it, but I opted to stick with MacPorts rather than Homebrew in large part because I got the impression that Homebrew wanted to own /usr/local rather than sharing it with other software. (Maybe that's inaccurate?) I still occasionally compile software by hand rather than through a package manager, and /usr/local has been the default target for a system-wide install on every Unix-style system that I've used in the past 20-ish years.

(Also, my wife and I both have active accounts on my machine, which makes me uneasy having files in a systemwide directory like /usr/local owned by one specific user. That also feels distinctly non-standard to me.)

Re:El Capitan and Homebrew by mjs on Thursday October 01, 2015 @11:42AM (#10311919)
> I got the impression that Homebrew wanted to own /usr/local rather than sharing it with other software

This is still accurate. Homebrew creates/manages /usr/local/.git. /usr/local/.gitignore starts with /* which is … not conventional.

Re:El Capitan and Homebrew by omribahumi on Thursday October 01, 2015 @10:14AM (#10311273)
It is possible to switch /usr/local according to [1], they state it's not recommended though.

[1] https://github.com/Homebrew/homebrew/blob/master/share/doc/h...

Re:El Capitan and Homebrew by halostatue on Thursday October 01, 2015 @11:09AM (#10311658)
I have used ~/.brew for years—it means that I have to do a slightly custom install every time I move to a new machine—but have never had a problem with it.
Re:El Capitan and Homebrew by _b8r0 on Thursday October 01, 2015 @10:32AM (#10311390)
As others have mentioned, /usr/local may be a fairly standard place to put stuff, but homebrew's permissions model changes the way /usr/local works.

Additionally, /usr/local is used by other applications, and there's no way to ensure that it isn't written over by them or by homebrew when installing or upgrading software.

Putting homebrew in /opt/homebrew means that you can have a systemwide directory that is self-contained, can have a working unix hierarchy underneath and should work.

Putting homebrew in ~/.homebrew/ lets you have a user-specific directory that is self-contained with a hierarchy underneath.

In an ideal world, homebrew would use something like /opt/* for systemwide hierarchy and ~/.homebrew for user-specific hierarchy. We don't live in an ideal world, so we just have to make do with fudges to /usr/local permissions for now.

Re:El Capitan and Homebrew by sigsergv on Thursday October 01, 2015 @08:37AM (#10310689)
Unfortunately, /usr/local is a total mess now. There is no internal package management in os x so applications could (and do) overwrite files in /usr/local. These conflicts are very annoying sometimes.
Re:El Capitan and Homebrew by deong on Thursday October 01, 2015 @07:45AM (#10310467)
Making/assuming /usr/local is 0777 is definitely not though.
Re:El Capitan and Homebrew by baldfat on Thursday October 01, 2015 @07:59AM (#10310532)
Re:El Capitan and Homebrew by alayne on Thursday October 01, 2015 @08:26AM (#10310641)
iuguy is not talking about use of /usr/local, but rather the fact that homebrew makes it owned by the user who installed homebrew with permissions so that the user can maintain homebrew packages without sudo. Usually /usr/local is owned by root.
Re:El Capitan and Homebrew by specialist on Thursday October 01, 2015 @01:19PM (#10312785)
Where am I supposed to put stuff like my shell scripts?

I'm now using /usr/local/bin.

I looked for a guide, no joy. The more opinionated, the better, because I just want to follow the norm.

Re:El Capitan and Homebrew by tptacek on Thursday October 01, 2015 @11:39AM (#10311889)
It is not standard for /usr/local to be writeable by users.
Re:El Capitan and Homebrew by twic on Thursday October 01, 2015 @09:25AM (#10310933)
/opt? MacPorts uses /opt/local.