Skip to main content
Solved

Deploy homebrew

  • July 24, 2017
  • 62 replies
  • 571 views

Show first post

62 replies

Forum|alt.badge.img+4
  • Contributor
  • April 14, 2020

@kenny.botelho Your autobrew script is running homebrew installation as root, that's not recommended for good reasons. You are than changing the permissions of everything in /usr/local to be owned by that user, that is not not good security hygine.

@JustGoogleIt85 Cool script however the part below is unnecessary. Touch fails if the file already exists.

if [[ -f ~/.zshrc ]] ; then
    log ".zshrc already exists"
    echo "" >> ~/.zshrc
else
    log "Creating .zshrc"
    touch ~/.zshrc
fi

if [[ -f ~/.bash_profile ]] ; then
    log ".bash_profile already exists"
    echo "" >> ~/.bash_profile
else
    log "Creating .bash_profile"
    touch ~/.bash_profile
fi
QuotedText


Forum|alt.badge.img+8
  • New Contributor
  • April 14, 2020

@bobbyjohn That's actually the whole point of AutoBrew. So you CAN perform the Homebrew install as root, and it's not much different than running the original installer and interactively running through the sudo prompts. The chown is also standard practice for Homebrew installation repairs. Could you perhaps share a bit more about good security hygiene for /usr/local/ ?


Forum|alt.badge.img+4
  • Contributor
  • April 15, 2020

/usr/local can contain binaries and other files that are owned by root and should not be writable by any other user and may cause privilege escalations or denial of service. The Jamf executable for example, can be in /usr/local and should be owned by ROOT only while others have permission to execute it. What happens when the current user is able to modify it? They can modify it, leading to priv escalation or delete it and so on. Maybe its not part of your specific threat model but say its a school where the student doesn't have root access but can get it with this? Or maybe just delete the binary because why not?

It is VERY different than the original installer because the original installer changes ownership of individual folders specific to its need.


Forum|alt.badge.img+4
  • Contributor
  • April 15, 2020

@darren.leong The script works fine, due to where. the error is happening (SSL_read function) its something to do with issues at layer 4 or lower. Maybe some caching is preventing it, some security policy, something else? Try doing wget of the repo.


Forum|alt.badge.img+8
  • New Contributor
  • April 15, 2020

Fair point @bobbyjohn ,

I've updated the source to now have more precision permission changes with the Homebrew install. This would mimic the behavior of how the "original installer changes ownership of individual folders specific to its need."


Forum|alt.badge.img+4

@honestpuck I am trying the one you posted at the URL and I'm still getting this error:

Mon May 18 14:55:08 EDT 2020 - Updating Homebrew
Error: /usr/local is not writable. You should change the
ownership and permissions of /usr/local back to your
user account:
  sudo chown -R $(whoami) /usr/local

Any suggestions?


Forum|alt.badge.img+4

@mattsvensson Where did you add this?

Change ownership to user
/usr/sbin/chown -R $ConsoleUser /usr/local/*

Forum|alt.badge.img+4

NVM. I just tried AutoBrew by @kenny.botelho and it worked like magic. Thanks


ImAMacGuy
Forum|alt.badge.img+23
  • Esteemed Contributor
  • June 24, 2020

@kenny.botelho Your Autobrew script seems to be failing whenever we try to install it... looks like Xcode related...

xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.
Failed during: git config --replace-all homebrew.analyticsmessage true
==> Next steps:
- Run `brew help` to get started
- Further documentation:
chown: /usr/local/bin/brew: No such file or directory
chown: /usr/local/share/doc/homebrew: No such file or directory
chown: /usr/local/share/man/man1/brew.1: No such file or directory
chown: /usr/local/share/zsh/site-functions/_brew: No such file or directory
chown: /usr/local/etc/bash_completion.d/brew: No such file or directory
bash: /usr/local/bin/brew: No such file or directory
bash: /usr/local/bin/brew: No such file or directory
bash: /usr/local/bin/brew: No such file or directory
AutoBrew Installation Failed

Forum|alt.badge.img+8
  • New Contributor
  • June 24, 2020

@jwojda This seems specific to your device I'm afraid so please ask for help in Homebrew Discourse instead.


MacJunior
Forum|alt.badge.img+9
  • Valued Contributor
  • July 19, 2021

Can someone share their script to install Homebrew on M1 Macs?


Forum|alt.badge.img+1
  • New Contributor
  • November 22, 2023

Can someone share their script to install Homebrew on M1 Macs?   Installomator does not put correct user/path.