Opened 3 weeks ago

Last modified 3 weeks ago

#69854 new defect

`port` instructs users to start LaunchAgents with `sudo port load`

Reported by: RJVB (René Bertin) Owned by:
Priority: Normal Milestone:
Component: base Version:
Keywords: Cc:
Port:

Description

https://github.com/macports/macports-base/blob/026bfbd86b4195477e277330eedd7372b5d6ad80/src/port1.0/portstartupitem.tcl#L231

The startupitem feature unconditionally adds a note instructing the user s/he can [un]load the created launchd item(s) via sudo port [un]load.

I think that's wrong for LaunchAgents which (AFAIK) are supposed to run under the user's own ID.

Change History (2)

comment:1 Changed 3 weeks ago by jmroot (Joshua Root)

Yes, that works correctly to load whatever mix of LaunchDaemons and LaunchAgents the port may define.

comment:2 Changed 3 weeks ago by RJVB (René Bertin)

Hmmm, it looks like that requires SUDO_USER to be set, which I'll assume is the case with a normally configured set-up.

The message remains a bit misleading IMHO as it suggests (incorrectly) that non-admin users can't use the feature. I know they wouldn't normally see the message at all (and admin users also discover only after install a port that provides the feature), but I still think the message could be improved ... and added to long_description, maybe?

The easiest solution here would probably be to add something like startupitem.note so ports can override the standard message with a tailored one. (I'm thinking a port like port:dbus could benefit from that to summarise when to use which kind of bus.)

FWIW, I did find a way to override the note and remove the "sudo" instruction, but it looks like a bit of a hack:

    # startup item stuff that presumably triggers the installation of the add_notes callback

    proc modify_notes {} {
        global notes
        notes {*}[string map {"sudo " ""} ${notes}]
    }
    port::register_callback modify_notes

For some reasons neither notes.delete nor notes.replace worked here.

Note: See TracTickets for help on using tickets.