summaryrefslogtreecommitdiffstats
path: root/src/rest.c
diff options
context:
space:
mode:
authorIrina Gómez <irinagomez@us.es>2020-08-05 14:21:16 +0200
committerIrina Gómez <irinagomez@us.es>2020-08-05 14:21:16 +0200
commit139633a3347f62a028a593540c65c0e46f1d736c (patch)
treef2e4745fdb010cb6777097b850d977ee2dd83f48 /src/rest.c
parentb8a509b1dd80cabad5ffeffd0d35117c6d63c7bf (diff)
#986 Fixs error in 'Advanced Netboot' caused by loss information from ogserver process owner (author Roberto Hueso Gómez).
Diffstat (limited to 'src/rest.c')
-rw-r--r--src/rest.c19
1 files 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 <dirent.h>
#include <time.h>
#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
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;