]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - support/nsm/file.c
statd: Decouple statd's state directory from the NFS state directory
[nfs-utils.git] / support / nsm / file.c
index 98b47bf8bd9f0b4dae29861b446d7ab3f137d134..5dd52c1e2640fb2effd07004c8902700811aa775 100644 (file)
 
 #define NSM_KERNEL_STATE_FILE  "/proc/sys/fs/nfs/nsm_local_state"
 
 
 #define NSM_KERNEL_STATE_FILE  "/proc/sys/fs/nfs/nsm_local_state"
 
-/*
- * Some distributions place statd's files in a subdirectory
- */
-#define NSM_PATH_EXTENSION
-/* #define NSM_PATH_EXTENSION  "/statd" */
-
-#define NSM_DEFAULT_STATEDIR           NFS_STATEDIR NSM_PATH_EXTENSION
-
 static char nsm_base_dirname[PATH_MAX] = NSM_DEFAULT_STATEDIR;
 
 #define NSM_MONITOR_DIR        "sm"
 static char nsm_base_dirname[PATH_MAX] = NSM_DEFAULT_STATEDIR;
 
 #define NSM_MONITOR_DIR        "sm"
@@ -395,18 +387,18 @@ nsm_drop_privileges(const int pidfd)
                return false;
        }
 
                return false;
        }
 
-       if (st.st_uid == 0) {
-               xlog_warn("Running as root.  "
-                       "chown %s to choose different user", nsm_base_dirname);
-               return true;
-       }
-
        if (chdir(nsm_base_dirname) == -1) {
                xlog(L_ERROR, "Failed to change working directory to %s: %m",
                                nsm_base_dirname);
                return false;
        }
 
        if (chdir(nsm_base_dirname) == -1) {
                xlog(L_ERROR, "Failed to change working directory to %s: %m",
                                nsm_base_dirname);
                return false;
        }
 
+       if (st.st_uid == 0) {
+               xlog_warn("Running as root.  "
+                       "chown %s to choose different user", nsm_base_dirname);
+               return true;
+       }
+
        /*
         * If the pidfile happens to reside on NFS, dropping privileges
         * will probably cause us to lose access, even though we are
        /*
         * If the pidfile happens to reside on NFS, dropping privileges
         * will probably cause us to lose access, even though we are