Add exception for using getgwnam() and getpwnam(). This is safe so early in the startup
This commit is contained in:
parent
c26efc1305
commit
77b128f2fd
1 changed files with 6 additions and 2 deletions
|
@ -119,14 +119,18 @@ int main(int argc, char **argv) {
|
||||||
std::string user = TelldusCore::wideToString(settings.getSetting(L"user"));
|
std::string user = TelldusCore::wideToString(settings.getSetting(L"user"));
|
||||||
std::string group = TelldusCore::wideToString(settings.getSetting(L"group"));
|
std::string group = TelldusCore::wideToString(settings.getSetting(L"group"));
|
||||||
|
|
||||||
struct group *grp = getgrnam(group.c_str());
|
// We use the non threadsafe function getgrnam() here. Since this is startup code
|
||||||
|
// and no other threads have been started yet.
|
||||||
|
struct group *grp = getgrnam(group.c_str()); // NOLINT(runtime/threadsafe_fn)
|
||||||
if (grp) {
|
if (grp) {
|
||||||
setgid(grp->gr_gid);
|
setgid(grp->gr_gid);
|
||||||
} else {
|
} else {
|
||||||
Log::warning("Group %s could not be found", group.c_str());
|
Log::warning("Group %s could not be found", group.c_str());
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
struct passwd *pw = getpwnam(user.c_str());
|
// We use the non threadsafe function getpwnam() here. Since this is startup code
|
||||||
|
// and no other threads have been started yet.
|
||||||
|
struct passwd *pw = getpwnam(user.c_str()); // NOLINT(runtime/threadsafe_fn)
|
||||||
if (pw) {
|
if (pw) {
|
||||||
setuid( pw->pw_uid );
|
setuid( pw->pw_uid );
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue