mirror of
https://github.com/ShaYmez/MMDVM_CM.git
synced 2025-09-03 13:47:47 -04:00
Move log LogInitialise()
This commit is contained in:
parent
d600b606cd
commit
c7e02fecd0
@ -132,32 +132,26 @@ int CDMR2NXDN::run()
|
||||
logDisplayLevel = 0U;
|
||||
#endif
|
||||
|
||||
ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), logDisplayLevel);
|
||||
if (!ret) {
|
||||
::fprintf(stderr, "DMR2NXDN: unable to open the log file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
bool m_daemon = m_conf.getDaemon();
|
||||
if (m_daemon) {
|
||||
// Create new process
|
||||
pid_t pid = ::fork();
|
||||
if (pid == -1) {
|
||||
::LogWarning("Couldn't fork() , exiting");
|
||||
::fprintf(stderr, "Couldn't fork() , exiting\n");
|
||||
return -1;
|
||||
} else if (pid != 0)
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
// Create new session and process group
|
||||
if (::setsid() == -1) {
|
||||
::LogWarning("Couldn't setsid(), exiting");
|
||||
::fprintf(stderr, "Couldn't setsid(), exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set the working directory to the root directory
|
||||
if (::chdir("/") == -1) {
|
||||
::LogWarning("Couldn't cd /, exiting");
|
||||
::fprintf(stderr, "Couldn't cd /, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -169,7 +163,7 @@ int CDMR2NXDN::run()
|
||||
if (getuid() == 0) {
|
||||
struct passwd* user = ::getpwnam("mmdvm");
|
||||
if (user == NULL) {
|
||||
::LogError("Could not get the mmdvm user, exiting");
|
||||
::fprintf(stderr, "Could not get the mmdvm user, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -178,24 +172,30 @@ int CDMR2NXDN::run()
|
||||
|
||||
// Set user and group ID's to mmdvm:mmdvm
|
||||
if (setgid(mmdvm_gid) != 0) {
|
||||
::LogWarning("Could not set mmdvm GID, exiting");
|
||||
::fprintf(stderr, "Could not set mmdvm GID, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (setuid(mmdvm_uid) != 0) {
|
||||
::LogWarning("Could not set mmdvm UID, exiting");
|
||||
::fprintf(stderr, "Could not set mmdvm UID, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Double check it worked (AKA Paranoia)
|
||||
if (setuid(0) != -1) {
|
||||
::LogWarning("It's possible to regain root - something is wrong!, exiting");
|
||||
::fprintf(stderr, "It's possible to regain root - something is wrong!, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), logDisplayLevel);
|
||||
if (!ret) {
|
||||
::fprintf(stderr, "DMR2NXDN: unable to open the log file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_defsrcid = m_conf.getDMRId();
|
||||
|
||||
std::string gatewayAddress = m_conf.getDstAddress();
|
||||
|
@ -135,32 +135,26 @@ int CDMR2YSF::run()
|
||||
logDisplayLevel = 0U;
|
||||
#endif
|
||||
|
||||
ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), logDisplayLevel);
|
||||
if (!ret) {
|
||||
::fprintf(stderr, "DMR2YSF: unable to open the log file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
bool m_daemon = m_conf.getDaemon();
|
||||
if (m_daemon) {
|
||||
// Create new process
|
||||
pid_t pid = ::fork();
|
||||
if (pid == -1) {
|
||||
::LogWarning("Couldn't fork() , exiting");
|
||||
::fprintf(stderr, "Couldn't fork() , exiting\n");
|
||||
return -1;
|
||||
} else if (pid != 0)
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
// Create new session and process group
|
||||
if (::setsid() == -1) {
|
||||
::LogWarning("Couldn't setsid(), exiting");
|
||||
::fprintf(stderr, "Couldn't setsid(), exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set the working directory to the root directory
|
||||
if (::chdir("/") == -1) {
|
||||
::LogWarning("Couldn't cd /, exiting");
|
||||
::fprintf(stderr, "Couldn't cd /, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -172,7 +166,7 @@ int CDMR2YSF::run()
|
||||
if (getuid() == 0) {
|
||||
struct passwd* user = ::getpwnam("mmdvm");
|
||||
if (user == NULL) {
|
||||
::LogError("Could not get the mmdvm user, exiting");
|
||||
::fprintf(stderr, "Could not get the mmdvm user, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -181,24 +175,30 @@ int CDMR2YSF::run()
|
||||
|
||||
// Set user and group ID's to mmdvm:mmdvm
|
||||
if (setgid(mmdvm_gid) != 0) {
|
||||
::LogWarning("Could not set mmdvm GID, exiting");
|
||||
::fprintf(stderr, "Could not set mmdvm GID, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (setuid(mmdvm_uid) != 0) {
|
||||
::LogWarning("Could not set mmdvm UID, exiting");
|
||||
::fprintf(stderr, "Could not set mmdvm UID, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Double check it worked (AKA Paranoia)
|
||||
if (setuid(0) != -1) {
|
||||
::LogWarning("It's possible to regain root - something is wrong!, exiting");
|
||||
::fprintf(stderr, "It's possible to regain root - something is wrong!, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), logDisplayLevel);
|
||||
if (!ret) {
|
||||
::fprintf(stderr, "DMR2YSF: unable to open the log file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_callsign = m_conf.getCallsign();
|
||||
m_defsrcid = m_conf.getDMRId();
|
||||
|
||||
|
@ -136,32 +136,26 @@ int CNXDN2DMR::run()
|
||||
logDisplayLevel = 0U;
|
||||
#endif
|
||||
|
||||
ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), logDisplayLevel);
|
||||
if (!ret) {
|
||||
::fprintf(stderr, "NXDN2DMR: unable to open the log file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
bool m_daemon = m_conf.getDaemon();
|
||||
if (m_daemon) {
|
||||
// Create new process
|
||||
pid_t pid = ::fork();
|
||||
if (pid == -1) {
|
||||
::LogWarning("Couldn't fork() , exiting");
|
||||
::fprintf(stderr, "Couldn't fork() , exiting\n");
|
||||
return -1;
|
||||
} else if (pid != 0)
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
// Create new session and process group
|
||||
if (::setsid() == -1) {
|
||||
::LogWarning("Couldn't setsid(), exiting");
|
||||
::fprintf(stderr, "Couldn't setsid(), exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set the working directory to the root directory
|
||||
if (::chdir("/") == -1) {
|
||||
::LogWarning("Couldn't cd /, exiting");
|
||||
::fprintf(stderr, "Couldn't cd /, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -173,7 +167,7 @@ int CNXDN2DMR::run()
|
||||
if (getuid() == 0) {
|
||||
struct passwd* user = ::getpwnam("mmdvm");
|
||||
if (user == NULL) {
|
||||
::LogError("Could not get the mmdvm user, exiting");
|
||||
::fprintf(stderr, "Could not get the mmdvm user, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -182,24 +176,30 @@ int CNXDN2DMR::run()
|
||||
|
||||
// Set user and group ID's to mmdvm:mmdvm
|
||||
if (setgid(mmdvm_gid) != 0) {
|
||||
::LogWarning("Could not set mmdvm GID, exiting");
|
||||
::fprintf(stderr, "Could not set mmdvm GID, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (setuid(mmdvm_uid) != 0) {
|
||||
::LogWarning("Could not set mmdvm UID, exiting");
|
||||
::fprintf(stderr, "Could not set mmdvm UID, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Double check it worked (AKA Paranoia)
|
||||
if (setuid(0) != -1) {
|
||||
::LogWarning("It's possible to regain root - something is wrong!, exiting");
|
||||
::fprintf(stderr, "It's possible to regain root - something is wrong!, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), logDisplayLevel);
|
||||
if (!ret) {
|
||||
::fprintf(stderr, "NXDN2DMR: unable to open the log file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_callsign = m_conf.getCallsign();
|
||||
m_nxdnTG = m_conf.getTG();
|
||||
|
||||
|
@ -141,32 +141,26 @@ int CYSF2DMR::run()
|
||||
logDisplayLevel = 0U;
|
||||
#endif
|
||||
|
||||
ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), logDisplayLevel);
|
||||
if (!ret) {
|
||||
::fprintf(stderr, "YSF2DMR: unable to open the log file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
bool m_daemon = m_conf.getDaemon();
|
||||
if (m_daemon) {
|
||||
// Create new process
|
||||
pid_t pid = ::fork();
|
||||
if (pid == -1) {
|
||||
::LogWarning("Couldn't fork() , exiting");
|
||||
::fprintf(stderr, "Couldn't fork() , exiting\n");
|
||||
return -1;
|
||||
} else if (pid != 0)
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
// Create new session and process group
|
||||
if (::setsid() == -1) {
|
||||
::LogWarning("Couldn't setsid(), exiting");
|
||||
::fprintf(stderr, "Couldn't setsid(), exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set the working directory to the root directory
|
||||
if (::chdir("/") == -1) {
|
||||
::LogWarning("Couldn't cd /, exiting");
|
||||
::fprintf(stderr, "Couldn't cd /, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -178,7 +172,7 @@ int CYSF2DMR::run()
|
||||
if (getuid() == 0) {
|
||||
struct passwd* user = ::getpwnam("mmdvm");
|
||||
if (user == NULL) {
|
||||
::LogError("Could not get the mmdvm user, exiting");
|
||||
::fprintf(stderr, "Could not get the mmdvm user, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -187,24 +181,30 @@ int CYSF2DMR::run()
|
||||
|
||||
// Set user and group ID's to mmdvm:mmdvm
|
||||
if (setgid(mmdvm_gid) != 0) {
|
||||
::LogWarning("Could not set mmdvm GID, exiting");
|
||||
::fprintf(stderr, "Could not set mmdvm GID, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (setuid(mmdvm_uid) != 0) {
|
||||
::LogWarning("Could not set mmdvm UID, exiting");
|
||||
::fprintf(stderr, "Could not set mmdvm UID, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Double check it worked (AKA Paranoia)
|
||||
if (setuid(0) != -1) {
|
||||
::LogWarning("It's possible to regain root - something is wrong!, exiting");
|
||||
::fprintf(stderr, "It's possible to regain root - something is wrong!, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), logDisplayLevel);
|
||||
if (!ret) {
|
||||
::fprintf(stderr, "YSF2DMR: unable to open the log file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_callsign = m_conf.getCallsign();
|
||||
m_suffix = m_conf.getSuffix();
|
||||
|
||||
|
@ -134,32 +134,26 @@ int CYSF2NXDN::run()
|
||||
logDisplayLevel = 0U;
|
||||
#endif
|
||||
|
||||
ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), logDisplayLevel);
|
||||
if (!ret) {
|
||||
::fprintf(stderr, "YSF2NXDN: unable to open the log file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
bool m_daemon = m_conf.getDaemon();
|
||||
if (m_daemon) {
|
||||
// Create new process
|
||||
pid_t pid = ::fork();
|
||||
if (pid == -1) {
|
||||
::LogWarning("Couldn't fork() , exiting");
|
||||
::fprintf(stderr, "Couldn't fork() , exiting\n");
|
||||
return -1;
|
||||
} else if (pid != 0)
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
// Create new session and process group
|
||||
if (::setsid() == -1) {
|
||||
::LogWarning("Couldn't setsid(), exiting");
|
||||
::fprintf(stderr, "Couldn't setsid(), exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set the working directory to the root directory
|
||||
if (::chdir("/") == -1) {
|
||||
::LogWarning("Couldn't cd /, exiting");
|
||||
::fprintf(stderr, "Couldn't cd /, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -171,7 +165,7 @@ int CYSF2NXDN::run()
|
||||
if (getuid() == 0) {
|
||||
struct passwd* user = ::getpwnam("mmdvm");
|
||||
if (user == NULL) {
|
||||
::LogError("Could not get the mmdvm user, exiting");
|
||||
::fprintf(stderr, "Could not get the mmdvm user, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -180,24 +174,30 @@ int CYSF2NXDN::run()
|
||||
|
||||
//Set user and group ID's to mmdvm:mmdvm
|
||||
if (setgid(mmdvm_gid) != 0) {
|
||||
::LogWarning("Could not set mmdvm GID, exiting");
|
||||
::fprintf(stderr, "Could not set mmdvm GID, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (setuid(mmdvm_uid) != 0) {
|
||||
::LogWarning("Could not set mmdvm UID, exiting");
|
||||
::fprintf(stderr, "Could not set mmdvm UID, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Double check it worked (AKA Paranoia)
|
||||
if (setuid(0) != -1) {
|
||||
::LogWarning("It's possible to regain root - something is wrong!, exiting");
|
||||
::fprintf(stderr, "It's possible to regain root - something is wrong!, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), logDisplayLevel);
|
||||
if (!ret) {
|
||||
::fprintf(stderr, "YSF2NXDN: unable to open the log file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_callsign = m_conf.getCallsign();
|
||||
m_suffix = m_conf.getSuffix();
|
||||
m_defsrcid = m_conf.getNXDNId();
|
||||
|
@ -186,32 +186,26 @@ int CYSF2P25::run()
|
||||
logDisplayLevel = 0U;
|
||||
#endif
|
||||
|
||||
ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), logDisplayLevel);
|
||||
if (!ret) {
|
||||
::fprintf(stderr, "YSF2P25: unable to open the log file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) && !defined(_WIN64)
|
||||
bool m_daemon = m_conf.getDaemon();
|
||||
if (m_daemon) {
|
||||
// Create new process
|
||||
pid_t pid = ::fork();
|
||||
if (pid == -1) {
|
||||
::LogWarning("Couldn't fork() , exiting");
|
||||
::fprintf(stderr, "Couldn't fork() , exiting\n");
|
||||
return -1;
|
||||
} else if (pid != 0)
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
// Create new session and process group
|
||||
if (::setsid() == -1) {
|
||||
::LogWarning("Couldn't setsid(), exiting");
|
||||
::fprintf(stderr, "Couldn't setsid(), exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Set the working directory to the root directory
|
||||
if (::chdir("/") == -1) {
|
||||
::LogWarning("Couldn't cd /, exiting");
|
||||
::fprintf(stderr, "Couldn't cd /, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -223,7 +217,7 @@ int CYSF2P25::run()
|
||||
if (getuid() == 0) {
|
||||
struct passwd* user = ::getpwnam("mmdvm");
|
||||
if (user == NULL) {
|
||||
::LogError("Could not get the mmdvm user, exiting");
|
||||
::fprintf(stderr, "Could not get the mmdvm user, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -232,24 +226,30 @@ int CYSF2P25::run()
|
||||
|
||||
// Set user and group ID's to mmdvm:mmdvm
|
||||
if (setgid(mmdvm_gid) != 0) {
|
||||
::LogWarning("Could not set mmdvm GID, exiting");
|
||||
::fprintf(stderr, "Could not set mmdvm GID, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (setuid(mmdvm_uid) != 0) {
|
||||
::LogWarning("Could not set mmdvm UID, exiting");
|
||||
::fprintf(stderr, "Could not set mmdvm UID, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Double check it worked (AKA Paranoia)
|
||||
if (setuid(0) != -1) {
|
||||
::LogWarning("It's possible to regain root - something is wrong!, exiting");
|
||||
::fprintf(stderr, "It's possible to regain root - something is wrong!, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), logDisplayLevel);
|
||||
if (!ret) {
|
||||
::fprintf(stderr, "YSF2P25: unable to open the log file\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
m_callsign = m_conf.getCallsign();
|
||||
m_defsrcid = m_conf.getP25Id();
|
||||
m_dstid = m_conf.getP25DstId();
|
||||
|
Loading…
x
Reference in New Issue
Block a user