When running as user X, the keyword "as uid X" should be allowed without root

Issue #869 closed
Former user created an issue

I'm wk on my macOS. I'd like to just run monit in a separate terminal and do some monitoring/workflow improvements. Frankly, most of the monitrc is transferable between macOS <> Linux without changes. On Linux I installed monit with apt-get and it runs as root, so "as uid" keyword isn't a problem.

One of the cases where stuff gets problematic -- when running on macOS as UID wk and with monitrc:

check process hh matching "hh"
    start program = "/Users/wk/r/hh/_scripts/ctl.sh start" as uid "wk" with timeout 7 seconds
    stop  program = "/Users/wk/r/hh/_scripts/ctl.sh stop"  as uid "wk" with timeout 7 seconds
    if 3 restarts within 5 cycles then unmonitor

I get:

$ monit -I
/Users/wk/r/hh/monitrc:18: UID statement requires root privileges '"wk"'
/Users/wk/r/hh/monitrc:19: UID statement requires root privileges '"wk"'

If the "as UID" and the current UID are the same, there are no special requirements to be met to make that happen. I think it should be permitted without requiring root and failing

Comments (3)

  1. Mayur

    One of the solution can be by entering,

    $ sudo su


    $ monit -I

    hope this can help for some times.

  2. Mayur

    Another solution for this is to run monit using sudo,

    $ sudo monit -I
    $ sudo service monit restart

    Check if working.

  3. Tildeslash repo owner

    Yes, using as uid requires Monit to run as root of course. On macOS there is also the added complication of sip especially in Catalina.

  4. Log in to comment