]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mountd/mountd.c
statd: Replace note() with xlog() in rpc.statd
[nfs-utils.git] / utils / mountd / mountd.c
index 8084359e290edd34faf489d56ff7a268b649d1f1..888fd8c92b3da19a42e3964407c680415ccfbe89 100644 (file)
@@ -88,6 +88,14 @@ unregister_services (void)
                pmap_unset (MOUNTPROG, MOUNTVERS_NFSV3);
 }
 
+static void
+cleanup_lockfiles (void)
+{
+       unlink(_PATH_XTABLCK);
+       unlink(_PATH_ETABLCK);
+       unlink(_PATH_RMTABLCK);
+}
+
 /* Wait for all worker child processes to exit and reap them */
 static void
 wait_for_workers (void)
@@ -154,6 +162,7 @@ fork_workers(void)
        /* in parent */
        wait_for_workers();
        unregister_services();
+       cleanup_lockfiles();
        xlog(L_NOTICE, "mountd: no more workers, exiting\n");
        exit(0);
 }
@@ -170,6 +179,7 @@ killer (int sig)
                kill(0, SIGTERM);
                wait_for_workers();
        }
+       cleanup_lockfiles();
        xlog (L_FATAL, "Caught signal %d, un-registering and exiting.", sig);
 }
 
@@ -349,6 +359,11 @@ static void set_authflavors(struct mountres3_ok *ok, nfs_export *exp)
                flavors[i] = s->flav->fnum;
                i++;
        }
+       if (i == 0) {
+               /* default when there is no sec= option: */
+               i = 1;
+               flavors[0] = AUTH_UNIX;
+       }
        ok->auth_flavors.auth_flavors_val = flavors;
        ok->auth_flavors.auth_flavors_len = i;
 }
@@ -457,8 +472,12 @@ get_rootfh(struct svc_req *rqstp, dirpath *path, nfs_export **expret,
                        return NULL;
                }
        } else {
-               if (exp->m_exported<1)
+               int did_export = 0;
+       retry:
+               if (exp->m_exported<1) {
                        export_export(exp);
+                       did_export = 1;
+               }
                if (!exp->m_xtabent)
                        xtab_append(exp);
 
@@ -472,6 +491,11 @@ get_rootfh(struct svc_req *rqstp, dirpath *path, nfs_export **expret,
                                fh = getfh_old ((struct sockaddr *) sin,
                                                stb.st_dev, stb.st_ino);
                }
+               if (fh == NULL && !did_export) {
+                       exp->m_exported = 0;
+                       goto retry;
+               }
+
                if (fh == NULL) {
                        xlog(L_WARNING, "getfh failed: %s", strerror(errno));
                        *error = NFSERR_ACCES;