Prepare a child_process for use by Git's SSH-tunneled transport. */
| 1340 | |
| 1341 | /* Prepare a child_process for use by Git's SSH-tunneled transport. */ |
| 1342 | static void fill_ssh_args(struct child_process *conn, const char *ssh_host, |
| 1343 | const char *port, enum protocol_version version, |
| 1344 | int flags) |
| 1345 | { |
| 1346 | const char *ssh; |
| 1347 | enum ssh_variant variant; |
| 1348 | |
| 1349 | if (looks_like_command_line_option(ssh_host)) |
| 1350 | die(_("strange hostname '%s' blocked"), ssh_host); |
| 1351 | |
| 1352 | ssh = get_ssh_command(); |
| 1353 | if (ssh) { |
| 1354 | variant = determine_ssh_variant(ssh, 1); |
| 1355 | } else { |
| 1356 | /* |
| 1357 | * GIT_SSH is the no-shell version of |
| 1358 | * GIT_SSH_COMMAND (and must remain so for |
| 1359 | * historical compatibility). |
| 1360 | */ |
| 1361 | conn->use_shell = 0; |
| 1362 | |
| 1363 | ssh = getenv("GIT_SSH"); |
| 1364 | if (!ssh) |
| 1365 | ssh = "ssh"; |
| 1366 | variant = determine_ssh_variant(ssh, 0); |
| 1367 | } |
| 1368 | |
| 1369 | if (variant == VARIANT_AUTO) { |
| 1370 | struct child_process detect = CHILD_PROCESS_INIT; |
| 1371 | |
| 1372 | detect.use_shell = conn->use_shell; |
| 1373 | detect.no_stdin = detect.no_stdout = detect.no_stderr = 1; |
| 1374 | |
| 1375 | strvec_push(&detect.args, ssh); |
| 1376 | strvec_push(&detect.args, "-G"); |
| 1377 | push_ssh_options(&detect.args, &detect.env, |
| 1378 | VARIANT_SSH, port, version, flags); |
| 1379 | strvec_push(&detect.args, ssh_host); |
| 1380 | |
| 1381 | variant = run_command(&detect) ? VARIANT_SIMPLE : VARIANT_SSH; |
| 1382 | } |
| 1383 | |
| 1384 | strvec_push(&conn->args, ssh); |
| 1385 | push_ssh_options(&conn->args, &conn->env, variant, port, version, |
| 1386 | flags); |
| 1387 | strvec_push(&conn->args, ssh_host); |
| 1388 | } |
| 1389 | |
| 1390 | /* |
| 1391 | * This returns the dummy child_process `no_fork` if the transport protocol |
no test coverage detected