From: Erik Faye-Lund <kusmabite@googlemail.com>
To: msysgit@googlegroups.com
Cc: git@vger.kernel.org, j6t@kdbg.org, Erik Faye-Lund <kusmabite@gmail.com>
Subject: [PATCH v2 11/14] mingw: compile git-daemon
Date: Fri, 15 Jan 2010 22:30:30 +0100 [thread overview]
Message-ID: <1263591033-4992-12-git-send-email-kusmabite@gmail.com> (raw)
In-Reply-To: <1263591033-4992-1-git-send-email-kusmabite@gmail.com>
--user and --detach are disabled on Windows due to lack of
fork(), setuid(), setgid(), setsid() and initgroups().
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---
Makefile | 8 +++-----
compat/mingw.h | 1 +
daemon.c | 19 ++++++++++++++-----
3 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/Makefile b/Makefile
index d81b392..cb6c36d 100644
--- a/Makefile
+++ b/Makefile
@@ -390,6 +390,7 @@ EXTRA_PROGRAMS =
# ... and all the rest that could be moved out of bindir to gitexecdir
PROGRAMS += $(EXTRA_PROGRAMS)
+PROGRAMS += git-daemon$X
PROGRAMS += git-fast-import$X
PROGRAMS += git-hash-object$X
PROGRAMS += git-imap-send$X
@@ -986,7 +987,6 @@ ifeq ($(uname_S),Windows)
NO_SVN_TESTS = YesPlease
NO_PERL_MAKEMAKER = YesPlease
RUNTIME_PREFIX = YesPlease
- NO_POSIX_ONLY_PROGRAMS = YesPlease
NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
NO_NSEC = YesPlease
USE_WIN32_MMAP = YesPlease
@@ -1037,7 +1037,6 @@ ifneq (,$(findstring MINGW,$(uname_S)))
NO_SVN_TESTS = YesPlease
NO_PERL_MAKEMAKER = YesPlease
RUNTIME_PREFIX = YesPlease
- NO_POSIX_ONLY_PROGRAMS = YesPlease
NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease
NO_NSEC = YesPlease
USE_WIN32_MMAP = YesPlease
@@ -1047,6 +1046,8 @@ ifneq (,$(findstring MINGW,$(uname_S)))
NO_REGEX = YesPlease
BLK_SHA1 = YesPlease
NO_PYTHON = YesPlease
+ NO_INET_PTON = YesPlease
+ NO_INET_NTOP = YesPlease
COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/fnmatch
COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/winansi.o
@@ -1141,9 +1142,6 @@ ifdef ZLIB_PATH
endif
EXTLIBS += -lz
-ifndef NO_POSIX_ONLY_PROGRAMS
- PROGRAMS += git-daemon$X
-endif
ifndef NO_OPENSSL
OPENSSL_LIBSSL = -lssl
ifdef OPENSSLDIR
diff --git a/compat/mingw.h b/compat/mingw.h
index e72c2ee..173bec5 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -7,6 +7,7 @@
typedef int pid_t;
typedef int socklen_t;
+typedef unsigned int gid_t;
#define hstrerror strerror
#define S_IFLNK 0120000 /* Symbolic link */
diff --git a/daemon.c b/daemon.c
index fc2c150..cdf5c72 100644
--- a/daemon.c
+++ b/daemon.c
@@ -589,7 +589,7 @@ static struct child {
struct sockaddr_storage address;
} *firstborn;
-static void add_child(struct child_process *cld, struct sockaddr *addr, int addrlen)
+static void add_child(struct child_process *cld, struct sockaddr *addr, socklen_t addrlen)
{
struct child *newborn, **cradle;
@@ -646,7 +646,7 @@ static void check_dead_children(void)
}
char **cld_argv;
-static void handle(int incoming, struct sockaddr *addr, int addrlen)
+static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
{
struct child_process cld = { 0 };
@@ -847,7 +847,7 @@ static int service_loop(int socknum, int *socklist)
for (i = 0; i < socknum; i++) {
if (pfd[i].revents & POLLIN) {
struct sockaddr_storage ss;
- unsigned int sslen = sizeof(ss);
+ socklen_t sslen = sizeof(ss);
int incoming = accept(pfd[i].fd, (struct sockaddr *)&ss, &sslen);
if (incoming < 0) {
switch (errno) {
@@ -879,6 +879,7 @@ static void sanitize_stdfds(void)
static void daemonize(void)
{
+#ifndef WIN32
switch (fork()) {
case 0:
break;
@@ -893,6 +894,9 @@ static void daemonize(void)
close(1);
close(2);
sanitize_stdfds();
+#else
+ die("--detach is not supported on Windows");
+#endif
}
static void store_pid(const char *path)
@@ -913,10 +917,12 @@ static int serve(char *listen_addr, int listen_port, struct passwd *pass, gid_t
die("unable to allocate any listen sockets on host %s port %u",
listen_addr, listen_port);
+#ifndef WIN32
if (pass && gid &&
(initgroups(pass->pw_name, gid) || setgid (gid) ||
setuid(pass->pw_uid)))
die("cannot drop privileges");
+#endif
return service_loop(socknum, socklist);
}
@@ -929,7 +935,6 @@ int main(int argc, char **argv)
const char *pid_file = NULL, *user_name = NULL, *group_name = NULL;
int detach = 0;
struct passwd *pass = NULL;
- struct group *group;
gid_t gid = 0;
int i;
@@ -1078,6 +1083,7 @@ int main(int argc, char **argv)
die("--group supplied without --user");
if (user_name) {
+#ifndef WIN32
pass = getpwnam(user_name);
if (!pass)
die("user not found - %s", user_name);
@@ -1085,12 +1091,15 @@ int main(int argc, char **argv)
if (!group_name)
gid = pass->pw_gid;
else {
- group = getgrnam(group_name);
+ struct group *group = getgrnam(group_name);
if (!group)
die("group not found - %s", group_name);
gid = group->gr_gid;
}
+#else
+ die("--user is not supported on Windows");
+#endif
}
if (strict_paths && (!ok_paths || !*ok_paths))
--
1.6.6.211.g26720
next prev parent reply other threads:[~2010-01-15 21:32 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-15 21:30 [PATCH v2 00/14] daemon-win32 Erik Faye-Lund
2010-01-15 21:30 ` [PATCH v2 01/14] mingw: add network-wrappers for daemon Erik Faye-Lund
2010-01-15 21:30 ` [PATCH v2 02/14] mingw: implement syslog Erik Faye-Lund
2010-01-15 22:57 ` [msysGit] " Janos Laube
2010-01-15 23:01 ` Erik Faye-Lund
2010-01-15 23:09 ` Janos Laube
2010-01-15 21:30 ` [PATCH v2 03/14] compat: add inet_pton and inet_ntop prototypes Erik Faye-Lund
2010-01-15 21:30 ` [PATCH v2 04/14] inet_ntop: fix a couple of old-style decls Erik Faye-Lund
2010-01-15 21:30 ` [PATCH v2 05/14] mingw: support waitpid with pid > 0 and WNOHANG Erik Faye-Lund
2010-01-15 22:28 ` Johannes Sixt
2010-01-16 21:57 ` Erik Faye-Lund
2010-01-15 21:30 ` [PATCH v2 06/14] mingw: use real pid Erik Faye-Lund
2010-01-15 22:30 ` Johannes Sixt
2010-01-15 22:53 ` Erik Faye-Lund
2010-01-16 8:03 ` Johannes Sixt
2010-01-16 9:12 ` Erik Faye-Lund
2010-01-18 22:33 ` Erik Faye-Lund
2010-01-19 18:19 ` Johannes Sixt
2010-01-19 19:23 ` Erik Faye-Lund
2010-01-15 21:30 ` [PATCH v2 07/14] mingw: add kill emulation Erik Faye-Lund
2010-01-15 22:31 ` Johannes Sixt
2010-01-16 21:56 ` Erik Faye-Lund
2010-01-15 21:30 ` [PATCH v2 08/14] daemon: use explicit file descriptor Erik Faye-Lund
2010-01-15 22:36 ` Johannes Sixt
2010-01-16 21:52 ` Erik Faye-Lund
2010-01-15 21:30 ` [PATCH v2 09/14] daemon: use run-command api for async serving Erik Faye-Lund
2010-01-15 22:42 ` Johannes Sixt
2010-01-15 21:30 ` [PATCH v2 10/14] daemon: use full buffered mode for stderr Erik Faye-Lund
2010-01-15 21:30 ` Erik Faye-Lund [this message]
2010-01-15 21:30 ` [PATCH v2 12/14] Improve the mingw getaddrinfo stub to handle more use cases Erik Faye-Lund
2010-01-15 21:30 ` [PATCH v2 13/14] daemon: use select() instead of poll() Erik Faye-Lund
2010-01-15 22:49 ` Johannes Sixt
2010-01-15 23:08 ` Erik Faye-Lund
2010-01-15 23:23 ` Erik Faye-Lund
2010-01-16 8:06 ` Johannes Sixt
2010-01-16 9:26 ` Erik Faye-Lund
2010-01-16 10:38 ` Johannes Sixt
2010-01-16 11:05 ` Erik Faye-Lund
2010-01-16 11:27 ` Andreas Schwab
2010-01-16 11:43 ` Erik Faye-Lund
2010-01-16 12:36 ` Johannes Sixt
2010-01-16 21:31 ` Erik Faye-Lund
2010-01-16 8:08 ` Johannes Sixt
2010-01-16 9:14 ` Erik Faye-Lund
2010-01-16 10:44 ` Johannes Sixt
2010-01-16 10:59 ` Erik Faye-Lund
2010-01-15 21:30 ` [PATCH v2 14/14] daemon: report connection from root-process Erik Faye-Lund
2010-01-15 22:27 ` [PATCH v2 00/14] daemon-win32 Johannes Sixt
2010-01-15 22:51 ` Erik Faye-Lund
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1263591033-4992-12-git-send-email-kusmabite@gmail.com \
--to=kusmabite@googlemail.com \
--cc=git@vger.kernel.org \
--cc=j6t@kdbg.org \
--cc=kusmabite@gmail.com \
--cc=msysgit@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.