comparison cli-main.c @ 1516:33b872649eb7

Add dbclient '-J &fd' option for a file descriptor Based on patch by Harald Becker
author Matt Johnston <matt@ucc.asn.au>
date Sun, 18 Feb 2018 15:12:15 +0800
parents 0c16b4ccbd54
children d5cdc60db08e
comparison
equal deleted inserted replaced
1515:d68d61e7056a 1516:33b872649eb7
156 static void cli_proxy_cmd(int *sock_in, int *sock_out, pid_t *pid_out) { 156 static void cli_proxy_cmd(int *sock_in, int *sock_out, pid_t *pid_out) {
157 char * ex_cmd = NULL; 157 char * ex_cmd = NULL;
158 size_t ex_cmdlen; 158 size_t ex_cmdlen;
159 int ret; 159 int ret;
160 160
161 /* File descriptor "-j &3" */
162 if (*cli_opts.proxycmd == '&') {
163 char *p = cli_opts.proxycmd + 1;
164 int sock = strtoul(p, &p, 10);
165 /* must be a single number, and not stdin/stdout/stderr */
166 if (sock > 2 && sock < 1024 && *p == '\0') {
167 *sock_in = sock;
168 *sock_out = sock;
169 return;
170 }
171 }
172
173 /* Normal proxycommand */
174
175 /* So that spawn_command knows which shell to run */
161 fill_passwd(cli_opts.own_user); 176 fill_passwd(cli_opts.own_user);
162 177
163 ex_cmdlen = strlen(cli_opts.proxycmd) + 6; /* "exec " + command + '\0' */ 178 ex_cmdlen = strlen(cli_opts.proxycmd) + 6; /* "exec " + command + '\0' */
164 ex_cmd = m_malloc(ex_cmdlen); 179 ex_cmd = m_malloc(ex_cmdlen);
165 snprintf(ex_cmd, ex_cmdlen, "exec %s", cli_opts.proxycmd); 180 snprintf(ex_cmd, ex_cmdlen, "exec %s", cli_opts.proxycmd);