Skip to content

Commit fa2fa6c

Browse files
committed
Added support for glob patterns (* and ?) in SSH config Include directive parser.
1 parent c21addc commit fa2fa6c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/terminal/ParseConfigFile.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
// #include <string.h>
77
// #include <unistd.h>
88

9+
#include <glob.h>
10+
911
#include <fstream>
1012
#include <iostream>
1113
#include <string>
@@ -1248,7 +1250,18 @@ static int ssh_config_parse_line(const char *targethost,
12481250
if (p && *parsing) {
12491251
char *filename = ssh_path_expand_tilde(p);
12501252
if (filename) {
1251-
local_parse_file(targethost, options, filename, parsing, seen);
1253+
glob_t g;
1254+
if (strchr(filename, '*') || strchr(filename, '?')) {
1255+
if (glob(filename, 0, NULL, &g) == 0) {
1256+
for (size_t i = 0; i < g.gl_pathc; ++i) {
1257+
local_parse_file(targethost, options, g.gl_pathv[i], parsing,
1258+
seen);
1259+
}
1260+
globfree(&g);
1261+
}
1262+
} else {
1263+
local_parse_file(targethost, options, filename, parsing, seen);
1264+
}
12521265
}
12531266
SAFE_FREE(filename);
12541267
}

0 commit comments

Comments
 (0)