X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fstatd%2Fstatd.c;h=a44f39f2394097863c14de256801984d9e6907f3;hp=17e2947b35f0b8021fb2b170e854dbe8156c92a4;hb=7b01c4762ae242d2114cc6a59994f678b7d253fc;hpb=632127e335095b6053fa93b7b695d688918f36bb diff --git a/utils/statd/statd.c b/utils/statd/statd.c index 17e2947..a44f39f 100644 --- a/utils/statd/statd.c +++ b/utils/statd/statd.c @@ -230,12 +230,10 @@ static void run_sm_notify(int outport) av[ac++] = op; } if (run_mode & STATIC_HOSTNAME) { - av[ac++] = "-N"; + av[ac++] = "-v"; av[ac++] = MY_NAME; } av[ac] = NULL; - fprintf(stderr, "%s: -N deprecated, consider using /usr/sbin/sm-notify directly\n", - name_p); execv(av[0], av); fprintf(stderr, "%s: failed to run %s\n", name_p, av[0]); exit(2); @@ -251,6 +249,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; @@ -368,8 +367,11 @@ int main (int argc, char **argv) exit(-1); } - if (run_mode & MODE_NOTIFY_ONLY) + if (run_mode & MODE_NOTIFY_ONLY) { + fprintf(stderr, "%s: -N deprecated, consider using /usr/sbin/sm-notify directly\n", + name_p); run_sm_notify(out_port); + } if (!(run_mode & MODE_NODAEMON)) { @@ -474,7 +476,14 @@ int main (int argc, char **argv) waitpid(pid, NULL, 0); } - drop_privs(); + /* Make sure we have a privilege port for calling into the kernel */ + statd_get_socket(); + + /* If sm-notify didn't take all the state files, load + * state information into our notify-list so we can + * pass on any SM_NOTIFY that arrives + */ + load_state(); for (;;) { pmap_unset (SM_PROG, SM_VERS); @@ -490,6 +499,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.