fixed wrong pointer check with rtp sync
[anytun.git] / plain_tool / plain_tool.cpp
bloba9bbfbd3cba5c5d4bce92cd8b9fc97c1fda6f1cc
1 #include <iostream>
3 #include "../datatypes.h"
5 #include "../log.h"
6 #include "../signalController.h"
8 #include "options.h"
11 // void chrootAndDrop(string const& chrootdir, string const& username)
12 // {
13 // if (getuid() != 0)
14 // {
15 // std::cerr << "this programm has to be run as root in order to run in a chroot" << std::endl;
16 // exit(-1);
17 // }
19 // struct passwd *pw = getpwnam(username.c_str());
20 // if(pw) {
21 // if(chroot(chrootdir.c_str()))
22 // {
23 // std::cerr << "can't chroot to " << chrootdir << std::endl;
24 // exit(-1);
25 // }
26 // std::cout << "we are in chroot jail (" << chrootdir << ") now" << std::endl;
27 // chdir("/");
28 // if (initgroups(pw->pw_name, pw->pw_gid) || setgid(pw->pw_gid) || setuid(pw->pw_uid))
29 // {
30 // std::cerr << "can't drop to user " << username << " " << pw->pw_uid << ":" << pw->pw_gid << std::endl;
31 // exit(-1);
32 // }
33 // std::cout << "dropped user to " << username << " " << pw->pw_uid << ":" << pw->pw_gid << std::endl;
34 // }
35 // else
36 // {
37 // std::cerr << "unknown user " << username << std::endl;
38 // exit(-1);
39 // }
40 // }
42 // void daemonize()
43 // {
44 // pid_t pid;
46 // pid = fork();
47 // if(pid) exit(0);
48 // setsid();
49 // pid = fork();
50 // if(pid) exit(0);
52 // std::cout << "running in background now..." << std::endl;
54 // int fd;
55 // for (fd=getdtablesize();fd>=0;--fd) // close all file descriptors
56 // close(fd);
57 // fd=open("/dev/null",O_RDWR); // stdin
58 // dup(fd); // stdout
59 // dup(fd); // stderr
60 // umask(027);
61 // }
64 int main(int argc, char* argv[])
66 std::cout << "plain_tool" << std::endl;
67 if(!gOpt.parse(argc, argv))
69 gOpt.printUsage();
70 exit(-1);
73 // if(gOpt.chroot)
74 // chrootAndDrop(gOpt.getChrootDir, gOpt.getUsername);
75 // if(testSetPid(gOpt.pidFilename))
76 // {
77 // std::cout << "exiting..." << std::endl;
78 // return -1;
79 // }
80 // if(gOpt.daemonize)
81 // daemonize(gOpt.pidFilename);
84 cLog.msg(Log::PRIO_NOTICE) << "plain_tool started...";
86 SignalController sig;
87 sig.init();
89 // pthread_t senderThread;
90 // pthread_create(&senderThread, NULL, sender, &p);
91 // pthread_detach(senderThread);
96 int ret = sig.run();
99 return ret;