From 5a2123471a4b4a2bd8ee260879a207aebd5d1441 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Sun, 3 Jul 2016 14:57:04 +0200 Subject: irmd, tools: checks on binary The bind tool and the auto_execute function will check if the binary exists and is executable. Return value of auto_execute corrected to pid_t --- src/irmd/main.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/irmd/main.c') 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) { -- cgit v1.2.3