toolinbox/iHosts

chmod every time I run iHosts?

Opened this issue · 7 comments

Is there a way to permanently set the permissions so that I don't have to run the chmod command everytime I restart my mac, or everytime I start iHosts?

@buckzilla Seems your macOS has some logic to reset permission for /etc/hosts after restart. Have no idea now.

In my side, it's fine, i.e., after reboot or restart iHosts, the /etc/hosts permission wasn't reset.

Logic? It's Mojave, but I don't have any special security software..?

Not sure about the logic to reset the file permission.

Am I the only person this is happening to? Really annoying, I can easily reset the permissions every reboot, but why am I required to? How do I get to the bottom of this?

dzsii commented

@buckzilla I have the same issue on a fresh Ventura installation without any specific security setting. Did you find the solution to the problem?

I have some workaround for change /etc/hosts permission on start

  1. Open Terminal.app
  2. Create file /Library/LaunchDaemons/com.ihosts.etc.hosts.fix.plist with sudo: sudo nano /Library/LaunchDaemons/com.ihosts.etc.hosts.fix.plist
  3. Input this text (dont forget replace your_username string on your username):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>com.ihosts.etc.hosts.fix</string>
    <key>ProgramArguments</key>
    <array>
      <string>chmod</string>
      <string>+a</string>
      <string>'user:your_username:allow write'</string>
      <string>/etc/hosts</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
  </dict>
</plist>
  1. Run sudo launchctl load /Library/LaunchDaemons/com.ihosts.etc.hosts.fix.plist
    Reboot and check.

Am I the only person this is happening to? Really annoying, I can easily reset the permissions every reboot, but why am I required to? How do I get to the bottom of this?

You are not. I have exactly the same problem . Running MacOS 13.5.