当我搜索手动启动ssh-agent的PID时,我还找到了进程/usr/bin/ssh-agent -l
。我试着在人身上找到特征,但我找不到。什么是-l
标志,它有用吗?
查看源代码,它似乎是一个未记录的标志,与ssh-agent
集成到macOS的launchd
有关,即如何创建用于与其他进程通信的unix文件套接字(如果在命令行上给出-l
,则设置l_flag
):
#ifdef __APPLE_LAUNCHD__
if (l_flag) {
int *fds = NULL;
size_t count = 0;
result = launch_activate_socket("Listeners", &fds, &count);
if (result != 0 || fds == NULL || count < 1) {
errno = result;
perror("launch_activate_socket()");
exit(1);
}
size_t i;
for (i = 0; i < count; i++) {
new_socket(AUTH_SOCKET, fds[i]);
}
if (fds)
free(fds);
goto skip2;
} else {
#endif
prev_mask = umask(0177);
sock = unix_listener(socket_name, SSH_LISTEN_BACKLOG, 0);
if (sock < 0) {
/* XXX - unix_listener() calls error() not perror() */
*socket_name = ' '; /* Don't unlink any existing file */
cleanup_exit(1);
}
#ifdef __APPLE_LAUNCHD__
}
#endif
我不熟悉launchd
的概念,但是检查ssh-agent服务的配置会显示相应的部分:
$ launchctl print gui/1010/com.openssh.ssh-agent
[...]
sockets = {
"Listeners" = {
type = stream
path = /private/tmp/com.apple.launchd.4crvXaBll8/Listeners
secure key = SSH_AUTH_SOCK
owner uid = 1010
group id = 0
sockets = {
26 (bytes to read)
}
active = 1
passive = 1
bonjour = 0
ipv4v6 = 0
receive_packet_info = 0
}
}
[...]