Permissions errors Catalina running hdiutil, write to user home, and sudo #118
-
I have only tried this in Catalina, as I don't have an older MacOS handy right now. I wouldn't be surprised if it has to do with Catalina's extra security. I'm trying to write a formula for something that has a Makefile that runs hdiutil to create a dmg. When it tries to run the hdiutil create command to make the dmg file, it fails with an exit code 66. Running the formula with debug so I can break to a shell when the error is raised, I find that trying the hdiutil command by hand gets the same error. If I try to run the same hdiutil command from an ordinary shell it works fine. I also notice that in that shell if I try to With hdiutil -debug the lines the output at point of error look like
I can put together an example project and formula if this isn't enough to explain or reproduce the problem, but I thought I would just start with the questions 1) What is it in the environment the formula runs in that has less permission than an ordinary shell? 2) Any suggestions about the problem running hdiutil? To try this for yourself, in Catalina run a formula in debug that will raise an error so you end up in a shell that has the homebrew shell environment. Try running the commands
That just produces the error "hdiutil: create failed - Directory not empty" but you can see the exit code 66 by adding the Also try writing to a file in your users home directory (not $HOME in that environment) and try running something with sudo to verify those aren't allowed either. I don't have a problem with those not being allowed, but I thought maybe the explanation as to why those aren't would shed light on the permissions problem running hdiutil. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
All Homebrew builds are done in a temporary sandbox, so trying to do anything that ventures outside the directory where the build happens is probably best done in a
If it requires root, add an explanation for the user to do the necessary steps in the |
Beta Was this translation helpful? Give feedback.
-
In fact, if your formula's sole purpose is to build a DMG, with no intention of installing anything under the Homebrew hierarchy, you're much better off just writing a simple shell script instead. The only use for Homebrew I can think of for your use case is the cask mechanism, but that only tells Homebrew how to manage the installation of your DMG. You'd still have to build the DMG yourself. |
Beta Was this translation helpful? Give feedback.
post_install
runs after all the formula's files have been installed in/usr/local
(hence the name). That's how it can run "for both source and bottle installs", and going by what you've written so far, it's probably not suitable for your purposes.In fact, if your formula's sole purpose is to build a DMG, with no intention of installing anything under the Homebrew hierarchy, you're much better off just writing a simple shell script instead. The only use for Homebrew I can think of for your use case is the cask mechanism, but that only tells Homebrew how to manage the installation of your DMG. You'd still have to build the DMG yourself.