osx - How to load launch daemon to have an access to WindowServer in LoginWindow context? -


i developing application osx can access windowserver. application (lets call agent) first loaded every user logged in. searching running loginwindow processes, , load plist each user (with of bsexec set proper context).

  • ps -ef | grep loginwindow

    501 90425 1 0 10:46am ?? 0:01.21 /system/library/coreservices/loginwindow.app/contents/macos/loginwindow console

    502 90721 90426 0 10:54am ?? 0:00.36 /system/library/coreservices/loginwindow.app/contents/macos/loginwindow

    0 91103 90426 0 11:01am ?? 0:02.57 /system/library/coreservices/loginwindow.app/contents/macos/loginwindow

here have 3 loginwindow processes 2 logged users (not active), 1 login window (active).

  • i run:

    sudo launchctl bsexec 90721 sudo -u 502 launchctl load -wf -s aqua /library/launchagents/com.myagent.plist 

for each of logged users.

  • and

    sudo launchctl bsexec 91103 launchctl load -wf -s loginwindow /library/launchagents/com.myagent.plist 

for login window.

the problem agent starting on login window (as root) causing error:

may 15 15:47:01 mac-mini.local wsagent.bin[99201]: kcgerrorfailure: user not allowed access window system right now. may 15 15:47:01 mac-mini.local wsagent.bin[99201]: kcgerrorinvalidconnection: cgsgeteventport: invalid connection may 15 15:47:01 mac-mini.local wsagent.bin[99201]: _registerapplication(), failed establish default connection windowserver, _cgsdefaultconnection() null. may 15 15:47:01 mac-mini.local wsagent.bin[99201]: cgsregisterconnectionnotifyproc called invalid connection may 15 15:47:01 --- last message repeated 1 time --- may 15 15:47:01 mac-mini.local wsagent.bin[99201]: kcgerrorinvalidconnection: cgssetconnectionproperty: invalid connection may 15 15:47:01 mac-mini.local wsagent.bin[99201]: kcgerrorinvalidconnection: error enabling suspendresume handling 

but when log in user, , log out login window again, agent starts created , can access window server without problems.

problem occurs on newer osx versions (on 10.6.8 example works fine).

i'm running out of ideas, want have working on login window. thank in advance help!

/ghulash


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -