*/
#include "includes.h"
-RCSID("$OpenBSD: ssh.c,v 1.61 2000/08/20 18:42:40 millert Exp $");
+RCSID("$OpenBSD: ssh.c,v 1.63 2000/08/28 20:19:52 markus Exp $");
#include <openssl/evp.h>
#include <openssl/dsa.h>
}
/* Cannot fork to background if no command. */
- if (fork_after_authentication_flag && buffer_len(&command) == 0)
+ if (fork_after_authentication_flag && buffer_len(&command) == 0 && !no_shell_flag)
fatal("Cannot fork into background without a command to execute.");
/* Allocate a tty by default if no command specified. */
int window, packetmax, id;
int in, out, err;
- /* If requested, let ssh continue in the background. */
- if (fork_after_authentication_flag)
- if (daemon(1, 1) < 0)
- fatal("daemon() failed: %.200s", strerror(errno));
-
- in = dup(STDIN_FILENO);
+ if (stdin_null_flag) {
+ in = open("/dev/null", O_RDONLY);
+ } else {
+ in = dup(STDIN_FILENO);
+ }
out = dup(STDOUT_FILENO);
err = dup(STDERR_FILENO);
if (in < 0 || out < 0 || err < 0)
- fatal("dump in/out/err failed");
+ fatal("dup() in/out/err failed");
/* should be pre-session */
init_local_fwd();
+ /* If requested, let ssh continue in the background. */
+ if (fork_after_authentication_flag)
+ if (daemon(1, 1) < 0)
+ fatal("daemon() failed: %.200s", strerror(errno));
+
window = 32*1024;
if (tty_flag) {
packetmax = window/8;