diff --git a/telldus-core/service/main_unix.cpp b/telldus-core/service/main_unix.cpp index af4ed71b..f6fcef66 100644 --- a/telldus-core/service/main_unix.cpp +++ b/telldus-core/service/main_unix.cpp @@ -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 */