Cleaning up indenting.

This commit is contained in:
Jonathan Naylor
2017-05-03 14:53:48 +01:00
committed by GitHub
parent 4b72c936ce
commit e9e8745aa7

View File

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