I'm using The Pritunl VPN software for one of my Mac's user accounts. The software installer creates a system LaunchDaemon found under /Library/LaunchDaemons
called com.pritunl.service.plist
Unfortunately this service remains active when I log out from the user profile it's intended for, causing the VPN connection to also remain active for different user accounts.
What I would like to do is to remove this service from the /system/ and add it as a /user/username startup service. My intention is for the service to be started whenever I log in with the specific user and for it to stop whenever the user is logged out.
What I've tried to do so far is to unload the system service, remove the .plist from the system directory /Library/LaunchDaemons
and to move it to the user directory ~/Library/LaunchAgents
after which I attempted loading and registering it for the specific user account. I've not yet succeeded in performing these steps correctly as the user account in question does not have root access.
<?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.pritunl.service</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Pritunl.app/Contents/Resources/pritunl-service</string>
</array>
<key>KeepAlive</key>
<true/>
<key>Umask</key>
<integer>0</integer>
</dict>
</plist>
sudo launchctl list com.pritunl.service
{
"LimitLoadToSessionType" = "System";
"Label" = "com.pritunl.service";
"OnDemand" = false;
"LastExitStatus" = 0;
"PID" = XXXX;
"Program" = "/Applications/Pritunl.app/Contents/Resources/pritunl-service";
"ProgramArguments" = (
"/Applications/Pritunl.app/Contents/Resources/pritunl-service";
);
};
Reference material I've used: https://rakhesh.com/mac/macos-launchctl-commands/
When trying to learn more about LimitLoadToSessionType I've only managed to find this archived older documentation. https://developer.apple.com/library/archive/technotes/tn2083/_index.html
Trying to find it on the current documentation page hasn't resulted in what I'm looking for. https://developer.apple.com/search/?q=LimitLoadToSessionType
I've found this excellent post detailing a lot of related subjects. launchd: Confusion on semantics of bootstrap and bootout etc. after reading manual pages