| 473 | } |
| 474 | |
| 475 | static void run_service(const char **argv, int buffer_input) |
| 476 | { |
| 477 | const char *encoding = getenv("HTTP_CONTENT_ENCODING"); |
| 478 | const char *user = getenv("REMOTE_USER"); |
| 479 | const char *host = getenv("REMOTE_ADDR"); |
| 480 | int gzipped_request = 0; |
| 481 | struct child_process cld = CHILD_PROCESS_INIT; |
| 482 | ssize_t req_len = get_content_length(); |
| 483 | |
| 484 | if (encoding && (!strcmp(encoding, "gzip") || !strcmp(encoding, "x-gzip"))) |
| 485 | gzipped_request = 1; |
| 486 | |
| 487 | if (!user || !*user) |
| 488 | user = "anonymous"; |
| 489 | if (!host || !*host) |
| 490 | host = "(none)"; |
| 491 | |
| 492 | if (!getenv("GIT_COMMITTER_NAME")) |
| 493 | strvec_pushf(&cld.env, "GIT_COMMITTER_NAME=%s", user); |
| 494 | if (!getenv("GIT_COMMITTER_EMAIL")) |
| 495 | strvec_pushf(&cld.env, |
| 496 | "GIT_COMMITTER_EMAIL=%s@http.%s", user, host); |
| 497 | |
| 498 | strvec_pushv(&cld.args, argv); |
| 499 | if (buffer_input || gzipped_request || req_len >= 0) |
| 500 | cld.in = -1; |
| 501 | cld.git_cmd = 1; |
| 502 | cld.clean_on_exit = 1; |
| 503 | cld.wait_after_clean = 1; |
| 504 | if (start_command(&cld)) |
| 505 | exit(1); |
| 506 | |
| 507 | close(1); |
| 508 | if (gzipped_request) |
| 509 | inflate_request(argv[0], cld.in, buffer_input, req_len); |
| 510 | else if (buffer_input) |
| 511 | copy_request(argv[0], cld.in, req_len); |
| 512 | else if (req_len >= 0) |
| 513 | pipe_fixed_length(argv[0], cld.in, req_len); |
| 514 | else |
| 515 | close(0); |
| 516 | |
| 517 | if (finish_command(&cld)) |
| 518 | exit(1); |
| 519 | } |
| 520 | |
| 521 | static int show_text_ref(const struct reference *ref, void *cb_data) |
| 522 | { |
no test coverage detected