MacOS SSH-Agent中的``-l`标志是什么?

发布于 2025-02-10 04:31:55 字数 153 浏览 1 评论 0原文

当我搜索手动启动SSH-Ancent时,我还找到了Process /usr/bin/ssh-agent -l <​​/code>。我尝试在人类中找到描述,但我不能。什么是-l <​​/code>标志,它可以有用吗?

When I search PID of manualy started ssh-agent I also found process /usr/bin/ssh-agent -l. I try to find description in man but I can't. What is the -l flag and can it be useful?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只是我以为 2025-02-17 04:31:56

查看,它似乎是一个无证件标志创建进程(l_flag是在命令行上给出-l <​​/code>的设置):

#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

我不熟悉aughterd的概念,但是检查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
        }
    }
[...]

Looking at the source code, it seems to be an undocumented flag that is related to ssh-agent's integration into macOS' launchd, namely how the unix file socket used to communicate with other processes is created (l_flag is set if -l is given on the command line):

#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

I'm not familiar with launchd's concepts, but checking the configuration of the ssh-agent service shows a corresponding section:

$ 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
        }
    }
[...]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文