mirror of https://github.com/Icinga/icinga2.git
parent
96aa503dbe
commit
9dd0fba02f
|
@ -362,6 +362,7 @@ int Main(void)
|
||||||
}
|
}
|
||||||
} else if (command && command->GetImpersonationLevel() == ImpersonateIcinga) {
|
} else if (command && command->GetImpersonationLevel() == ImpersonateIcinga) {
|
||||||
String group = Application::GetRunAsGroup();
|
String group = Application::GetRunAsGroup();
|
||||||
|
String user = Application::GetRunAsUser();
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
struct group *gr = getgrnam(group.CStr());
|
struct group *gr = getgrnam(group.CStr());
|
||||||
|
@ -382,6 +383,8 @@ int Main(void)
|
||||||
if (!vm.count("reload-internal") && setgroups(0, NULL) < 0) {
|
if (!vm.count("reload-internal") && setgroups(0, NULL) < 0) {
|
||||||
Log(LogCritical, "cli")
|
Log(LogCritical, "cli")
|
||||||
<< "setgroups() failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
|
<< "setgroups() failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
|
||||||
|
Log(LogCritical, "cli")
|
||||||
|
<< "Please re-run this command as a privileged user or using the \"" << user << "\" account.";
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,8 +395,6 @@ int Main(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String user = Application::GetRunAsUser();
|
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
struct passwd *pw = getpwnam(user.CStr());
|
struct passwd *pw = getpwnam(user.CStr());
|
||||||
|
|
||||||
|
@ -414,12 +415,16 @@ int Main(void)
|
||||||
if (!vm.count("reload-internal") && initgroups(user.CStr(), pw->pw_gid) < 0) {
|
if (!vm.count("reload-internal") && initgroups(user.CStr(), pw->pw_gid) < 0) {
|
||||||
Log(LogCritical, "cli")
|
Log(LogCritical, "cli")
|
||||||
<< "initgroups() failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
|
<< "initgroups() failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
|
||||||
|
Log(LogCritical, "cli")
|
||||||
|
<< "Please re-run this command as a privileged user or using the \"" << user << "\" account.";
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setuid(pw->pw_uid) < 0) {
|
if (setuid(pw->pw_uid) < 0) {
|
||||||
Log(LogCritical, "cli")
|
Log(LogCritical, "cli")
|
||||||
<< "setuid() failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
|
<< "setuid() failed with error code " << errno << ", \"" << Utility::FormatErrorNumber(errno) << "\"";
|
||||||
|
Log(LogCritical, "cli")
|
||||||
|
<< "Please re-run this command as a privileged user or using the \"" << user << "\" account.";
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue