]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/global: refactor global_init to avoid setuser/setgroup modification 13687/head
authorliuchang0812 <liuchang0812@gmail.com>
Wed, 22 Mar 2017 13:16:50 +0000 (21:16 +0800)
committerliuchang0812 <liuchang0812@gmail.com>
Wed, 22 Mar 2017 13:16:50 +0000 (21:16 +0800)
Signed-off-by: liuchang0812 <liuchang0812@gmail.com>
src/global/global_init.cc

index 950cee2ec3702d1eed36b5c5cb750ba39e2c74ed..7ec5ab93dd1cc8c5afc53fa5436d1788f13fc7cd 100644 (file)
@@ -166,24 +166,21 @@ global_init(std::vector < const char * > *alt_def_args,
   if (g_conf->log_flush_on_exit)
     g_ceph_context->_log->set_flush_on_exit();
 
+  // drop privileges?
+  ostringstream priv_ss;
   // consider --setuser root a no-op, even if we're not root
   if (getuid() != 0) {
     if (g_conf->setuser.length()) {
       cerr << "ignoring --setuser " << g_conf->setuser << " since I am not root"
           << std::endl;
-      g_conf->set_val("setuser", "", false);
     }
     if (g_conf->setgroup.length()) {
       cerr << "ignoring --setgroup " << g_conf->setgroup
           << " since I am not root" << std::endl;
-      g_conf->set_val("setgroup", "", false);
     }
-  }
-
-  // drop privileges?
-  ostringstream priv_ss;
-  if (g_conf->setgroup.length() ||
-      g_conf->setuser.length()) {
+  } else if (g_conf->setgroup.length() ||
+             g_conf->setuser.length()) {
     uid_t uid = 0;  // zero means no change; we can only drop privs here.
     gid_t gid = 0;
     std::string uid_string;