summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/irmd/main.c14
-rw-r--r--src/tools/irm/irm_bind.c12
2 files changed, 25 insertions, 1 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c
index b4771b89..b14aa213 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -1613,9 +1613,21 @@ static int flow_dealloc(int port_id)
return ret;
}
-static int auto_execute(char ** argv)
+static pid_t auto_execute(char ** argv)
{
pid_t api;
+ struct stat s;
+
+ if (stat(argv[0], &s) != 0) {
+ LOG_WARN("Application %s does not exist.", argv[0]);
+ return -1;
+ }
+
+ if (!(s.st_mode & S_IXUSR)) {
+ LOG_WARN("Application %s is not executable.", argv[0]);
+ return -1;
+ }
+
LOG_INFO("Executing %s.", argv[0]);
api = fork();
if (api == -1) {
diff --git a/src/tools/irm/irm_bind.c b/src/tools/irm/irm_bind.c
index 85e5bd3d..3fc1d5c5 100644
--- a/src/tools/irm/irm_bind.c
+++ b/src/tools/irm/irm_bind.c
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <string.h>
+#include <sys/stat.h>
#include <ouroboros/irm.h>
@@ -44,6 +45,7 @@ int do_bind(int argc, char ** argv)
char * name = NULL;
char * ap_name = NULL;
uint16_t flags = 0;
+ struct stat s;
while (argc > 0) {
if (matches(*argv, "name") == 0) {
@@ -77,5 +79,15 @@ int do_bind(int argc, char ** argv)
return -1;
}
+ if (stat(ap_name, &s) != 0) {
+ printf("Application %s does not exist.\n\n", ap_name);
+ return -1;
+ }
+
+ if (!(s.st_mode & S_IXUSR)) {
+ printf("Application %s is not executable.\n\n", ap_name);
+ return -1;
+ }
+
return irm_bind(name, ap_name, flags, argc, argv);
}