X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=support%2Fnsm%2Ffile.c;h=a12c75300eebab5bc9dd4309e84e1bb88f68a067;hp=e21c7d43e58ec1c19e1d1a9b89cb459e467ab9cd;hb=fe34ff0312c7c22554087ecd78bbbeadb38ce195;hpb=5c498280fd9353ded3ea169841079bdae23418e2 diff --git a/support/nsm/file.c b/support/nsm/file.c index e21c7d4..a12c753 100644 --- a/support/nsm/file.c +++ b/support/nsm/file.c @@ -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 @@ -421,7 +421,7 @@ nsm_drop_privileges(const int pidfd) */ if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) == -1) { xlog(L_ERROR, "prctl(PR_SET_KEEPCAPS) failed: %m"); - return 0; + return false; } if (setgroups(0, NULL) == -1) {