static void copyLibraryCreateSymlink(const char* pkgId, std::vector<std::string> LibrariesInfo, std::string tlcDir)
{
if (LibrariesInfo.empty()) {
- _INFO("Not exist data for TLC in %s", pkgId);
return;
}
status = "install";
if (tacDB.empty()) {
- _INFO("Not exist data for TAC in %s", pkgId);
return 0;
}
_ERR("Cannot create directory: %s", tlcDir.c_str());
return 0;
}
+ copySmackAndOwnership(__DOTNET_DIR, tlcDir);
tlc_db = createDB(TLC_APP_LIST_DB, CREATE_TLC_DB_TABLE);
if (!tlc_db) {
tac_updateDB(tac_db);
skipTLC = true;
- _INFO("Not exist data for TAC in %s", pkgId);
} else {
std::string tac_dir = concatPath(binPath, TAC_SYMLINK_SUB_DIR);
if (!createDir(tac_dir)) {
_ERR("Cannot create directory: %s", tlcDir.c_str());
return 0;
}
+ copySmackAndOwnership(__DOTNET_DIR, tlcDir);
tlc_db = createDB(TLC_APP_LIST_DB, CREATE_TLC_DB_TABLE);
if (!tlc_db) {
return 0;
}
+void changeOwnershipTAC(std::string current_tac)
+{
+ copySmackAndOwnership(__DOTNET_DIR, current_tac);
+ try {
+ for (auto& path : bf::recursive_directory_iterator(current_tac))
+ copySmackAndOwnership(__DOTNET_DIR, path.path().string());
+ } catch (const bf::filesystem_error& error) {
+ _ERR("Failed to recursive directory: %s", error.what());
+ }
+}
+
void cleanStep(std::string tac)
{
std::string current_tac = concatPath(__DOTNET_DIR, tac.substr(0, tac.find('/')));
void install_Clean()
{
- return;
+ for (auto& cd : createDirectories) {
+ changeOwnershipTAC(cd);
+ }
+
+ for (auto& cl : createLibraries) {
+ changeOwnershipTAC(cl);
+ }
}
void unInstall_Clean()
void update_Clean()
{
+ install_Clean();
if (!tacDB.empty()) {
for (auto& np : tacDB) {
cleanStep(np);
+ changeOwnershipTAC(concatPath(__DOTNET_DIR, np.substr(0, np.find('/'))));
}
}
unInstall_Clean();
if (tac_db) {
closeDB(tac_db);
tac_db = NULL;
+ copySmackAndOwnership(__DOTNET_DIR, TAC_APP_LIST_DB);
+ copySmackAndOwnership(__DOTNET_DIR, TAC_APP_LIST_DB + std::string("-journal"));
}
if (tlc_db) {
closeDB(tlc_db);
tlc_db = NULL;
+ copySmackAndOwnership(__DOTNET_DIR, TLC_APP_LIST_DB);
+ copySmackAndOwnership(__DOTNET_DIR, TLC_APP_LIST_DB + std::string("-journal"));
}
return 0;
tac_db = NULL;
}
- const uid_t g_uid = 301; // app_fw
- const gid_t g_gid = 301; // app_fw
-
if (!copyFile(TAC_APP_LIST_RESTORE_DB, TAC_APP_LIST_DB)) {
fprintf(stderr, "Failed to copy of %s\n", TAC_APP_LIST_DB);
return TAC_ERROR_UNKNOWN;
fprintf(stderr, "Failed to remove of %s\n", TAC_APP_LIST_RESTORE_DB);
return TAC_ERROR_UNKNOWN;
}
- if (chown(TAC_APP_LIST_DB, g_uid, g_gid) == -1) {
- fprintf(stderr, "Failed to change owner and group name\n");
- }
std::string dbJournal = TAC_APP_LIST_DB + std::string("-journal");
if (!copyFile(dbRestoreJournal, dbJournal)) {
fprintf(stderr, "Failed to remove of %s\n", dbRestoreJournal.c_str());
return TAC_ERROR_UNKNOWN;
}
- if (chown(dbJournal.c_str(), g_uid, g_gid) == -1) {
- fprintf(stderr, "Failed to change owner and group name\n");
- }
cleanupDirectory();
tlc_db = NULL;
}
- const uid_t g_uid = 301; // app_fw
- const gid_t g_gid = 301; // app_fw
-
if (!copyFile(TLC_APP_LIST_RESTORE_DB, TLC_APP_LIST_DB)) {
fprintf(stderr, "Failed to copy of %s\n", TLC_APP_LIST_DB);
return TAC_ERROR_UNKNOWN;
fprintf(stderr, "Failed to remove of %s\n", TLC_APP_LIST_RESTORE_DB);
return TAC_ERROR_UNKNOWN;
}
- if (chown(TLC_APP_LIST_DB, g_uid, g_gid) == -1) {
- fprintf(stderr, "Failed to change owner and group name\n");
- }
std::string dbJournal = TLC_APP_LIST_DB + std::string("-journal");
if (!copyFile(dbRestoreJournal, dbJournal)) {
fprintf(stderr, "Failed to remove of %s\n", dbRestoreJournal.c_str());
return TAC_ERROR_UNKNOWN;
}
- if (chown(dbJournal.c_str(), g_uid, g_gid) == -1) {
- fprintf(stderr, "Failed to change owner and group name\n");
- }
auto convert = [](const std::string& path, const std::string& filename) {
bool isExist = false;