From: Woongsuk Cho Date: Mon, 10 Aug 2020 07:15:00 +0000 (+0900) Subject: Remove debug pipe for candidate process X-Git-Tag: accepted/tizen/unified/20200811.050502^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d64e1c5574384191b7b93729dcb5c0df031ae223;p=platform%2Fcore%2Fdotnet%2Flauncher.git Remove debug pipe for candidate process The debug pipe created in the candidate process has a "User" label. As a result, smack deny occurs when app process try to access the debug pipe. Also, since debugging is performed only in standalone mode, the debug pipe does not be used in the candidate process --- diff --git a/NativeLauncher/launcher/lib/core_runtime.cc b/NativeLauncher/launcher/lib/core_runtime.cc index 8795ac3..2a39b0a 100644 --- a/NativeLauncher/launcher/lib/core_runtime.cc +++ b/NativeLauncher/launcher/lib/core_runtime.cc @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -223,6 +224,31 @@ static std::string readSelfPath() return ""; } +static void removeDebugPipe() +{ + DIR *dir; + struct dirent* entry; + char debugPipeFiles[PATH_MAX];; + sprintf(debugPipeFiles, "/tmp/clr-debug-pipe-%d-", getpid()); + + dir = opendir("/tmp"); + if (dir == nullptr) { + _ERR("Fail to open /tmp directory"); + return; + } + + while ((entry = readdir(dir)) != nullptr) { + std::string path = concatPath("/tmp", entry->d_name); + if (path.find(debugPipeFiles) != std::string::npos) { + if (!removeFile(path)) { + _ERR("Fail to remove file (%s)", path.c_str()); + } + } + } + + closedir(dir); +} + void preload() { typedef void (*PreloadDelegate)(); @@ -425,6 +451,13 @@ int CoreRuntime::initialize(const char* appType, LaunchMode launchMode) // preload libraries and manage dlls for optimizing startup time preload(); + + // The debug pipe created in the candidate process has a "User" label. + // As a result, smack deny occurs when app process try to access the debug pipe. + // Also, since debugging is performed only in standalone mode, + // the debug pipe doesnot be used in the candidate process. + // So, to avoid smack deny error, delete unused debug pipe files. + removeDebugPipe(); } __initialized = true;