X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=daemon.c;h=66f8d6f03d91d7dfa4a164137ee0310ca26dc1aa;hb=204d409247e7bbc7848569462aa11a87e373c8d6;hp=e66bb802da9faed6e01229fffbe56e3d7cca60c6;hpb=24ad8e0ce23d08d28a5d664ab6164b10125146ce;p=thirdparty%2Fgit.git diff --git a/daemon.c b/daemon.c index e66bb802da..66f8d6f03d 100644 --- a/daemon.c +++ b/daemon.c @@ -1,20 +1,10 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "pkt-line.h" #include "cache.h" +#include "pkt-line.h" #include "exec_cmd.h" #include "interpolate.h" +#include + #ifndef HOST_NAME_MAX #define HOST_NAME_MAX 256 #endif @@ -112,7 +102,7 @@ static void logreport(int priority, const char *err, va_list params) buf[buflen++] = '\n'; buf[buflen] = '\0'; - write(2, buf, buflen); + write_in_full(2, buf, buflen); } static void logerror(const char *err, ...) @@ -382,9 +372,16 @@ static int upload_archive(void) return -1; } +static int receive_pack(void) +{ + execl_git_cmd("receive-pack", ".", NULL); + return -1; +} + static struct daemon_service daemon_service[] = { { "upload-archive", "uploadarch", upload_archive, 0, 1 }, { "upload-pack", "uploadpack", upload_pack, 1, 1 }, + { "receive-pack", "receivepack", receive_pack, 0, 1 }, }; static void enable_service(const char *name, int ena) { @@ -411,7 +408,7 @@ static void make_service_overridable(const char *name, int ena) { /* * Separate the "extra args" information as supplied by the client connection. - * Any resulting data is squirrelled away in the given interpolation table. + * Any resulting data is squirreled away in the given interpolation table. */ static void parse_extra_args(struct interp *table, char *extra_args, int buflen) { @@ -776,6 +773,7 @@ static int socksetup(char *listen_addr, int listen_port, int **socklist_p) char pbuf[NI_MAXSERV]; struct addrinfo hints, *ai0, *ai; int gai; + long flags; sprintf(pbuf, "%d", listen_port); memset(&hints, 0, sizeof(hints)); @@ -823,6 +821,10 @@ static int socksetup(char *listen_addr, int listen_port, int **socklist_p) continue; /* not fatal */ } + flags = fcntl(sockfd, F_GETFD, 0); + if (flags >= 0) + fcntl(sockfd, F_SETFD, flags | FD_CLOEXEC); + socklist = xrealloc(socklist, sizeof(int) * (socknum + 1)); socklist[socknum++] = sockfd; @@ -842,6 +844,7 @@ static int socksetup(char *listen_addr, int listen_port, int **socklist_p) { struct sockaddr_in sin; int sockfd; + long flags; memset(&sin, 0, sizeof sin); sin.sin_family = AF_INET; @@ -874,6 +877,10 @@ static int socksetup(char *listen_addr, int listen_port, int **socklist_p) return 0; } + flags = fcntl(sockfd, F_GETFD, 0); + if (flags >= 0) + fcntl(sockfd, F_SETFD, flags | FD_CLOEXEC); + *socklist_p = xmalloc(sizeof(int)); **socklist_p = sockfd; return 1;