version 1.545, 2020/01/24 23:56:01 |
version 1.546, 2020/01/31 22:42:45 |
|
|
/* sshd_config buffer */ |
/* sshd_config buffer */ |
struct sshbuf *cfg; |
struct sshbuf *cfg; |
|
|
|
/* Included files from the configuration file */ |
|
struct include_list includes = TAILQ_HEAD_INITIALIZER(includes); |
|
|
/* message to be displayed after login */ |
/* message to be displayed after login */ |
struct sshbuf *loginmsg; |
struct sshbuf *loginmsg; |
|
|
|
|
static void |
static void |
send_rexec_state(int fd, struct sshbuf *conf) |
send_rexec_state(int fd, struct sshbuf *conf) |
{ |
{ |
struct sshbuf *m; |
struct sshbuf *m = NULL, *inc = NULL; |
|
struct include_item *item = NULL; |
int r; |
int r; |
|
|
debug3("%s: entering fd = %d config len %zu", __func__, fd, |
debug3("%s: entering fd = %d config len %zu", __func__, fd, |
sshbuf_len(conf)); |
sshbuf_len(conf)); |
|
|
|
if ((m = sshbuf_new()) == NULL || (inc = sshbuf_new()) == NULL) |
|
fatal("%s: sshbuf_new failed", __func__); |
|
|
|
/* pack includes into a string */ |
|
TAILQ_FOREACH(item, &includes, entry) { |
|
if ((r = sshbuf_put_cstring(inc, item->selector)) != 0 || |
|
(r = sshbuf_put_cstring(inc, item->filename)) != 0 || |
|
(r = sshbuf_put_stringb(m, item->contents)) != 0) |
|
fatal("%s: buffer error: %s", __func__, ssh_err(r)); |
|
} |
|
|
/* |
/* |
* Protocol from reexec master to child: |
* Protocol from reexec master to child: |
* string configuration |
* string configuration |
|
* string included_files[] { |
|
* string selector |
|
* string filename |
|
* string contents |
|
* } |
*/ |
*/ |
if ((m = sshbuf_new()) == NULL) |
if ((r = sshbuf_put_stringb(m, conf)) != 0 || |
fatal("%s: sshbuf_new failed", __func__); |
(r = sshbuf_put_stringb(m, inc)) != 0) |
if ((r = sshbuf_put_stringb(m, conf)) != 0) |
|
fatal("%s: buffer error: %s", __func__, ssh_err(r)); |
fatal("%s: buffer error: %s", __func__, ssh_err(r)); |
if (ssh_msg_send(fd, 0, m) == -1) |
if (ssh_msg_send(fd, 0, m) == -1) |
fatal("%s: ssh_msg_send failed", __func__); |
fatal("%s: ssh_msg_send failed", __func__); |
|
|
sshbuf_free(m); |
sshbuf_free(m); |
|
sshbuf_free(inc); |
|
|
debug3("%s: done", __func__); |
debug3("%s: done", __func__); |
} |
} |
|
|
static void |
static void |
recv_rexec_state(int fd, struct sshbuf *conf) |
recv_rexec_state(int fd, struct sshbuf *conf) |
{ |
{ |
struct sshbuf *m; |
struct sshbuf *m, *inc; |
u_char *cp, ver; |
u_char *cp, ver; |
size_t len; |
size_t len; |
int r; |
int r; |
|
struct include_item *item; |
|
|
debug3("%s: entering fd = %d", __func__, fd); |
debug3("%s: entering fd = %d", __func__, fd); |
|
|
if ((m = sshbuf_new()) == NULL) |
if ((m = sshbuf_new()) == NULL || (inc = sshbuf_new()) == NULL) |
fatal("%s: sshbuf_new failed", __func__); |
fatal("%s: sshbuf_new failed", __func__); |
if (ssh_msg_recv(fd, m) == -1) |
if (ssh_msg_recv(fd, m) == -1) |
fatal("%s: ssh_msg_recv failed", __func__); |
fatal("%s: ssh_msg_recv failed", __func__); |
|
|
fatal("%s: buffer error: %s", __func__, ssh_err(r)); |
fatal("%s: buffer error: %s", __func__, ssh_err(r)); |
if (ver != 0) |
if (ver != 0) |
fatal("%s: rexec version mismatch", __func__); |
fatal("%s: rexec version mismatch", __func__); |
if ((r = sshbuf_get_string(m, &cp, &len)) != 0) |
if ((r = sshbuf_get_string(m, &cp, &len)) != 0 || |
|
(r = sshbuf_get_stringb(m, inc)) != 0) |
fatal("%s: buffer error: %s", __func__, ssh_err(r)); |
fatal("%s: buffer error: %s", __func__, ssh_err(r)); |
|
|
if (conf != NULL && (r = sshbuf_put(conf, cp, len))) |
if (conf != NULL && (r = sshbuf_put(conf, cp, len))) |
fatal("%s: buffer error: %s", __func__, ssh_err(r)); |
fatal("%s: buffer error: %s", __func__, ssh_err(r)); |
|
|
|
while (sshbuf_len(inc) != 0) { |
|
item = xcalloc(1, sizeof(*item)); |
|
if ((item->contents = sshbuf_new()) == NULL) |
|
fatal("%s: sshbuf_new failed", __func__); |
|
if ((r = sshbuf_get_cstring(inc, &item->selector, NULL)) != 0 || |
|
(r = sshbuf_get_cstring(inc, &item->filename, NULL)) != 0 || |
|
(r = sshbuf_get_stringb(inc, item->contents)) != 0) |
|
fatal("%s: buffer error: %s", __func__, ssh_err(r)); |
|
TAILQ_INSERT_TAIL(&includes, item, entry); |
|
} |
|
|
free(cp); |
free(cp); |
sshbuf_free(m); |
sshbuf_free(m); |
|
|
|
|
case 'o': |
case 'o': |
line = xstrdup(optarg); |
line = xstrdup(optarg); |
if (process_server_config_line(&options, line, |
if (process_server_config_line(&options, line, |
"command-line", 0, NULL, NULL) != 0) |
"command-line", 0, NULL, NULL, &includes) != 0) |
exit(1); |
exit(1); |
free(line); |
free(line); |
break; |
break; |
|
|
load_server_config(config_file_name, cfg); |
load_server_config(config_file_name, cfg); |
|
|
parse_server_config(&options, rexeced_flag ? "rexec" : config_file_name, |
parse_server_config(&options, rexeced_flag ? "rexec" : config_file_name, |
cfg, NULL); |
cfg, &includes, NULL); |
|
|
/* Fill in default values for those options not explicitly set. */ |
/* Fill in default values for those options not explicitly set. */ |
fill_default_server_options(&options); |
fill_default_server_options(&options); |
|
|
if (connection_info == NULL) |
if (connection_info == NULL) |
connection_info = get_connection_info(ssh, 0, 0); |
connection_info = get_connection_info(ssh, 0, 0); |
connection_info->test = 1; |
connection_info->test = 1; |
parse_server_match_config(&options, connection_info); |
parse_server_match_config(&options, &includes, connection_info); |
dump_config(&options); |
dump_config(&options); |
} |
} |
|
|