summaryrefslogtreecommitdiffhomepage
path: root/cli-main.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2018-02-18 15:12:15 +0800
committerMatt Johnston <matt@ucc.asn.au>2018-02-18 15:12:15 +0800
commit1656db9e58e7e8188e4ca27ae4892b14949c56a5 (patch)
tree5bad3dbe30955cedc2acd5bfee1575aa140f2824 /cli-main.c
parent802dace05e8bce06bf4c7df9faadba779d60bb82 (diff)
Add dbclient '-J &fd' option for a file descriptor
Based on patch by Harald Becker
Diffstat (limited to 'cli-main.c')
-rw-r--r--cli-main.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/cli-main.c b/cli-main.c
index 09ff496..713cb09 100644
--- a/cli-main.c
+++ b/cli-main.c
@@ -158,6 +158,21 @@ static void cli_proxy_cmd(int *sock_in, int *sock_out, pid_t *pid_out) {
size_t ex_cmdlen;
int ret;
+ /* File descriptor "-j &3" */
+ if (*cli_opts.proxycmd == '&') {
+ char *p = cli_opts.proxycmd + 1;
+ int sock = strtoul(p, &p, 10);
+ /* must be a single number, and not stdin/stdout/stderr */
+ if (sock > 2 && sock < 1024 && *p == '\0') {
+ *sock_in = sock;
+ *sock_out = sock;
+ return;
+ }
+ }
+
+ /* Normal proxycommand */
+
+ /* So that spawn_command knows which shell to run */
fill_passwd(cli_opts.own_user);
ex_cmdlen = strlen(cli_opts.proxycmd) + 6; /* "exec " + command + '\0' */