kumquat-buildroot/package/portmap/portmap-6.0-0003-NO_FORK-control-usage-of-fork-for-nommu-systems.patch
Mike Frysinger 758eff8852 portmap: add nommu support
Acked-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
2011-01-19 22:18:34 +01:00

96 lines
2.7 KiB
Diff

From b3afea5757af1a7356ba30d2e0a7d5909ca18121 Mon Sep 17 00:00:00 2001
From: Mike Frysinger <vapier@gentoo.org>
Date: Fri, 19 Nov 2010 23:48:20 -0500
Subject: [PATCH 3/4] NO_FORK: control usage of fork() for nommu systems
nommu systems lack a fork() function, so add a NO_FORK flag to control
its usage. We don't lose a ton of functionality in doing so, and on an
embedded system, this is OK.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
Makefile | 5 +++++
README | 1 +
pmap_check.c | 6 ++++--
portmap.c | 6 ++++++
4 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index cfcfdbb..9df5574 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,11 @@ MAN_SED += -e 's/USE_DNS/yes/'
endif
endif
+# For no-mmu systems, we have to disable the fork() functions.
+ifneq ($(NO_FORK),)
+CPPFLAGS += -DNO_FORK
+endif
+
# Comment out if your RPC library does not allocate privileged ports for
# requests from processes with root privilege, or the new portmap will
# always reject requests to register/unregister services on privileged
diff --git a/README b/README
index e0b561a..bda1707 100644
--- a/README
+++ b/README
@@ -18,6 +18,7 @@ There is no "./configure", just use "make".
Some make variable can be used to control compilation.
+ NO_FORK= if non-empty, don't use fork (good for nommu systems)
NO_PIE= if non-empty, don't build portmap as a PIE
NO_TCP_WRAPPER= if non-empty, don't use tcp_wrappers
USE_DNS= if set, tcp_wrappers can check peers based on hostname
diff --git a/pmap_check.c b/pmap_check.c
index 6b3e490..983414e 100644
--- a/pmap_check.c
+++ b/pmap_check.c
@@ -302,8 +302,10 @@ static void logit(int severity, struct sockaddr_in *addr,
* getrpcbynumber() or syslog() does its thing.
*/
- if (fork() == 0) {
-
+#ifndef NO_FORK
+ if (fork() == 0)
+#endif
+ {
/* Try to map program number to name. */
if (prognum == 0) {
diff --git a/portmap.c b/portmap.c
index 2a98881..94abc64 100644
--- a/portmap.c
+++ b/portmap.c
@@ -753,6 +755,7 @@ static void callit(struct svc_req *rqstp, SVCXPRT *xprt)
if ((pml = find_service(a.rmt_prog, a.rmt_vers,
(u_long)IPPROTO_UDP)) == NULL)
return;
+#ifndef NO_FORK
/*
* fork a child to do the work. Parent immediately returns.
* Child exits upon completion.
@@ -763,6 +766,7 @@ static void callit(struct svc_req *rqstp, SVCXPRT *xprt)
a.rmt_prog);
return;
}
+#endif
port = pml->pml_map.pm_port;
get_myaddress(&me);
me.sin_port = htons(port);
@@ -783,7 +787,9 @@ static void callit(struct svc_req *rqstp, SVCXPRT *xprt)
clnt_destroy(client);
}
(void)close(so);
+#ifndef NO_FORK
exit(0);
+#endif
}
#ifndef IGNORE_SIGCHLD /* Lionel Cons <cons@dxcern.cern.ch> */
--
1.7.3.1