From a7069153bd478ee4c927401431e3f5243716d3a0 Mon Sep 17 00:00:00 2001 From: Antonio SJ Musumeci Date: Sun, 22 Oct 2023 00:43:19 -0500 Subject: [PATCH] Warn if not running as root --- src/mergerfs.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/mergerfs.cpp b/src/mergerfs.cpp index 47d36285..89bf531e 100644 --- a/src/mergerfs.cpp +++ b/src/mergerfs.cpp @@ -230,6 +230,21 @@ namespace l std::signal(SIGUSR2,l::usr2_signal_handler); } + static + void + warn_if_not_root() + { + uid_t uid; + + uid = geteuid(); + if(uid == 0) + return; + + char const *s = "mergerfs is not running as root and may not work correctly\n"; + fprintf(stderr,"warning: %s",s); + syslog_warning(s); + } + int main(const int argc_, char **argv_) @@ -241,6 +256,8 @@ namespace l syslog_open(); + l::warn_if_not_root(); + memset(&ops,0,sizeof(fuse_operations)); args.argc = argc_;