MCPcopy Index your code
hub / github.com/git/git / run_access_hook

Function run_access_hook

daemon.c:311–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309static const char *access_hook;
310
311static int run_access_hook(struct daemon_service *service, const char *dir,
312 const char *path, struct hostinfo *hi)
313{
314 struct child_process child = CHILD_PROCESS_INIT;
315 struct strbuf buf = STRBUF_INIT;
316 char *eol;
317 int seen_errors = 0;
318
319 strvec_push(&child.args, access_hook);
320 strvec_push(&child.args, service->name);
321 strvec_push(&child.args, path);
322 strvec_push(&child.args, hi->hostname.buf);
323 strvec_push(&child.args, get_canon_hostname(hi));
324 strvec_push(&child.args, get_ip_address(hi));
325 strvec_push(&child.args, hi->tcp_port.buf);
326
327 child.use_shell = 1;
328 child.no_stdin = 1;
329 child.no_stderr = 1;
330 child.out = -1;
331 if (start_command(&child)) {
332 logerror("daemon access hook '%s' failed to start",
333 access_hook);
334 goto error_return;
335 }
336 if (strbuf_read(&buf, child.out, 0) < 0) {
337 logerror("failed to read from pipe to daemon access hook '%s'",
338 access_hook);
339 strbuf_reset(&buf);
340 seen_errors = 1;
341 }
342 if (close(child.out) < 0) {
343 logerror("failed to close pipe to daemon access hook '%s'",
344 access_hook);
345 seen_errors = 1;
346 }
347 if (finish_command(&child))
348 seen_errors = 1;
349
350 if (!seen_errors) {
351 strbuf_release(&buf);
352 return 0;
353 }
354
355error_return:
356 strbuf_ltrim(&buf);
357 if (!buf.len)
358 strbuf_addstr(&buf, "service rejected");
359 eol = strchr(buf.buf, '\n');
360 if (eol)
361 *eol = '\0';
362 errno = EACCES;
363 daemon_error(dir, buf.buf);
364 strbuf_release(&buf);
365 return -1;
366}
367
368static int run_service(const char *dir, struct daemon_service *service,

Callers 1

run_serviceFunction · 0.85

Calls 11

strvec_pushFunction · 0.85
get_canon_hostnameFunction · 0.85
get_ip_addressFunction · 0.85
start_commandFunction · 0.85
logerrorFunction · 0.85
strbuf_readFunction · 0.85
finish_commandFunction · 0.85
strbuf_releaseFunction · 0.85
strbuf_ltrimFunction · 0.85
strbuf_addstrFunction · 0.85
daemon_errorFunction · 0.85

Tested by

no test coverage detected