Cleaning up indenting.
This commit is contained in:
parent
4b72c936ce
commit
e9e8745aa7
|
@ -173,33 +173,34 @@ int CMMDVMHost::run()
|
|||
// Create new process
|
||||
pid_t pid = ::fork();
|
||||
if (pid == -1) {
|
||||
::LogWarning("Couldn't fork() , exiting");
|
||||
LogWarning("Couldn't fork() , exiting");
|
||||
return -1;
|
||||
}
|
||||
else if (pid != 0)
|
||||
} else if (pid != 0) {
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
// Create new session and process group
|
||||
if (::setsid() == -1){
|
||||
::LogWarning("Couldn't setsid(), exiting");
|
||||
LogWarning("Couldn't setsid(), exiting");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set the working directory to the root directory
|
||||
if (::chdir("/") == -1){
|
||||
::LogWarning("Couldn't cd /, exiting");
|
||||
LogWarning("Couldn't cd /, exiting");
|
||||
return -1;
|
||||
}
|
||||
|
||||
::close(STDIN_FILENO);
|
||||
::close(STDOUT_FILENO);
|
||||
::close(STDERR_FILENO);
|
||||
|
||||
#if !defined(HD44780) && !defined(OLED)
|
||||
//If we are currently root...
|
||||
if (getuid() == 0) {
|
||||
struct passwd* user = ::getpwnam("mmdvm");
|
||||
if (user == NULL) {
|
||||
::LogError("Could not get the mmdvm user, exiting");
|
||||
LogError("Could not get the mmdvm user, exiting");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -207,27 +208,23 @@ int CMMDVMHost::run()
|
|||
gid_t mmdvm_gid = user->pw_gid;
|
||||
|
||||
//Set user and group ID's to mmdvm:mmdvm
|
||||
if (setgid(mmdvm_gid) != 0) {
|
||||
::LogWarning("Could not set mmdvm GID, exiting");
|
||||
if (::setgid(mmdvm_gid) != 0) {
|
||||
LogWarning("Could not set mmdvm GID, exiting");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (setuid(mmdvm_uid) != 0) {
|
||||
::LogWarning("Could not set mmdvm UID, exiting");
|
||||
if (::setuid(mmdvm_uid) != 0) {
|
||||
LogWarning("Could not set mmdvm UID, exiting");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Double check it worked (AKA Paranoia)
|
||||
if (setuid(0) != -1){
|
||||
::LogWarning("It's possible to regain root - something is wrong!, exiting");
|
||||
if (::setuid(0) != -1){
|
||||
LogWarning("It's possible to regain root - something is wrong!, exiting");
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#else
|
||||
::LogWarning("Dropping root permissions in daemon mode is disabled with HD44780 display");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue