diff options
author | Jakub Jelen <jjelen@redhat.com> | 2019-09-16 10:48:48 +0200 |
---|---|---|
committer | Anderson Toshiyuki Sasaki <ansasaki@redhat.com> | 2019-09-30 15:58:57 +0200 |
commit | 27f5bfd129f28f50760dc9e5e74f1c654d6e204b (patch) | |
tree | a8cb98a83c95dd89391bb4fb51591dfa7be43644 | |
parent | 4a0cbe396d6776177bb9c01554fde04a6749d0f6 (diff) | |
download | libssh-27f5bfd129f28f50760dc9e5e74f1c654d6e204b.tar.gz libssh-27f5bfd129f28f50760dc9e5e74f1c654d6e204b.tar.xz libssh-27f5bfd129f28f50760dc9e5e74f1c654d6e204b.zip |
config: Support match localuser
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
(cherry picked from commit 6500134259c40c95d0b342278c42304b1067b85b)
-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 b4c17bd4..62279a67 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') { |