summaryrefslogtreecommitdiff
path: root/src/sysexec.hpp
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@anytun.org>2008-11-28 17:39:14 +0000
committerOthmar Gsenger <otti@anytun.org>2008-11-28 17:39:14 +0000
commit409d58d0b63a113b29d8ce7c75a70e6dbbb39e69 (patch)
tree27a2526d6fc3b4600f18572e77f9fb8890ccfb39 /src/sysexec.hpp
parentfixed datatypes (really using boost now) (diff)
added compile time options NOCRYPT,NODAEMON,NOEXEC for easyier windows porting
moved crypto init functions to cryptinit.hpp and exec to sysexec.hpp (as this will be platform dependant)
Diffstat (limited to 'src/sysexec.hpp')
-rw-r--r--src/sysexec.hpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/sysexec.hpp b/src/sysexec.hpp
new file mode 100644
index 0000000..73a18bf
--- /dev/null
+++ b/src/sysexec.hpp
@@ -0,0 +1,26 @@
+#ifndef _SYSEXEC_HPP
+#define _SYSEXEC_HPP
+#ifndef NOEXEC
+
+int execScript(std::string const& script, std::string const& ifname)
+{
+ pid_t pid;
+ pid = fork();
+ if(!pid) {
+ int fd;
+ for (fd=getdtablesize();fd>=0;--fd) // close all file descriptors
+ close(fd);
+ fd=open("/dev/null",O_RDWR); // stdin
+ dup(fd); // stdout
+ dup(fd); // stderr
+ return execl("/bin/sh", "/bin/sh", script.c_str(), ifname.c_str(), NULL);
+ }
+ int status = 0;
+ waitpid(pid, &status, 0);
+ return status;
+}
+
+
+#endif
+#endif
+