summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/anytun.cpp4
-rw-r--r--src/sysexec.hpp12
2 files changed, 12 insertions, 4 deletions
diff --git a/src/anytun.cpp b/src/anytun.cpp
index b33ddcd..46cdead 100644
--- a/src/anytun.cpp
+++ b/src/anytun.cpp
@@ -367,8 +367,8 @@ int main(int argc, char* argv[])
cLog.msg(Log::PRIO_NOTICE) << "dev type is '" << dev.getTypeString() << "'";
#ifndef NO_EXEC
if(gOpt.getPostUpScript() != "") {
- int postup_ret = execScript(gOpt.getPostUpScript(), dev.getActualName());
- cLog.msg(Log::PRIO_NOTICE) << "post up script '" << gOpt.getPostUpScript() << "' returned " << postup_ret;
+ cLog.msg(Log::PRIO_NOTICE) << "executing post-up script '" << gOpt.getPostUpScript() << "'";
+ execScript(gOpt.getPostUpScript(), dev.getActualName(), dev.getActualNode());
}
#endif
diff --git a/src/sysexec.hpp b/src/sysexec.hpp
index f2d5d35..2883102 100644
--- a/src/sysexec.hpp
+++ b/src/sysexec.hpp
@@ -33,7 +33,7 @@
#define _SYSEXEC_HPP
#ifndef NO_EXEC
-int execScript(std::string const& script, std::string const& ifname)
+int execScript(std::string const& script, std::string const& ifname, std::string const& ifnode)
{
pid_t pid;
pid = fork();
@@ -51,10 +51,18 @@ int execScript(std::string const& script, std::string const& ifname)
if(dup(fd) == -1) // stderr
cLog.msg(Log::PRIO_WARNING) << "can't open stderr";
}
- return execl("/bin/sh", "/bin/sh", script.c_str(), ifname.c_str(), NULL);
+ execl("/bin/sh", "/bin/sh", script.c_str(), ifname.c_str(), ifnode.c_str(), (char*)NULL);
+ // if execl return, an error occurred
+ cLog.msg(Log::PRIO_ERR) << "error on executing script: " << LogErrno(errno);
+ return -1;
}
int status = 0;
waitpid(pid, &status, 0);
+ if(WIFEXITED(status))
+ cLog.msg(Log::PRIO_NOTICE) << "script '" << script << "' returned " << WEXITSTATUS(status);
+ if(WIFSIGNALED(status))
+ cLog.msg(Log::PRIO_NOTICE) << "script '" << script << "' terminated after signal " << WTERMSIG(status);
+
return status;
}