]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mount/network.c
Ensure statd gets started if required when non-root
[nfs-utils.git] / utils / mount / network.c
index 2db694d2541bb1a8acfe8d3956bbc14d1de8a84f..806344c399dd92d4f3b5ebe8d8f67ea9099c6061 100644 (file)
@@ -36,6 +36,7 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <sys/wait.h>
 #include <netinet/in.h>
 #include <rpc/rpc.h>
 #include <rpc/pmap_prot.h>
@@ -705,7 +706,18 @@ int start_statd(void)
 #ifdef START_STATD
        if (stat(START_STATD, &stb) == 0) {
                if (S_ISREG(stb.st_mode) && (stb.st_mode & S_IXUSR)) {
-                       system(START_STATD);
+                       pid_t pid = fork();
+                       switch (pid) {
+                       case 0: /* child */
+                               execl(START_STATD, START_STATD, NULL);
+                               exit(1);
+                       case -1: /* error */
+                               perror("Fork failed");
+                               break;
+                       default: /* parent */
+                               waitpid(pid, NULL,0);
+                               break;
+                       }
                        if (probe_statd())
                                return 1;
                }