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:
+8
-3
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user