commit - 9e5f5a1ed2a6c44ecf477a26643c467f49a6c112
commit + 44e35bfc5d79729b628868aacb8e88ad5ab5bd46
blob - b76352f09eb64d8b4a8abdea88ec12556b121f49
blob + aac808b4b78aea1e1c1e43492f46a8fd7ff4495f
--- gitwrapper/gitwrapper.c
+++ gitwrapper/gitwrapper.c
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/uio.h>
-#include <sys/wait.h>
#include <err.h>
#include <errno.h>
char *gitcommand = NULL;
struct gotd gotd;
struct gotd_repo *repo = NULL;
- pid_t pid;
- int st = -1;
log_init(1, LOG_USER); /* Log to stderr. */
#ifndef PROFILE
- if (pledge("stdio rpath proc exec unveil", NULL) == -1)
+ if (pledge("stdio rpath exec unveil", NULL) == -1)
err(1, "pledge");
#endif
goto done;
#ifndef PROFILE
- if (pledge("stdio proc exec", NULL) == -1)
+ if (pledge("stdio exec", NULL) == -1)
err(1, "pledge");
#endif
* Invoke our custom Git server if the repository was found
* in gotd.conf. Otherwise invoke native git(1) tooling.
*/
- switch (pid = fork()) {
- case -1:
- goto done;
- case 0:
- if (repo) {
- if (myserver == NULL) {
- error = got_error_fmt(GOT_ERR_NO_PROG,
- "cannot run '%s'",
- GITWRAPPER_MY_SERVER_PROG);
- goto done;
- }
- if (execl(myserver, command, repo_name,
- (char *)NULL) == -1) {
- error = got_error_from_errno2("execl",
- myserver);
- goto done;
- }
- } else {
- if (asprintf(&gitcommand, "%s/%s",
- GITWRAPPER_GIT_LIBEXEC_DIR, command) == -1) {
- error = got_error_from_errno("asprintf");
- goto done;
- }
- if (execl(gitcommand, gitcommand, repo_path,
- (char *)NULL) == -1) {
- error = got_error_from_errno2("execl",
- gitcommand);
- goto done;
- }
+ if (repo) {
+ if (myserver == NULL) {
+ error = got_error_fmt(GOT_ERR_NO_PROG,
+ "cannot run '%s'",
+ GITWRAPPER_MY_SERVER_PROG);
+ goto done;
}
- _exit(127);
+ execl(myserver, command, repo_name, (char *)NULL);
+ error = got_error_from_errno2("execl", myserver);
+ } else {
+ if (asprintf(&gitcommand, "%s/%s",
+ GITWRAPPER_GIT_LIBEXEC_DIR, command) == -1) {
+ error = got_error_from_errno("asprintf");
+ goto done;
+ }
+ execl(gitcommand, gitcommand, repo_path, (char *)NULL);
+ error = got_error_from_errno2("execl", gitcommand);
}
- while (waitpid(pid, &st, 0) == -1) {
- if (errno != EINTR)
- break;
- }
done:
free(command);
free(repo_name);