From 4b94cfd3910de26dbca64cf746a899cbc635158b Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Thu, 11 Dec 2014 10:00:45 -0600 Subject: Attempt to set the proper uid/gid/contexts on new files and dirs Files and folders that we create during backups, copy log, or MTP operations often do not have the proper uid/gid/contexts assigned. We will attempt to read the proper contexts from the settings storage path and assign those same contexts to any files or dirs that we create. Change-Id: I769f9479854122b49b499de2175e6e2d026f8afd --- twrp-functions.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'twrp-functions.cpp') diff --git a/twrp-functions.cpp b/twrp-functions.cpp index 96114241f..b51024cf1 100644 --- a/twrp-functions.cpp +++ b/twrp-functions.cpp @@ -54,6 +54,7 @@ extern "C" { #include "libcrecovery/common.h" + #include "set_metadata.h" } /* Execute a command */ @@ -406,9 +407,13 @@ int TWFunc::Recursive_Mkdir(string Path) { while (pos != string::npos) { wholePath = pathCpy.substr(0, pos); - if (mkdir(wholePath.c_str(), 0777) && errno != EEXIST) { - LOGERR("Unable to create folder: %s (errno=%d)\n", wholePath.c_str(), errno); - return false; + if (!TWFunc::Path_Exists(wholePath)) { + if (mkdir(wholePath.c_str(), 0777)) { + LOGERR("Unable to create folder: %s (errno=%d)\n", wholePath.c_str(), errno); + return false; + } else { + tw_set_default_metadata(wholePath.c_str()); + } } pos = pathCpy.find("/", pos + 1); -- cgit v1.2.3