From 7336d7da9e863be6fac9b5cab5ffe441e658f15f Mon Sep 17 00:00:00 2001 From: MilhouseVH Date: Wed, 5 Jul 2017 15:46:51 +0100 Subject: [PATCH] make binary addons executable add executable mode to all files in addon's bin folder credits to vpeter4 for the patch --- xbmc/addons/Addon.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) --- a/xbmc/addons/Addon.cpp +++ b/xbmc/addons/Addon.cpp @@ -29,6 +29,10 @@ #include #include +#include +#include +#include + #ifdef HAS_PYTHON #include "interfaces/python/XBPython.h" #endif @@ -665,6 +669,28 @@ void OnPreInstall(const AddonPtr& addon) void OnPostInstall(const AddonPtr& addon, bool update, bool modal) { + // OE: make binary addons executable, creddits to vpeter4 + std::string addonDirPath; + std::string chmodFilePath; + DIR *addonsDir; + struct dirent *fileDirent; + struct stat fileStat; + int statRet; + + addonDirPath = "/storage/.kodi/addons/" + addon->ID() + "/bin/"; + if ((addonsDir = opendir(addonDirPath.c_str())) != NULL) + { + while ((fileDirent = readdir(addonsDir)) != NULL) + { + chmodFilePath = addonDirPath + fileDirent->d_name; + statRet = stat(chmodFilePath.c_str(), &fileStat); + if (statRet == 0 && (fileStat.st_mode & S_IFMT) != S_IFDIR) + chmod(chmodFilePath.c_str(), fileStat.st_mode | S_IXUSR | S_IXGRP | S_IXOTH); + } + closedir(addonsDir); + } + // OE + addon->OnPostInstall(update, modal); }