/[projects]/smsdaemon/daemon.cpp
ViewVC logotype

Diff of /smsdaemon/daemon.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 146 by torben, Sun Dec 7 20:06:12 2008 UTC revision 153 by torben, Mon Dec 8 13:14:55 2008 UTC
# Line 1  Line 1 
1  #include <iostream>  #include <iostream>
2    #include <sstream>
3  #include <signal.h>  #include <signal.h>
4  #include <fcntl.h>  #include <fcntl.h>
5  #include <stdlib.h>  #include <stdlib.h>
# Line 10  Line 10 
10  #include <grp.h>  #include <grp.h>
11    
12    
13    #include "ConfigFile.h"
14  #include "daemon.h"  #include "daemon.h"
15  #include "common.h"  #include "common.h"
16    
# Line 30  void signal_handler(int sig) Line 31  void signal_handler(int sig)
31                  Common::instance()->logMessage("terminate signal catched...exiting");                  Common::instance()->logMessage("terminate signal catched...exiting");
32                  Common::instance()->mainContinue = false;                  Common::instance()->mainContinue = false;
33                  break;                  break;
34            default:
35                    std::stringstream ss;
36                    ss << "Received unknown signal: " << sig;
37                    Common::instance()->logMessage(ss.str());
38                    break;
39          }          }
40  }  }
41    
# Line 37  void lookup_uid_values() Line 43  void lookup_uid_values()
43  {  {
44          Common* cmn = Common::instance();          Common* cmn = Common::instance();
45    
46          passwd* pass = getpwnam("smsdaemon");          std::string userstr = cmn->GetConfigfile()->GetValue("smsdaemon","user");
47            std::string groupstr = cmn->GetConfigfile()->GetValue("smsdaemon","group");
48    
49            passwd* pass = getpwnam(userstr.c_str());
50          if (pass != 0)          if (pass != 0)
51          {          {
52                  cmn->uid = pass->pw_uid;                  cmn->uid = pass->pw_uid;
53          }          }
54          else          else
55          {          {
56                  cmn->logMessage("could not lookup userid: smsdaemon");                  cmn->logMessage( string("could not lookup userid: ") + userstr );
57                  exit(1);                  exit(1);
58          }          }
59    
60          group* grp = getgrnam("smsdaemon");          group* grp = getgrnam(groupstr.c_str() );
61          if (grp != 0)          if (grp != 0)
62          {          {
63                  cmn->gid = grp->gr_gid;                  cmn->gid = grp->gr_gid;
64          }          }
65          else          else
66          {          {
67                  cmn->logMessage("could not lookup groupid: smsdaemon");                  cmn->logMessage( string("could not lookup groupid: ") + groupstr );
68                  exit(1);                  exit(1);
69          }          }
70  }  }

Legend:
Removed from v.146  
changed lines
  Added in v.153

  ViewVC Help
Powered by ViewVC 1.1.20