]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
statd - delay drop-privs until sockets have been setup.
authorNeil Brown <neilb@suse.de>
Mon, 19 Mar 2007 23:14:44 +0000 (10:14 +1100)
committerNeil Brown <neilb@suse.de>
Mon, 19 Mar 2007 23:14:44 +0000 (10:14 +1100)
Registering sockets with portmap might require root privs,
so don't drop privs until that has been done.

utils/statd/statd.c

index 17e2947b35f0b8021fb2b170e854dbe8156c92a4..157de853bf5aa4fbab1d6cc655f40beb6b806bca 100644 (file)
@@ -251,6 +251,7 @@ int main (int argc, char **argv)
        int arg;
        int port = 0, out_port = 0;
        struct rlimit rlim;
+       int once = 1;
 
        int pipefds[2] = { -1, -1};
        char status;
@@ -474,7 +475,6 @@ int main (int argc, char **argv)
                        waitpid(pid, NULL, 0);
                }
 
-       drop_privs();
 
        for (;;) {
                pmap_unset (SM_PROG, SM_VERS);
@@ -490,6 +490,10 @@ int main (int argc, char **argv)
                /* this registers both UDP and TCP services */
                rpc_init("statd", SM_PROG, SM_VERS, sm_prog_1, port);
 
+               if (once) {
+                       once = 0;
+                       drop_privs();
+               }
                /*
                 * Handle incoming requests:  SM_NOTIFY socket requests, as
                 * well as callbacks from lockd.