-
Notifications
You must be signed in to change notification settings - Fork 412
Description
Is your feature request related to a problem? Please describe.
I'm testing a use case where the main user of the Mac Laptop is a Standard user, and is not supposed to have admin password. I'd like this user can still trigger a block without entering the admin password, as the user is not supposed to know it.
The approach I'd like to use is to grant this user access to sudo selfcontrol-cli
without password via sudoers file. This will also allow selfcontrol-cli to call launchctl load
as superuser. Given that /Library/PrivilegedHelperTools/org.eyebeam.selfcontrold
should already be installed, this can smooth the experience as it can avoid the unnecessary privilege escalation dialog which requires admin password. It will also allow cronjob to automatically schedule blocks, fulfilling one of the most requested features in this repo.
The following is the sudoers file I'm testing with:
mainuser ALL=(ALL) NOPASSWD: /Applications/SelfControl.app/Contents/MacOS/selfcontrol-cli
There are two hurdles I ran into with this approach:
- the daemon automatically unload after two minutes, this can be easily resolved by updating
INACTIVITY_LIMIT_SECS = 60 * 60 * 24 * 365 * 10
inDaemon/SCDaemon.m
and rebuild selfcontrold. - However, it appears in the logic of cli-main.m, it always calls installDaemon, which runs
SMJobRemove
andSMJobBless
, both will require privilege escalation dialog and admin password, hence defeating the purpose of what I want to achieve.
Is there a way to avoid calling installDaemon function but still allow selfcontrol-cli to start a blocking session?