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-11 10:00:45 -06:00
parent ac21cb5ae3
commit 4b94cfd391
15 changed files with 179 additions and 9 deletions
+3
View File
@@ -26,6 +26,7 @@
#include <sys/stat.h>
#include <dirent.h>
#include "../twcommon.h"
#include "../set_metadata.h"
#include <cutils/properties.h>
#include "MtpTypes.h"
@@ -1002,6 +1003,7 @@ MtpResponseCode MtpServer::doSendObjectInfo() {
return MTP_RESPONSE_GENERAL_ERROR;
}
chown((const char *)path, getuid(), mFileGroup);
tw_set_default_metadata((const char *)path);
// SendObject does not get sent for directories, so call endSendObject here instead
mDatabase->lockMutex();
@@ -1073,6 +1075,7 @@ MtpResponseCode MtpServer::doSendObject() {
ret = ioctl(mFD, MTP_RECEIVE_FILE, (unsigned long)&mfr);
}
close(mfr.fd);
tw_set_default_metadata((const char *)mSendObjectFilePath);
if (ret < 0) {
unlink(mSendObjectFilePath);