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/tools/irm/irm_bind.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/tools/irm/irm_bind.c') 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 #include +#include #include @@ -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); } -- cgit v1.2.3 From 9a255c8ff98815cc1c6d0b39c19e8ee2afbb587c Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Sun, 3 Jul 2016 15:15:50 +0200 Subject: irm bind: fixed double newline --- src/tools/irm/irm_bind.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/tools/irm/irm_bind.c') diff --git a/src/tools/irm/irm_bind.c b/src/tools/irm/irm_bind.c index 3fc1d5c5..92ebdd8a 100644 --- a/src/tools/irm/irm_bind.c +++ b/src/tools/irm/irm_bind.c @@ -80,12 +80,12 @@ int do_bind(int argc, char ** argv) } if (stat(ap_name, &s) != 0) { - printf("Application %s does not exist.\n\n", ap_name); + printf("Application %s does not exist.\n", ap_name); return -1; } if (!(s.st_mode & S_IXUSR)) { - printf("Application %s is not executable.\n\n", ap_name); + printf("Application %s is not executable.\n", ap_name); return -1; } -- cgit v1.2.3