]> git.neil.brown.name Git - portmap.git/commitdiff
NO_FORK: control usage of fork() for nommu systems
authorMike Frysinger <vapier@gentoo.org>
Tue, 11 Jan 2011 19:09:04 +0000 (14:09 -0500)
committerNeil Brown <neilb@suse.de>
Wed, 12 Jan 2011 06:21:14 +0000 (17:21 +1100)
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>
Signed-off-by: Neil Brown <neilb@suse.de>
Makefile
README
pmap_check.c
portmap.c

index 8004c1a2b418a5162b9107dead95a5b91ffe9149..1864b1799c73d090ffb01667e0761c77f3f27fe4 100644 (file)
--- 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
+
 ifeq ($(PREFIX),)
 PREFIX = /usr
 endif
diff --git a/README b/README
index e0b561a85ee22f4e84f3596c7c08d32346a76173..bda17070188dae7596605f41e4b0bd7f216ba089 100644 (file)
--- 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
index fd7671113b1a2445bd6ee357460273e13478a350..ebe30f1b3a0bbf06cc094a46cc7ab38b1ed7469d 100644 (file)
@@ -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) {
index 7719349d029069d3ceb663159e939bddb03f9c39..89416ebe765e92342e042300e7a5ca1d98b36c05 100644 (file)
--- a/portmap.c
+++ b/portmap.c
@@ -784,6 +784,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.
@@ -794,6 +795,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);
@@ -814,7 +816,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> */