mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +03:00
add support for identityagent ssh_config option
This commit adds an `agent_socket` field to the session options and connects the config parser to that option. `SSH_OPTIONS_IDENTITY_AGENT` is added to allow applications to set this option for themselves. agent.c is updated to take the `agent_socket` value in preference to the `SSH_AUTH_SOCK` environment variable. Signed-off-by: Wez Furlong <wez@fb.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Andreas Schneider
parent
899ec9e519
commit
51a53cc6d4
@@ -476,6 +476,11 @@ int ssh_options_set_algo(ssh_session session,
|
||||
* Setting 0 will revert the value to defaults.
|
||||
* Default is 1024 bits or 2048 bits in FIPS mode.
|
||||
* (int *)
|
||||
|
||||
* - SSH_OPTIONS_IDENTITY_AGENT
|
||||
* Set the path to the SSH agent socket. If unset, the
|
||||
* SSH_AUTH_SOCK environment is consulted.
|
||||
* (const char *)
|
||||
*
|
||||
* @param value The value to set. This is a generic pointer and the
|
||||
* datatype which is used should be set according to the
|
||||
@@ -1056,6 +1061,22 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type,
|
||||
session->opts.rsa_min_size = *x;
|
||||
}
|
||||
break;
|
||||
case SSH_OPTIONS_IDENTITY_AGENT:
|
||||
v = value;
|
||||
SAFE_FREE(session->opts.agent_socket);
|
||||
if (v == NULL) {
|
||||
/* The default value will be set by the ssh_options_apply() */
|
||||
} else if (v[0] == '\0') {
|
||||
ssh_set_error_invalid(session);
|
||||
return -1;
|
||||
} else {
|
||||
session->opts.agent_socket = ssh_path_expand_tilde(v);
|
||||
if (session->opts.agent_socket == NULL) {
|
||||
ssh_set_error_oom(session);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ssh_set_error(session, SSH_REQUEST_DENIED, "Unknown ssh option %d", type);
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user