macos ssh-agent 中的“-l”标志是什么?

dwd*_*ugr 5 macos ssh ssh-agent

当我搜索手动启动 ssh-agent 的 PID 时,我还发现了 process /usr/bin/ssh-agent -l。我试图在 man 中找到描述,但找不到。该标志是什么-l?它有用吗?

dor*_*ian 8

查看源代码,它似乎是一个与ssh-agent“集成到macOS”相关的未记录标志launchd,即如何创建用于与其他进程通信的unix文件套接字(如果在命令行上给出l_flag则设置):-l

#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 = '\0'; /* Don't unlink any existing file */
        cleanup_exit(1);
    }
#ifdef __APPLE_LAUNCHD__
    }
#endif
Run Code Online (Sandbox Code Playgroud)

我不熟悉 的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
        }
    }
[...]
Run Code Online (Sandbox Code Playgroud)