diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lbdata.cc | 2 | ||||
-rw-r--r-- | src/lbdecision.cc | 1 | ||||
-rw-r--r-- | src/lboutput.cc | 1 | ||||
-rw-r--r-- | src/loadbalance.cc | 3 | ||||
-rw-r--r-- | src/main.cc | 24 |
5 files changed, 24 insertions, 7 deletions
diff --git a/src/lbdata.cc b/src/lbdata.cc index 99c36e7..60578de 100644 --- a/src/lbdata.cc +++ b/src/lbdata.cc @@ -332,7 +332,7 @@ LBData::update_dhcp_nexthop() LBData::InterfaceHealthIter h_iter = _iface_health_coll.begin(); while (h_iter != _iface_health_coll.end()) { if (h_iter->second._nexthop == "dhcp") { - string file("/var/lib/dhcp3/dhclient_"+h_iter->first+"_lease"); + string file("/var/lib/dhcp/dhclient_"+h_iter->first+"_lease"); FILE *fp = fopen(file.c_str(),"r"); if (fp) { char str[1025]; diff --git a/src/lbdecision.cc b/src/lbdecision.cc index a86a878..fd5fd62 100644 --- a/src/lbdecision.cc +++ b/src/lbdecision.cc @@ -13,6 +13,7 @@ #include <net/if.h> #include <string.h> #include <stdlib.h> +#include <unistd.h> #include <sys/types.h> #include <sys/ioctl.h> diff --git a/src/lboutput.cc b/src/lboutput.cc index 28eb001..d146d8e 100644 --- a/src/lboutput.cc +++ b/src/lboutput.cc @@ -9,6 +9,7 @@ #include <sys/time.h> #include <time.h> #include <syslog.h> +#include <unistd.h> #include <iostream> diff --git a/src/loadbalance.cc b/src/loadbalance.cc index 4f42388..80eab13 100644 --- a/src/loadbalance.cc +++ b/src/loadbalance.cc @@ -6,6 +6,7 @@ * by the Free Software Foundation. */ #include <string> +#include <unistd.h> #include "lbpathtest.hh" #include "loadbalance.hh" @@ -114,6 +115,6 @@ LoadBalance::output() void LoadBalance::sleep() { - ::sleep(5); + usleep(5000000); } diff --git a/src/main.cc b/src/main.cc index 05b1fa7..2be1edb 100644 --- a/src/main.cc +++ b/src/main.cc @@ -12,14 +12,16 @@ #include <syslog.h> #include <stdio.h> #include "stdlib.h" +#include <unistd.h> #include <iostream> +#include <unistd.h> +#include <grp.h> #include "loadbalance.hh" bool g_check_path = false; LoadBalance *g_lb = NULL; pid_t pid_output (const char *path); - static void usage() { cout << "lb -ftviodh" << endl; @@ -105,7 +107,7 @@ int main(int argc, char* argv[]) cout << "Configuration file is empty" << endl; exit(0); } - + int s = 0; if (daemon) { if (fork() != 0) { @@ -119,7 +121,7 @@ int main(int argc, char* argv[]) } g_lb = new LoadBalance(debug, output_path); - + bool success = g_lb->set_conf(c_file); if (success == false) { syslog(LOG_ERR, "wan_lb: error loading configuration file: %s", c_file.c_str()); @@ -134,9 +136,21 @@ int main(int argc, char* argv[]) cout << "STARTING CYCLE" << endl; } + // Get config owners group GID and set the GID to it to avoid + // ruining the permissions of the running config if hooks + // execute VyOS configuration commands + group* vyattacfg_group = getgrnam("vyattacfg"); + if (vyattacfg_group == NULL) { + syslog(LOG_ERR, "Could not get vyattacfg group ID, exiting"); + exit(1); + } + gid_t cfg_gid = vyattacfg_group->gr_gid; + setgid(cfg_gid); + + g_lb->init(); - + //signal handler here // sighup... signal(SIGINT, sig_end); @@ -191,7 +205,7 @@ pid_output (const char *path) oldumask = umask(0777 & ~PIDFILE_MASK); fp = fopen (path, "w"); - if (fp != NULL) + if (fp != NULL) { fprintf (fp, "%d\n", (int) pid); fclose (fp); |