mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-12 03:00:26 +09:00
config: Support match localuser
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
(cherry picked from commit 6500134259)
This commit is contained in:
committed by
Anderson Toshiyuki Sasaki
parent
4a0cbe396d
commit
27f5bfd129
24
src/config.c
24
src/config.c
@@ -447,6 +447,7 @@ ssh_config_parse_line(ssh_session session,
|
|||||||
int result = 1;
|
int result = 1;
|
||||||
size_t args = 0;
|
size_t args = 0;
|
||||||
enum ssh_config_match_e opt;
|
enum ssh_config_match_e opt;
|
||||||
|
char *localuser = NULL;
|
||||||
|
|
||||||
*parsing = 0;
|
*parsing = 0;
|
||||||
do {
|
do {
|
||||||
@@ -512,8 +513,29 @@ ssh_config_parse_line(ssh_session session,
|
|||||||
result = 0;
|
result = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MATCH_ORIGINALHOST:
|
|
||||||
case MATCH_LOCALUSER:
|
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 */
|
/* Skip one argument */
|
||||||
p = ssh_config_get_str_tok(&s, NULL);
|
p = ssh_config_get_str_tok(&s, NULL);
|
||||||
if (p == NULL || p[0] == '\0') {
|
if (p == NULL || p[0] == '\0') {
|
||||||
|
|||||||
Reference in New Issue
Block a user