@@ -14,7 +14,7 @@ def runas_daemon(argv)
1414 if IS_BASHRC
1515 warn "crew-sudo: Daemon started with PID #{ File . read ( PID_FILE_PATH ) } "
1616 else
17- message <<~EOT , loglevel : error
17+ message <<~EOT , loglevel : : error
1818 crew-sudo daemon (process #{ File . read ( PID_FILE_PATH ) } ) is already running.
1919
2020 Use `#{ PROGNAME } --daemon --replace` to replace the running daemon
@@ -31,8 +31,11 @@ def runas_daemon(argv)
3131 File . chmod ( 0o660 , SOCKET_PATH )
3232
3333 # daemonize
34- unless ARGV . include? ( '--foreground' )
34+ if ARGV . include? ( '--foreground' )
35+ warn "crew-sudo: Daemon started with PID #{ Process . pid } "
36+ else
3537 Process . daemon ( false , true )
38+ warn "crew-sudo: Daemon started with PID #{ Process . pid } "
3639
3740 # redirect output to log
3841 $log = File . open ( DAEMON_LOG_PATH , 'w' )
@@ -47,16 +50,14 @@ def runas_daemon(argv)
4750 Process . setproctitle ( 'crew-sudo daemon process' )
4851 File . write ( PID_FILE_PATH , Process . pid )
4952
50- warn "crew-sudo: Daemon started with PID #{ Process . pid } "
53+ message " Daemon running with PID #{ Process . pid } "
5154
52- if Process . uid . zero?
55+ if Process . euid . zero?
5356 message 'Daemon running with root permission.'
5457 else
55- message "Daemon running under UID #{ Process . uid } ."
58+ message "Daemon running under UID #{ Process . euid } ."
5659 end
5760
58- message "Started with PID #{ Process . pid } "
59-
6061 Socket . accept_loop ( @server ) do |socket , _ |
6162 client_pid , client_uid , client_gid = socket . getsockopt ( :SOL_SOCKET , :SO_PEERCRED ) . unpack ( 'L*' )
6263
0 commit comments