diff options
author | Jakub Jelen <jjelen@redhat.com> | 2019-09-16 10:48:48 +0200 |
---|---|---|
committer | Jakub Jelen <jjelen@redhat.com> | 2019-09-18 15:17:21 +0200 |
commit | 6500134259c40c95d0b342278c42304b1067b85b (patch) | |
tree | 4e930b0d8ea85cc47aa5587864038de707c03013 | |
parent | 9b8b312b88ee79009df40a07b90548f743df9f9f (diff) | |
download | libssh-6500134259c40c95d0b342278c42304b1067b85b.tar.gz libssh-6500134259c40c95d0b342278c42304b1067b85b.tar.xz libssh-6500134259c40c95d0b342278c42304b1067b85b.zip |
config: Support match localuser
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
-rw-r--r-- | src/config.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/config.c b/src/config.c index 256a9a94..2b813dcb 100644 --- a/src/config.c +++ b/src/config.c @@ -447,6 +447,7 @@ ssh_config_parse_line(ssh_session session, int result = 1; size_t args = 0; enum ssh_config_match_e opt; + char *localuser = NULL; *parsing = 0; do { @@ -512,8 +513,29 @@ ssh_config_parse_line(ssh_session session, result = 0; break; - case MATCH_ORIGINALHOST: case MATCH_LOCALUSER: + /* Here we match only one argument */ + p = ssh_config_get_str_tok(&s, NULL); + if (p == NULL || p[0] == '\0') { + ssh_set_error(session, SSH_FATAL, + "line %d: ERROR - Match user keyword " + "requires argument", count); + SAFE_FREE(x); + return -1; + } + localuser = ssh_get_local_username(); + if (localuser == NULL) { + SSH_LOG(SSH_LOG_WARN, "line %d: Can not get local username " + "for conditional matching.", count); + SAFE_FREE(x); + return -1; + } + result &= ssh_config_match(localuser, p, negate); + SAFE_FREE(localuser); + args++; + break; + + case MATCH_ORIGINALHOST: /* Skip one argument */ p = ssh_config_get_str_tok(&s, NULL); if (p == NULL || p[0] == '\0') { |