![sshd 如何知道调用 shell?](https://linux22.com/image/571102/sshd%20%E5%A6%82%E4%BD%95%E7%9F%A5%E9%81%93%E8%B0%83%E7%94%A8%20shell%EF%BC%9F.png)
当我输入时ssh remote-host command
,将为我sshd
运行。bash -c command
如何知道用选项sshd
来调用?bash
-c
答案1
哦,该死,这是在 OpenSSH 源代码中硬编码的。
来自OpenSSH 5.9p1源代码的session.c:
/*
* Execute the command using the user's shell. This uses the -c
* option to execute the command.
*/
argv[0] = (char *) shell0;
argv[1] = "-c";
argv[2] = (char *) command;
argv[3] = NULL;
execve(shell, argv, env);
perror(shell);
exit(1);
所以我猜这是一个 POSIX 标准吧?