From 9ec680aaf7adbf669d922c2e86c3ece5b5345ef6 Mon Sep 17 00:00:00 2001 From: fancyrabbit Date: Sat, 23 Jun 2018 22:06:21 +0000 Subject: [PATCH] fix the operation not permitted error when rsync --daemon is NOT executed by root for rsync > 3.1 --- slash/src/rsync.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/slash/src/rsync.cc b/slash/src/rsync.cc index 5f2a531..403eaeb 100644 --- a/slash/src/rsync.cc +++ b/slash/src/rsync.cc @@ -31,8 +31,11 @@ int StartRsync(const std::string& raw_path, const std::string& module, const std log_warn("Open rsync conf file failed!"); return -1; } - conf_stream << "uid = root" << std::endl; - conf_stream << "gid = root" << std::endl; + + if (geteuid() == 0) { + conf_stream << "uid = root" << std::endl; + conf_stream << "gid = root" << std::endl; + } conf_stream << "use chroot = no" << std::endl; conf_stream << "max connections = 10" << std::endl; conf_stream << "lock file = " << rsync_path + kRsyncLockFile << std::endl;