Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b94cfd3 authored by Ethan Yonker's avatar Ethan Yonker
Browse files

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
parent ac21cb5a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -449,8 +449,8 @@ include $(CLEAR_VARS)
LOCAL_MODULE := libaosprecovery
LOCAL_MODULE_TAGS := eng optional
LOCAL_C_INCLUDES := $(LOCAL_PATH)/libmincrypt/includes
LOCAL_SRC_FILES := adb_install.cpp asn1_decoder.cpp bootloader.cpp mtdutils/mtdutils.c legacy_property_service.c verifier.cpp
LOCAL_SHARED_LIBRARIES += libc liblog libcutils libmtdutils libfusesideload libmincrypttwrp
LOCAL_SRC_FILES := adb_install.cpp asn1_decoder.cpp bootloader.cpp mtdutils/mtdutils.c legacy_property_service.c verifier.cpp set_metadata.c
LOCAL_SHARED_LIBRARIES += libc liblog libcutils libmtdutils libfusesideload libmincrypttwrp libselinux

ifneq ($(BOARD_RECOVERY_BLDRMSG_OFFSET),)
    LOCAL_CFLAGS += -DBOARD_RECOVERY_BLDRMSG_OFFSET=$(BOARD_RECOVERY_BLDRMSG_OFFSET)
+2 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
#include "gui/blanktimer.hpp"
#endif
#include "find_file.hpp"
#include "set_metadata.h"

#ifdef TW_USE_MODEL_HARDWARE_ID_FOR_DEVICE_ID
	#include "cutils/properties.h"
@@ -333,6 +334,7 @@ int DataManager::SaveValues()
		}
	}
	fclose(out);
	tw_set_default_metadata(mBackingFile.c_str());
#endif // ifdef TW_OEM_BUILD
	return 0;
}
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ else
  LOCAL_SRC_FILES += hardwarekeyboard.cpp
endif

LOCAL_SHARED_LIBRARIES += libminuitwrp libc libstdc++ libminzip
LOCAL_SHARED_LIBRARIES += libminuitwrp libc libstdc++ libminzip libaosprecovery
LOCAL_MODULE := libguitwrp

# Use this flag to create a build that simulates threaded actions like installing zips, backups, restores, and wipes for theme testing
+8 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ extern "C" {
#include "cutils/properties.h"
#include "../minadbd/adb.h"
#include "../adb_install.h"
#include "../set_metadata.h"

int TWinstall_zip(const char* path, int* wipe_cache);
void run_script(const char *str1, const char *str2, const char *str3, const char *str4, const char *str5, const char *str6, const char *str7, int request_confirm);
@@ -503,6 +504,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
			PartitionManager.Mount_Current_Storage(true);
			dst = DataManager::GetCurrentStoragePath() + "/recovery.log";
			TWFunc::copy_file("/tmp/recovery.log", dst.c_str(), 0755);
			tw_set_default_metadata(dst.c_str());
			sync();
			gui_print("Copied recovery log to %s.\n", DataManager::GetCurrentStoragePath().c_str());
		} else
@@ -1222,6 +1224,12 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */)
							int check = 0;
							std::string theme_path;

							if (tw_get_default_metadata(DataManager::GetSettingsStoragePath().c_str()) != 0) {
								LOGERR("Failed to get default contexts and file mode for storage files.\n");
							} else {
								LOGINFO("Got default contexts and file mode for storage files.\n");
							}

							theme_path = DataManager::GetSettingsStoragePath();
							if (PartitionManager.Mount_By_Path(theme_path.c_str(), 1) < 0) {
								LOGERR("Unable to mount %s during reload function startup.\n", theme_path.c_str());
+3 −1
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
#include "infomanager.hpp"
#include "twcommon.h"
#include "partitions.hpp"
#include "set_metadata.h"

using namespace std;

@@ -112,6 +113,7 @@ LOGINFO("InfoManager saving '%s'\n", File.c_str());
		fwrite(iter->second.c_str(), 1, length, out);
	}
	fclose(out);
	tw_set_default_metadata(File.c_str());
	return 0;
}

Loading