[launchd-dev] Replacing the env variable set by SecureSocketWithKey.

Mihai Moldovan ionic at ionic.de
Sun Jul 6 08:21:26 PDT 2014


Hi,

I hope this list is still active. I haven't seen any posts on 2014 yet.

I'm currently trying to make gpg-agent launchd-compatible.

The plist for my LaunchAgent specifies SecureSocketWithKey for "GPG_AGENT_INFO".

This is, correctly, setting GPG_AGENT_INFO to the socket path created by launchd.
However, things are getting complicated here. I need GPG_AGENT_INFO to be
"sockpath:PID:1".

As far as I understood, I can pass environment values to launchd via
launch_msg(), passing them as dict entries (launch_data_dict_insert()).

This doesn't seem to work for GPG_AGENT_INFO, though, most likely because
SecureSocketWithKey is taking control of that env var.


I can remove the Socket part from the agent's plist and get a "correct" value in
GPG_AGENT_INFO, alas, the UNIX socket is not within launchd's control but
created by the gpg-agent daemon.


What I'd ultimately like to have is the following: letting launchd handle UNIX
socket creation and management (like SecureSocketWithKey, but not have any
environment variable set by launchd "yet"), fetch/query the generated sockpath
from launchd within gpg-agent and then pass back GPG_AGENT_INFO with a "sane"
value gpg-agent expects to launchd, so that it is available session-wide.


Defining an empty "<string/>" for SecureSocketWithKey so that launchd creates no
env var seems to work fine.
I'm having problems retrieving the sockpath, though.

Reading launchd's source code, I've gathered from support/launchctl.c that
LAUNCH_JOBSOCKETKEY_SECUREWITHKEY is just a wrapper and actually adds a
LAUNCH_JOBSOCKETKEY_PATHNAME dict with the secure socket path to the data array.

However, I have been unable to query a LAUNCH_JOBSOCKETKEY_PATHNAME from a
socket dict returned by launch_data_dict_lookup(checkin_response,
LAUNCH_JOBKEY_SOCKETS);

Any idea how I can get this data?


Any help is appreciated. :)


Best regards,



Mihai


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4265 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://lists.macosforge.org/pipermail/launchd-dev/attachments/20140706/cbba1134/attachment.p7s>


More information about the launchd-dev mailing list