|
Lines 160-172
char *forward_agent_sock_path = NULL;
Link Here
|
| 160 |
/* Various strings used to to percent_expand() arguments */ |
160 |
/* Various strings used to to percent_expand() arguments */ |
| 161 |
static char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; |
161 |
static char thishost[NI_MAXHOST], shorthost[NI_MAXHOST], portstr[NI_MAXSERV]; |
| 162 |
static char uidstr[32], *host_arg, *conn_hash_hex; |
162 |
static char uidstr[32], *host_arg, *conn_hash_hex; |
| 163 |
#define DEFAULT_CLIENT_PERCENT_EXPAND_ARGS \ |
|
|
| 164 |
"C", conn_hash_hex, \ |
| 165 |
"L", shorthost, \ |
| 166 |
"i", uidstr, \ |
| 167 |
"l", thishost, \ |
| 168 |
"n", host_arg, \ |
| 169 |
"p", portstr |
| 170 |
|
163 |
|
| 171 |
/* socket address the host resolves to */ |
164 |
/* socket address the host resolves to */ |
| 172 |
struct sockaddr_storage hostaddr; |
165 |
struct sockaddr_storage hostaddr; |
|
Lines 222-227
tilde_expand_paths(char **paths, u_int n
Link Here
|
| 222 |
} |
215 |
} |
| 223 |
} |
216 |
} |
| 224 |
|
217 |
|
|
|
218 |
#define DEFAULT_CLIENT_PERCENT_EXPAND_ARGS \ |
| 219 |
"C", conn_hash_hex, \ |
| 220 |
"L", shorthost, \ |
| 221 |
"i", uidstr, \ |
| 222 |
"l", thishost, \ |
| 223 |
"n", host_arg, \ |
| 224 |
"p", portstr |
| 225 |
|
| 226 |
/* |
| 227 |
* Expands the set of percent_expand options used by the majority of keywords |
| 228 |
* in the client that support percent expansion. |
| 229 |
* Caller must free returned string. |
| 230 |
*/ |
| 231 |
static char * |
| 232 |
default_client_percent_expand(const char *str, const char *homedir, |
| 233 |
const char *remhost, const char *remuser, const char *locuser) |
| 234 |
{ |
| 235 |
return percent_expand(str, |
| 236 |
/* values from statics above */ |
| 237 |
DEFAULT_CLIENT_PERCENT_EXPAND_ARGS, |
| 238 |
/* values from arguments */ |
| 239 |
"d", homedir, |
| 240 |
"h", remhost, |
| 241 |
"r", remuser, |
| 242 |
"u", locuser, |
| 243 |
(char *)NULL); |
| 244 |
} |
| 245 |
|
| 225 |
/* |
246 |
/* |
| 226 |
* Attempt to resolve a host name / port to a set of addresses and |
247 |
* Attempt to resolve a host name / port to a set of addresses and |
| 227 |
* optionally return any CNAMEs encountered along the way. |
248 |
* optionally return any CNAMEs encountered along the way. |
|
Lines 1324-1336
main(int ac, char **av)
Link Here
|
| 1324 |
if (options.remote_command != NULL) { |
1345 |
if (options.remote_command != NULL) { |
| 1325 |
debug3("expanding RemoteCommand: %s", options.remote_command); |
1346 |
debug3("expanding RemoteCommand: %s", options.remote_command); |
| 1326 |
cp = options.remote_command; |
1347 |
cp = options.remote_command; |
| 1327 |
options.remote_command = percent_expand(cp, |
1348 |
options.remote_command = default_client_percent_expand(cp, |
| 1328 |
DEFAULT_CLIENT_PERCENT_EXPAND_ARGS, |
1349 |
pw->pw_dir, host, options.user, pw->pw_name); |
| 1329 |
"d", pw->pw_dir, |
|
|
| 1330 |
"h", host, |
| 1331 |
"r", options.user, |
| 1332 |
"u", pw->pw_name, |
| 1333 |
(char *)NULL); |
| 1334 |
debug3("expanded RemoteCommand: %s", options.remote_command); |
1350 |
debug3("expanded RemoteCommand: %s", options.remote_command); |
| 1335 |
free(cp); |
1351 |
free(cp); |
| 1336 |
if ((r = sshbuf_put(command, options.remote_command, |
1352 |
if ((r = sshbuf_put(command, options.remote_command, |
|
Lines 1341-1365
main(int ac, char **av)
Link Here
|
| 1341 |
if (options.control_path != NULL) { |
1357 |
if (options.control_path != NULL) { |
| 1342 |
cp = tilde_expand_filename(options.control_path, getuid()); |
1358 |
cp = tilde_expand_filename(options.control_path, getuid()); |
| 1343 |
free(options.control_path); |
1359 |
free(options.control_path); |
| 1344 |
options.control_path = percent_expand(cp, |
1360 |
options.control_path = default_client_percent_expand(cp, |
| 1345 |
DEFAULT_CLIENT_PERCENT_EXPAND_ARGS, |
1361 |
pw->pw_dir, host, options.user, pw->pw_name); |
| 1346 |
"d", pw->pw_dir, |
|
|
| 1347 |
"h", host, |
| 1348 |
"r", options.user, |
| 1349 |
"u", pw->pw_name, |
| 1350 |
(char *)NULL); |
| 1351 |
free(cp); |
1362 |
free(cp); |
| 1352 |
} |
1363 |
} |
| 1353 |
|
1364 |
|
| 1354 |
if (options.identity_agent != NULL) { |
1365 |
if (options.identity_agent != NULL) { |
| 1355 |
p = tilde_expand_filename(options.identity_agent, getuid()); |
1366 |
p = tilde_expand_filename(options.identity_agent, getuid()); |
| 1356 |
cp = percent_expand(p, |
1367 |
cp = default_client_percent_expand(p, |
| 1357 |
DEFAULT_CLIENT_PERCENT_EXPAND_ARGS, |
1368 |
pw->pw_dir, host, options.user, pw->pw_name); |
| 1358 |
"d", pw->pw_dir, |
|
|
| 1359 |
"h", host, |
| 1360 |
"r", options.user, |
| 1361 |
"u", pw->pw_name, |
| 1362 |
(char *)NULL); |
| 1363 |
free(p); |
1369 |
free(p); |
| 1364 |
free(options.identity_agent); |
1370 |
free(options.identity_agent); |
| 1365 |
options.identity_agent = cp; |
1371 |
options.identity_agent = cp; |
|
Lines 1368-1385
main(int ac, char **av)
Link Here
|
| 1368 |
if (options.forward_agent_sock_path != NULL) { |
1374 |
if (options.forward_agent_sock_path != NULL) { |
| 1369 |
p = tilde_expand_filename(options.forward_agent_sock_path, |
1375 |
p = tilde_expand_filename(options.forward_agent_sock_path, |
| 1370 |
getuid()); |
1376 |
getuid()); |
| 1371 |
cp = percent_expand(p, |
1377 |
cp = default_client_percent_expand(p, |
| 1372 |
DEFAULT_CLIENT_PERCENT_EXPAND_ARGS, |
1378 |
pw->pw_dir, host, options.user, pw->pw_name); |
| 1373 |
"d", pw->pw_dir, |
|
|
| 1374 |
"h", host, |
| 1375 |
"r", options.user, |
| 1376 |
"u", pw->pw_name, |
| 1377 |
(char *)NULL); |
| 1378 |
free(p); |
1379 |
free(p); |
| 1379 |
free(options.forward_agent_sock_path); |
1380 |
free(options.forward_agent_sock_path); |
| 1380 |
options.forward_agent_sock_path = cp; |
1381 |
options.forward_agent_sock_path = cp; |
| 1381 |
} |
1382 |
} |
| 1382 |
|
1383 |
|
|
|
1384 |
for (i = 0; i < options.num_local_forwards; i++) { |
| 1385 |
if (options.local_forwards[i].listen_path != NULL) { |
| 1386 |
cp = options.local_forwards[i].listen_path; |
| 1387 |
p = options.local_forwards[i].listen_path = |
| 1388 |
default_client_percent_expand(cp, |
| 1389 |
pw->pw_dir, host, options.user, pw->pw_name); |
| 1390 |
if (strcmp(cp, p) != 0) |
| 1391 |
debug3("expanded LocalForward listen path " |
| 1392 |
"'%s' -> '%s'", cp, p); |
| 1393 |
free(cp); |
| 1394 |
} |
| 1395 |
if (options.local_forwards[i].connect_path != NULL) { |
| 1396 |
cp = options.local_forwards[i].connect_path; |
| 1397 |
p = options.local_forwards[i].connect_path = |
| 1398 |
default_client_percent_expand(cp, |
| 1399 |
pw->pw_dir, host, options.user, pw->pw_name); |
| 1400 |
if (strcmp(cp, p) != 0) |
| 1401 |
debug3("expanded LocalForward connect path " |
| 1402 |
"'%s' -> '%s'", cp, p); |
| 1403 |
free(cp); |
| 1404 |
} |
| 1405 |
} |
| 1406 |
|
| 1407 |
for (i = 0; i < options.num_remote_forwards; i++) { |
| 1408 |
if (options.remote_forwards[i].listen_path != NULL) { |
| 1409 |
cp = options.remote_forwards[i].listen_path; |
| 1410 |
p = options.remote_forwards[i].listen_path = |
| 1411 |
default_client_percent_expand(cp, |
| 1412 |
pw->pw_dir, host, options.user, pw->pw_name); |
| 1413 |
if (strcmp(cp, p) != 0) |
| 1414 |
debug3("expanded RemoteForward listen path " |
| 1415 |
"'%s' -> '%s'", cp, p); |
| 1416 |
free(cp); |
| 1417 |
} |
| 1418 |
if (options.remote_forwards[i].connect_path != NULL) { |
| 1419 |
cp = options.remote_forwards[i].connect_path; |
| 1420 |
p = options.remote_forwards[i].connect_path = |
| 1421 |
default_client_percent_expand(cp, |
| 1422 |
pw->pw_dir, host, options.user, pw->pw_name); |
| 1423 |
if (strcmp(cp, p) != 0) |
| 1424 |
debug3("expanded RemoteForward connect path " |
| 1425 |
"'%s' -> '%s'", cp, p); |
| 1426 |
free(cp); |
| 1427 |
} |
| 1428 |
} |
| 1429 |
|
| 1383 |
if (config_test) { |
1430 |
if (config_test) { |
| 1384 |
dump_client_config(&options, host); |
1431 |
dump_client_config(&options, host); |
| 1385 |
exit(0); |
1432 |
exit(0); |
|
Lines 2099-2111
load_public_identity_files(struct passwd
Link Here
|
| 2099 |
continue; |
2146 |
continue; |
| 2100 |
} |
2147 |
} |
| 2101 |
cp = tilde_expand_filename(options.identity_files[i], getuid()); |
2148 |
cp = tilde_expand_filename(options.identity_files[i], getuid()); |
| 2102 |
filename = percent_expand(cp, |
2149 |
filename = default_client_percent_expand(cp, |
| 2103 |
DEFAULT_CLIENT_PERCENT_EXPAND_ARGS, |
2150 |
pw->pw_dir, host, options.user, pw->pw_name); |
| 2104 |
"d", pw->pw_dir, |
|
|
| 2105 |
"h", host, |
| 2106 |
"r", options.user, |
| 2107 |
"u", pw->pw_name, |
| 2108 |
(char *)NULL); |
| 2109 |
free(cp); |
2151 |
free(cp); |
| 2110 |
check_load(sshkey_load_public(filename, &public, NULL), |
2152 |
check_load(sshkey_load_public(filename, &public, NULL), |
| 2111 |
filename, "pubkey"); |
2153 |
filename, "pubkey"); |
|
Lines 2154-2166
load_public_identity_files(struct passwd
Link Here
|
| 2154 |
for (i = 0; i < options.num_certificate_files; i++) { |
2196 |
for (i = 0; i < options.num_certificate_files; i++) { |
| 2155 |
cp = tilde_expand_filename(options.certificate_files[i], |
2197 |
cp = tilde_expand_filename(options.certificate_files[i], |
| 2156 |
getuid()); |
2198 |
getuid()); |
| 2157 |
filename = percent_expand(cp, |
2199 |
filename = default_client_percent_expand(cp, |
| 2158 |
DEFAULT_CLIENT_PERCENT_EXPAND_ARGS, |
2200 |
pw->pw_dir, host, options.user, pw->pw_name); |
| 2159 |
"d", pw->pw_dir, |
|
|
| 2160 |
"h", host, |
| 2161 |
"r", options.user, |
| 2162 |
"u", pw->pw_name, |
| 2163 |
(char *)NULL); |
| 2164 |
free(cp); |
2201 |
free(cp); |
| 2165 |
|
2202 |
|
| 2166 |
check_load(sshkey_load_public(filename, &public, NULL), |
2203 |
check_load(sshkey_load_public(filename, &public, NULL), |