5 ms·
The motivation seems laudable: obviously if I drag a file to the terminal I want it to be able to access it, one less confirmation dialog the better. But it's
by crazygringo 7y ago
The motivation seems laudable: obviously if I drag a file to the terminal I want it to be able to access it, one less confirmation dialog the better.
But it's the implementation that seems deeply flawed: that there's no obvious way to remove the permission afterwards, or even a record of it where you'd expect to look.
There seems to be a reasonable solution, however: as soon as the terminal window gets closed (and perhaps any background processes ended), the permissions get revoked. And even if your terminal process gets killed without cleanup, permissions would be revoked when your terminal app reboots or your computer restarts.
That could work, right?
- pmarreck 7y agoThe problem is that whoever implemented this change did not care to consider the full workflow lifecycle/consequences of enabling that change. And whoever did the code review on it ALSO failed to consider, or push for, dealing with it holistically and thoughtfully instead of just GSD’ing it (“gettin’ shit done”) This is not the Apple I grew up with.
- saagarjha 7y ago> The problem is that whoever implemented this change did not care to consider the full workflow lifecycle/consequences of enabling that change. Why do you think this is the case?
- floatingatoll 7y agoWhat if they did fully consider it, and reached a decision that you disagree with?
- jerf 7y agoI have a hard time buying that anyone deliberately shipped a security feature that permanently opens access short of rebooting the system into a special mode. A "full deliberation" would presumably include input from a dedicated security team, who would almost certainly say "better not to ship this at all and leave the old behavior in than ship this". So either the security team missed this entirely, or the security team was not consulted, or the security team is not empowered to stop this sort of half-baked feature from going in... I really can't come up with a pleasant scenario here.
- floatingatoll 7y agoOr the security team agrees that the benefit to the 99.9% of macOS users (that have no idea Terminal exists and accepts drag and drop) is worth the additional risk to the 0.1% who use this.
- jjoonathan 7y ago"We're trying to ship a system-wide permission lockdown, but we ran into unforeseen complications that will require more than a single release cycle to properly address. Instead of holding up the entire rollout for a release cycle, we'll ship the lockdown today and most users will benefit from it, but users that would otherwise run into the complications get a permissive bypass. Once the infrastructure to address the complications is in place, we'll get the lockdown working for them as well."
- jerf 7y agoThe near-complete inability to revert the permission is what argues against this. You could get this past a security team if you had the ability to revert it and Apple could document it away. It is the fact that it is a non-revertible thing (in any reasonable manner) that is the key here. The odds that there's some way to chain this in an interesting way are just too high, even if the security team couldn't immediately come up with it.
- linuxdude314 7y agoSure there is; monitor the process and when it terminates remove permissions. It's not like the kernel doesn't have ABIs to do this. I'm sure its not _that_ simple to implement in actuality, but from a back of the napkin design perspective its not too hard to appreciate.
- kccqzy 7y agoWhich process? Remember you are usually (but not always) at the command line prompt to pass an argument when you drag things to the Terminal. You can't trivially find out the process(es) that gets run from there so you are tracking the shell. Do you wait till the shell exits? Many developers spend months in a single shell. What if the process forks? What if the process double-forks to become a daemon, and then Terminal quits? Who removes the xattr then when Terminal isn't even running? Does the kernel now remember that and need to do I/O when _exit(2) is called? What if the process forks and itself exits? Does the permission gets revoked upon the parent process's exit and the child process's access suddenly get revoked? If so, does the opened file descriptor still works or it becomes unusable? If the file descriptor still works even though the on-disk file doesn't contain the permission xattr, would the file descriptor still continue to have special access when transmitted over a UNIX socket to an unrelated process? Do you instead track the original PGID instead of PID? Then what if setpgid(2) is called? What if the system loses power and no one cleans up the permissions? Do you keep a log of files with such xattrs and clean them at next boot? What if at next boot the file system isn't mounted or mounted at a different mount point?
- TazeTSchnitzel 7y agoPerhaps Apple found that the path might get stored somewhere by a terminal app, and it would annoy the user to have to re-authorise it later?
- Someone 7y agoNot really. Consider the case where are editing a configuration file for some service, need to type a file path, and drag in a folder from the Finder instead. Even simpler, if you write a small shell script with a hard-coded path in it that you run occasionally, you expect that script to keep running even across reboots. That means that, _if Terminal.app automatically adds a permission_, that permission has to be fairly permanent. In both cases, under your suggested solution, both scripts would work when you test them, and then silently break when you close the terminal window. I do wonder whether Terminal.app should automatically add that permission, though. If, instead of using emacs/pico/nano/vim, you use a GUI app to edit that script, that doesn’t happen, either, does it?
- pcr910303 7y agoActually, that wouldn't work; AFAIK the binary that executes the script needs to have permission, so for example if you're adding a cron script cron has to have the permission, not the Terminal.app, since the cron script running has nothing to do with Terminal.app. It's confusing. :-(
- oldmanhorton 7y agoThis is not always the case though - in order to run some applescripts, you need accessibility permissions... But you grant that to terminal.app, not applescript or not even bash that invokes applescript
- Someone 7y agoYou probably are right about that, but it can’t be fully correct. If I type “cat ”, drag in a file, and hit return, it isn’t Terminal.app that reads the file, but cat, launched by my shell (and that’s the simple case; nothing forbids me from nesting a few shells, a few sudo’s, etc. before accessing a file) ⇒ this special permission must either directly apply to all command-line tools or always be inherited on fork and/or execve (it cannot require a magic system call, as the command-line tool reading or writing data might not be Apple-supplied) I can see how opening this door “just long enough” gets hairy very easily. So, as others suggest, this may have been implemented as a “OK, let’s do it this way for now, and try and figure out whether we can better later”.