=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/readconf.c,v retrieving revision 1.318 retrieving revision 1.319 diff -u -r1.318 -r1.319 --- src/usr.bin/ssh/readconf.c 2019/12/20 02:42:42 1.318 +++ src/usr.bin/ssh/readconf.c 2019/12/21 02:19:13 1.319 @@ -1,4 +1,4 @@ -/* $OpenBSD: readconf.c,v 1.318 2019/12/20 02:42:42 dtucker Exp $ */ +/* $OpenBSD: readconf.c,v 1.319 2019/12/21 02:19:13 djm Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland @@ -905,6 +905,34 @@ case oForwardAgent: intptr = &options->forward_agent; + + arg = strdelim(&s); + if (!arg || *arg == '\0') + fatal("%s line %d: missing argument.", + filename, linenum); + + value = -1; + multistate_ptr = multistate_flag; + for (i = 0; multistate_ptr[i].key != NULL; i++) { + if (strcasecmp(arg, multistate_ptr[i].key) == 0) { + value = multistate_ptr[i].value; + break; + } + } + if (value != -1) { + if (*activep && *intptr == -1) + *intptr = value; + break; + } + /* ForwardAgent wasn't 'yes' or 'no', assume a path */ + if (*activep && *intptr == -1) + *intptr = 1; + + charptr = &options->forward_agent_sock_path; + goto parse_agent_path; + + case oForwardX11: + intptr = &options->forward_x11; parse_flag: multistate_ptr = multistate_flag; parse_multistate: @@ -926,10 +954,6 @@ *intptr = value; break; - case oForwardX11: - intptr = &options->forward_x11; - goto parse_flag; - case oForwardX11Trusted: intptr = &options->forward_x11_trusted; goto parse_flag; @@ -1722,6 +1746,7 @@ if (!arg || *arg == '\0') fatal("%.200s line %d: Missing argument.", filename, linenum); + parse_agent_path: /* Extra validation if the string represents an env var. */ if (arg[0] == '$' && !valid_env_name(arg + 1)) { fatal("%.200s line %d: Invalid environment name %s.", @@ -1839,6 +1864,7 @@ { memset(options, 'X', sizeof(*options)); options->forward_agent = -1; + options->forward_agent_sock_path = NULL; options->forward_x11 = -1; options->forward_x11_trusted = -1; options->forward_x11_timeout = -1; @@ -2615,7 +2641,6 @@ dump_cfg_fmtint(oClearAllForwardings, o->clear_forwardings); dump_cfg_fmtint(oExitOnForwardFailure, o->exit_on_forward_failure); dump_cfg_fmtint(oFingerprintHash, o->fingerprint_hash); - dump_cfg_fmtint(oForwardAgent, o->forward_agent); dump_cfg_fmtint(oForwardX11, o->forward_x11); dump_cfg_fmtint(oForwardX11Trusted, o->forward_x11_trusted); dump_cfg_fmtint(oGatewayPorts, o->fwd_opts.gateway_ports); @@ -2690,6 +2715,12 @@ dump_cfg_strarray(oSetEnv, o->num_setenv, o->setenv); /* Special cases */ + + /* oForwardAgent */ + if (o->forward_agent_sock_path == NULL) + dump_cfg_fmtint(oForwardAgent, o->forward_agent); + else + dump_cfg_string(oForwardAgent, o->forward_agent_sock_path); /* oConnectTimeout */ if (o->connection_timeout == -1)