We must change our group first to have permissions to do so

This commit is contained in:
Micke Prag 2011-03-03 16:36:13 +00:00
parent 8d4f240744
commit c25a848578

View file

@ -98,13 +98,6 @@ int main(int argc, char **argv) {
std::string user = TelldusCore::wideToString(settings.getSetting(L"user"));
std::string group = TelldusCore::wideToString(settings.getSetting(L"group"));
struct passwd *pw = getpwnam(user.c_str());
if (pw) {
setuid( pw->pw_uid );
} else {
syslog(LOG_WARNING, "User %s could not be found", user.c_str());
exit(EXIT_FAILURE);
}
struct group *grp = getgrnam(group.c_str());
if (grp) {
setgid(grp->gr_gid);
@ -112,6 +105,13 @@ int main(int argc, char **argv) {
syslog(LOG_WARNING, "Group %s could not be found", group.c_str());
exit(EXIT_FAILURE);
}
struct passwd *pw = getpwnam(user.c_str());
if (pw) {
setuid( pw->pw_uid );
} else {
syslog(LOG_WARNING, "User %s could not be found", user.c_str());
exit(EXIT_FAILURE);
}
}
/* Change the current working directory */