From 8cb2f2fe999476b55358e3cfbdcbcbb3cf75f2cb Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Sun, 3 Jul 2016 16:20:56 +0200 Subject: tools, irm: move binary check to library This will make the library check if the user has permissions to execute the binary when auto is set. This prevents writing malicious software that would use the irmd to execute other applications to which the user has no access. --- src/lib/irm.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/lib/irm.c') diff --git a/src/lib/irm.c b/src/lib/irm.c index 6b296258..93963eb1 100644 --- a/src/lib/irm.c +++ b/src/lib/irm.c @@ -29,6 +29,7 @@ #include #include +#include pid_t irm_create_ipcp(char * name, enum ipcp_type ipcp_type) @@ -246,10 +247,17 @@ int irm_bind(char * name, irm_msg_t msg = IRM_MSG__INIT; irm_msg_t * recv_msg = NULL; int ret = -1; + struct stat s; if (name == NULL || ap_name == NULL) return -EINVAL; + if (stat(ap_name, &s) != 0) + return -ENOENT; + + if (!(s.st_mode & S_IXUSR)) + return -EPERM; + msg.code = IRM_MSG_CODE__IRM_BIND; msg.dst_name = name; msg.ap_name = ap_name; -- cgit v1.2.3