We must change our group first to have permissions to do so
This commit is contained in:
parent
8d4f240744
commit
c25a848578
1 changed files with 7 additions and 7 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue