mirror of
https://github.com/badaix/snapcast.git
synced 2025-04-29 18:27:12 +02:00
Reformat code
This commit is contained in:
parent
6d2f1a2b3e
commit
be40e66c63
1 changed files with 96 additions and 96 deletions
|
@ -55,8 +55,8 @@ void Daemon::daemonize()
|
|||
utils::file::mkdirRecursive(pidfileDir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
|
||||
/// Ensure only one copy
|
||||
pidFilehandle_ = open(pidfile_.c_str(), O_RDWR|O_CREAT, 0644);
|
||||
if (pidFilehandle_ == -1 )
|
||||
pidFilehandle_ = open(pidfile_.c_str(), O_RDWR | O_CREAT, 0644);
|
||||
if (pidFilehandle_ == -1)
|
||||
{
|
||||
/// Couldn't open lock file
|
||||
throw SnapException("Could not open PID lock file \"" + pidfile_ + "\"");
|
||||
|
@ -65,13 +65,13 @@ void Daemon::daemonize()
|
|||
uid_t user_uid = (uid_t)-1;
|
||||
gid_t user_gid = (gid_t)-1;
|
||||
std::string user_name;
|
||||
#ifdef FREEBSD
|
||||
bool had_group = false;
|
||||
#endif
|
||||
// #ifdef FREEBSD
|
||||
// bool had_group = false;
|
||||
// #endif
|
||||
|
||||
if (!user_.empty())
|
||||
{
|
||||
struct passwd *pwd = getpwnam(user_.c_str());
|
||||
struct passwd* pwd = getpwnam(user_.c_str());
|
||||
if (pwd == nullptr)
|
||||
throw SnapException("no such user \"" + user_ + "\"");
|
||||
user_uid = pwd->pw_uid;
|
||||
|
@ -83,13 +83,13 @@ void Daemon::daemonize()
|
|||
|
||||
if (!group_.empty())
|
||||
{
|
||||
struct group *grp = getgrnam(group_.c_str());
|
||||
struct group* grp = getgrnam(group_.c_str());
|
||||
if (grp == nullptr)
|
||||
throw SnapException("no such group \"" + group_ + "\"");
|
||||
user_gid = grp->gr_gid;
|
||||
#ifdef FREEBSD
|
||||
had_group = true;
|
||||
#endif
|
||||
// #ifdef FREEBSD
|
||||
// had_group = true;
|
||||
// #endif
|
||||
}
|
||||
|
||||
if (chown(pidfile_.c_str(), user_uid, user_gid) == -1)
|
||||
|
@ -102,14 +102,14 @@ void Daemon::daemonize()
|
|||
if (user_gid != (gid_t)-1 && user_gid != getgid() && setgid(user_gid) == -1)
|
||||
throw SnapException("Failed to set group " + cpt::to_string((int)user_gid));
|
||||
|
||||
//#if defined(FREEBSD) && !defined(MACOS)
|
||||
//#ifdef FREEBSD
|
||||
//#if defined(FREEBSD) && !defined(MACOS)
|
||||
//#ifdef FREEBSD
|
||||
/// init supplementary groups
|
||||
/// (must be done before we change our uid)
|
||||
/// no need to set the new user's supplementary groups if we are already this user
|
||||
// if (!had_group && user_uid != getuid() && initgroups(user_name, user_gid) == -1)
|
||||
// throw SnapException("Failed to set supplementary groups of user \"" + user + "\"");
|
||||
//#endif
|
||||
// if (!had_group && user_uid != getuid() && initgroups(user_name, user_gid) == -1)
|
||||
// throw SnapException("Failed to set supplementary groups of user \"" + user + "\"");
|
||||
//#endif
|
||||
/// set uid
|
||||
if (user_uid != (uid_t)-1 && user_uid != getuid() && setuid(user_uid) == -1)
|
||||
throw SnapException("Failed to set user " + user_);
|
||||
|
|
Loading…
Add table
Reference in a new issue