2

I'm trying to get synergy to load when my mac starts up so I can use my mouse/keyboard to log in. I followed these instructions

http://sourceforge.net/p/synergy2/discussion/199580/thread/76cf630a

Where my synology is installed in /Applications/Synergy.app/

The plist file looks like this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>KeepAlive</key> <true/>
    <key>Label</key> <string>net.sourceforge.synergy2.loginwindow</string>
    <key>LimitLoadToSessionType</key> <string>LoginWindow</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Applications/Synergy.app/Contents/MacOS/synergyc</string>
        <string>-f</string>
        <string>-1</string>
        <string>--name</string>
        <string>mini</string>
        <string>--debug</string>
        <string>WARNING</string>
        <string>192.168.1.200</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

But I'm getting these errors in /var/log/system.log

synergyc[220]: 3891612: (connect_and_check) Untrusted apps are not allowed to connect to or launch Window Server before login.

The files are all owned correctly

-rwxr-xr-x  1 root  wheel   893040 May  2 21:07 Synergy
-rwxr-xr-x  1 root  wheel  3999988 May  2 21:07 synergyc
-rwxr-xr-x  1 root  wheel  4269168 May  2 21:07 synergys

I've removed the quarantine

xattr -d com.apple.quarantine /Applications/Synergy.app/Contents/MacOS/*

I don't know what else to do? Why is OSX being so difficult? What else can I try?

p.s. I tried the hook method but that didn't work either. This approach looks cleaner.

Blorgbeard
  • 101,031
  • 48
  • 228
  • 272
reza
  • 1,329
  • 2
  • 22
  • 37

1 Answers1

4

From Apple's developer tech note on Daemons and Agents:

If, in Mac OS X 10.5 and later, you see a message like that shown in Listing 9 you might mistakenly think that the solution is to get the system to 'trust' your application, perhaps via code signing.

Listing 9: Pre-Login Trust Message

Untrusted apps are not allowed to connect to or launch Window Server before login.

However, this isn't the case. This message is really telling you is that you're trying to connect to the window server from the wrong context. You see this message if you try to connect to the global window server service from outside of the pre-login context before the user has logged in; typically this means that you're trying to use the window server from a daemon.

You should not attempt to fix this by convincing the window server to trust your program; doing so will just cause other problems further down the road. For example, if you do successfully connect to the window server from your daemon, you still have to deal with window server lifecycle issues described previously.

Instead, you should fix this problem by changing your code to run in the correct context. If you need to connect to the window server in a pre-login context, create a pre-login launchd agent. For an example of this, see Sample Code 'PreLoginAgents'.

It looks to me like the "right" way to do this would involve some rewriting of synergy itself (see the Sample Code link above). There's a synergy bug report on this, filed 3 years ago with no real action... I think if you want it fixed it's up to you to do it.

Gordon Davisson
  • 118,432
  • 16
  • 123
  • 151
  • Would writing a wrapper be possible, or does synology need patching? Did the solution I posted work pre-10.5 then? I'm surprised this problem hasn't been raised more often. – reza Sep 04 '13 at 07:44
  • I'm pretty sure it needs patching. You might be able to use `launchctl bsexec` in a wrapper to attach to the right Mach bootstrap context, but from the sample code it looks like the program itself needs to call `-[NSWindow setCanBecomeVisibleWithoutLogin:]` (Cocoa) or set `kHIWindowBitCanBeVisibleWithoutLogin` (Carbon) before it can do much with the UI. – Gordon Davisson Sep 04 '13 at 19:15
  • Though I'm not sure if it does. It just allows me to control the mouse/keyboard. There is nothing that becomes visible -- does it still need to become visible to work? – reza Sep 05 '13 at 18:52
  • I'm not really sure, you'd have to try. The wrapper approach I'm thinking of would have to find the PID of some process in the right context (probably either the window server itself, or loginwindow -- but be aware there may be more than one due to fast user switching sessions and the like), and use `launchctl bsexec RelevantPID /Applications/Synergy.app/Contents/MacOS/synergyc ...` to fire off synergy. You may have to experiment with different .plist options to get it to relaunch for each new loginwindow. – Gordon Davisson Sep 05 '13 at 19:00
  • None of this works in el captain, getting a app to emit CGEventPost in loginwindow even using prelogin agent code fails with the error in the question given above – Sai Prasanna Jan 04 '17 at 11:24