eprev / locationchanger

Change OS X’s network location based on the name of Wi-Fi network
404 stars 67 forks source link

☝🏻 Different behavior on macOS 13 Ventura #28

Open Gems opened 1 year ago

Gems commented 1 year ago

Launch Agents' behavior has been changed in the new version of macOS 13 Ventura.

Upon the network configuration change, the locationchanger script gets running several times: one time under the root user and the other time under the user registered the Launch Agent.

In case the ~/.locations/locations.conf configuration file is used to define an alias for a wireless network, the run under the root user doesn't see it because the CONFIG_FILE=$HOME/.locations/locations.conf path in case of root user gets resolved to /.locations/locations.conf which doesn't exist.

This leads to the "Automatic" location being resolved for the root user; therefore, the location gets changed back and forth from Automatic to the one specified in the ~/.locations/locations.conf.

I fixed it by moving the configuration file to /usr/local/etc/.locations/location.conf making it accessible for all the users, though it's not what would fit the original design.

The other way to fix it could be that the runs under the root user just get simply ignored. This wasn't an option for me because upon location change I got to re-route IP traffic and sudo is required for that. I could've done it with sudoers and more custom scripts though.

In summary, I suggest the latter for the amendments to the implementation.

Cheers ✌🏻 Ed