当我inputssh remote-host command , sshd会为我运行bash -c command 。
sshd如何知道用-c选项调用bash ?
哦,该死的,这是硬编码在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标准吧?