version 1.504, 2019/06/14 04:13:58 |
version 1.505, 2019/06/28 13:35:04 |
|
|
break; |
break; |
case 'i': |
case 'i': |
p = tilde_expand_filename(optarg, getuid()); |
p = tilde_expand_filename(optarg, getuid()); |
if (stat(p, &st) < 0) |
if (stat(p, &st) == -1) |
fprintf(stderr, "Warning: Identity file %s " |
fprintf(stderr, "Warning: Identity file %s " |
"not accessible: %s.\n", p, |
"not accessible: %s.\n", p, |
strerror(errno)); |
strerror(errno)); |
|
|
if (config == NULL) { |
if (config == NULL) { |
r = snprintf(buf, sizeof buf, "%s%s%s", pw->pw_dir, |
r = snprintf(buf, sizeof buf, "%s%s%s", pw->pw_dir, |
strcmp(pw->pw_dir, "/") ? "/" : "", _PATH_SSH_USER_DIR); |
strcmp(pw->pw_dir, "/") ? "/" : "", _PATH_SSH_USER_DIR); |
if (r > 0 && (size_t)r < sizeof(buf) && stat(buf, &st) < 0) |
if (r > 0 && (size_t)r < sizeof(buf) && stat(buf, &st) == -1) |
if (mkdir(buf, 0700) < 0) |
if (mkdir(buf, 0700) == -1) |
error("Could not create directory '%.200s'.", |
error("Could not create directory '%.200s'.", |
buf); |
buf); |
} |
} |
|
|
control_persist_detach(); |
control_persist_detach(); |
debug("forking to background"); |
debug("forking to background"); |
fork_after_authentication_flag = 0; |
fork_after_authentication_flag = 0; |
if (daemon(1, 1) < 0) |
if (daemon(1, 1) == -1) |
fatal("daemon() failed: %.200s", strerror(errno)); |
fatal("daemon() failed: %.200s", strerror(errno)); |
} |
} |
|
|
|
|
debug3("%s: %s:%d", __func__, options.stdio_forward_host, |
debug3("%s: %s:%d", __func__, options.stdio_forward_host, |
options.stdio_forward_port); |
options.stdio_forward_port); |
|
|
if ((in = dup(STDIN_FILENO)) < 0 || |
if ((in = dup(STDIN_FILENO)) == -1 || |
(out = dup(STDOUT_FILENO)) < 0) |
(out = dup(STDOUT_FILENO)) == -1) |
fatal("channel_connect_stdio_fwd: dup() in/out failed"); |
fatal("channel_connect_stdio_fwd: dup() in/out failed"); |
if ((c = channel_connect_stdio_fwd(ssh, options.stdio_forward_host, |
if ((c = channel_connect_stdio_fwd(ssh, options.stdio_forward_host, |
options.stdio_forward_port, in, out)) == NULL) |
options.stdio_forward_port, in, out)) == NULL) |
|
|
out = dup(STDOUT_FILENO); |
out = dup(STDOUT_FILENO); |
err = dup(STDERR_FILENO); |
err = dup(STDERR_FILENO); |
|
|
if (in < 0 || out < 0 || err < 0) |
if (in == -1 || out == -1 || err == -1) |
fatal("dup() in/out/err failed"); |
fatal("dup() in/out/err failed"); |
|
|
/* enable nonblocking unless tty */ |
/* enable nonblocking unless tty */ |
|
|
if ((devnull = open(_PATH_DEVNULL, O_WRONLY)) == -1) |
if ((devnull = open(_PATH_DEVNULL, O_WRONLY)) == -1) |
error("%s: open %s: %s", __func__, |
error("%s: open %s: %s", __func__, |
_PATH_DEVNULL, strerror(errno)); |
_PATH_DEVNULL, strerror(errno)); |
if (dup2(devnull, STDOUT_FILENO) < 0) |
if (dup2(devnull, STDOUT_FILENO) == -1) |
fatal("%s: dup2() stdout failed", __func__); |
fatal("%s: dup2() stdout failed", __func__); |
if (devnull > STDERR_FILENO) |
if (devnull > STDERR_FILENO) |
close(devnull); |
close(devnull); |
|
|
int status; |
int status; |
|
|
while ((pid = waitpid(-1, &status, WNOHANG)) > 0 || |
while ((pid = waitpid(-1, &status, WNOHANG)) > 0 || |
(pid < 0 && errno == EINTR)) |
(pid == -1 && errno == EINTR)) |
; |
; |
errno = save_errno; |
errno = save_errno; |
} |
} |