Skip to content

Allow sudo selfcontrol-cli to start a block without reinstalling selfcontrold #893

@EternalDebugger

Description

@EternalDebugger

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:

  1. the daemon automatically unload after two minutes, this can be easily resolved by updating INACTIVITY_LIMIT_SECS = 60 * 60 * 24 * 365 * 10 in Daemon/SCDaemon.m and rebuild selfcontrold.
  2. However, it appears in the logic of cli-main.m, it always calls installDaemon, which runs SMJobRemove and SMJobBless, 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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions