// don't do anything daemonish, like create /var/run/ceph, or print a banner
CINIT_FLAG_NO_DAEMON_ACTIONS = 0x8,
+
+ // don't drop privileges
+ CINIT_FLAG_DEFER_DROP_PRIVILEGES = 0x16,
};
/*
}
}
g_ceph_context->set_uid_gid(uid, gid);
- if (setgid(gid) != 0) {
- int r = errno;
- cerr << "unable to setgid " << gid << ": " << cpp_strerror(r)
- << std::endl;
- exit(1);
- }
- if (setuid(uid) != 0) {
- int r = errno;
- cerr << "unable to setuid " << uid << ": " << cpp_strerror(r)
- << std::endl;
- exit(1);
+ if ((flags & CINIT_FLAG_DEFER_DROP_PRIVILEGES) == 0) {
+ if (setgid(gid) != 0) {
+ int r = errno;
+ cerr << "unable to setgid " << gid << ": " << cpp_strerror(r)
+ << std::endl;
+ exit(1);
+ }
+ if (setuid(uid) != 0) {
+ int r = errno;
+ cerr << "unable to setuid " << uid << ": " << cpp_strerror(r)
+ << std::endl;
+ exit(1);
+ }
+ priv_ss << "set uid:gid to " << uid << ":" << gid;
+ } else {
+ priv_ss << "deferred set uid:gid to " << uid << ":" << gid;
}
- priv_ss << "set uid:gid to " << uid << ":" << gid;
}
// Expand metavariables. Invoke configuration observers. Open log file.