#21 add daemon user

pull/32/head
Geoffrey Merck 4 years ago
parent 027bbc1f65
commit 2328c31f77

@ -88,11 +88,11 @@ int main(int argc, char *argv[])
} }
TDaemon daemon; TDaemon daemon;
config->getGeneral(daemon); config->getDaemon(daemon);
if (daemon.daemon) { if (daemon.daemon) {
CLog::logInfo("Configured as a daemon, detaching ..."); CLog::logInfo("Configured as a daemon, detaching ...");
auto res = CDaemon::daemonize(daemon.pidFile, "dstar"); auto res = CDaemon::daemonize(daemon.pidFile, daemon.user);
switch (res) switch (res)
{ {

@ -72,8 +72,9 @@ bool CDStarGatewayConfig::load()
bool CDStarGatewayConfig::loadDaemon(const CConfig & cfg) bool CDStarGatewayConfig::loadDaemon(const CConfig & cfg)
{ {
bool ret = cfg.getValue("daemon", "daemon", m_general.daemon, false); bool ret = cfg.getValue("daemon", "daemon", m_daemon.daemon, false);
ret = cfg.getValue("daemon", "pidfile", m_general.pidFile, 0, 1024, "") && ret; ret = cfg.getValue("daemon", "pidfile", m_daemon.pidFile, 0, 1024, "") && ret;
ret = cfg.getValue("daemon", "user", m_daemon.user, 0, 1024, "") && ret;
return ret; return ret;
} }
@ -447,7 +448,7 @@ void CDStarGatewayConfig::getGPSD(TGPSD & gpsd) const
} }
#endif #endif
void CDStarGatewayConfig::getGeneral(TDaemon & gen) const void CDStarGatewayConfig::getDaemon(TDaemon & gen) const
{ {
gen = m_general; gen = m_daemon;
} }

@ -28,6 +28,7 @@
typedef struct { typedef struct {
bool daemon; bool daemon;
std::string pidFile; std::string pidFile;
std::string user;
} TDaemon; } TDaemon;
typedef struct { typedef struct {
@ -155,7 +156,7 @@ public:
#ifdef USE_GPSD #ifdef USE_GPSD
void getGPSD(TGPSD & gpsd) const; void getGPSD(TGPSD & gpsd) const;
#endif #endif
void getGeneral(TDaemon & gen) const; void getDaemon(TDaemon & gen) const;
private: private:
bool open(CConfig & cfg); bool open(CConfig & cfg);
@ -188,7 +189,7 @@ private:
#ifdef USE_GPSD #ifdef USE_GPSD
TGPSD m_gpsd; TGPSD m_gpsd;
#endif #endif
TDaemon m_general; TDaemon m_daemon;
std::vector<TRepeater *> m_repeaters; std::vector<TRepeater *> m_repeaters;
std::vector<TircDDB *> m_ircDDB; std::vector<TircDDB *> m_ircDDB;

@ -179,5 +179,5 @@ password=CHANGE_ME # If password is left blank, remote will be disabled regardle
[Daemon] [Daemon]
daemon=false daemon=false
# pid file is in our case useless when running as a daemon using systemd as systemd handles all the pid stuff for us pidfile=/var/run/dstargateway/dstargateway.pid # pid file is in our case useless when running as a daemon using systemd as systemd takes care of the service not being started twice
pidfile=#/var/run/dstargateway/dstargateway.pid user=dstar # user account the daemon will run under, ideally a user with low privileges
Loading…
Cancel
Save

Powered by TurnKey Linux.