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
This commit is contained in:
Ethan Yonker
2014-12-12 09:20:42 -06:00
parent ac21cb5ae3
commit 4b94cfd391
15 changed files with 179 additions and 9 deletions
+8 -3
View File
@@ -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);