From 139633a3347f62a028a593540c65c0e46f1d736c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Irina=20G=C3=B3mez?= Date: Wed, 5 Aug 2020 14:21:16 +0200 Subject: [PATCH] =?UTF-8?q?#986=20Fixs=20error=20in=20'Advanced=20Netboot'?= =?UTF-8?q?=20caused=20by=20loss=20information=20from=20ogserver=20process?= =?UTF-8?q?=20owner=20(author=20=20Roberto=20Hueso=20G=C3=B3mez).?= 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(-) 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;