From 139633a3347f62a028a593540c65c0e46f1d736c Mon Sep 17 00:00:00 2001 From: Irina Gómez Date: Wed, 5 Aug 2020 14:21:16 +0200 Subject: #986 Fixs error in 'Advanced Netboot' caused by loss information from ogserver process owner (author Roberto Hueso Gómez). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rest.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/rest.c b/src/rest.c index 3e4d39c..5f5e3f5 100644 --- a/src/rest.c +++ b/src/rest.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include struct ev_loop *og_loop; @@ -939,9 +941,8 @@ static int og_set_client_mode(struct og_dbi *dbi, const char *mac, const char *msglog; dbi_result result; unsigned int i; - char cmd[200]; int numbytes; - int err = 0; + int status; int fd; result = dbi_conn_queryf(dbi->conn, @@ -982,12 +983,16 @@ static int og_set_client_mode(struct og_dbi *dbi, const char *mac, return -1; } - snprintf(cmd, sizeof(cmd), "/opt/opengnsys/bin/setclientmode %s", - filename); - - err = system(cmd); + if (fork() == 0) { + execlp("/bin/bash", "/bin/bash", + "/opt/opengnsys/bin/setclientmode", filename, NULL); + _exit(1); + } else { + wait(&status); + } unlink(filename); - if (err != 0) { + + if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { syslog(LOG_ERR, "failed script execution (%s:%d)\n", __func__, __LINE__); return -1; -- cgit v1.2.3-18-g5258