]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - support/nsm/file.c
Statd should always 'chdir' to its state directory.
[nfs-utils.git] / support / nsm / file.c
index 98b47bf8bd9f0b4dae29861b446d7ab3f137d134..a12c75300eebab5bc9dd4309e84e1bb88f68a067 100644 (file)
@@ -395,18 +395,18 @@ nsm_drop_privileges(const int pidfd)
                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 (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