mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Fixed bad permissions on LOOT .git folders.
They were being fixed when LOOT needed to delete them, but left with too restrictive permissions otherwise. Now the permissions are write access for all on successful operations too.
This commit is contained in:
+13
-9
@@ -40,6 +40,16 @@ namespace fs = boost::filesystem;
|
||||
namespace lc = boost::locale;
|
||||
|
||||
namespace loot {
|
||||
|
||||
// Removes the read-only flag from some files in git repositories created by libgit2.
|
||||
void FixRepoPermissions(const fs::path& path) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "Recursively setting write permission on directory: " << path;
|
||||
for (fs::recursive_directory_iterator it(path); it != fs::recursive_directory_iterator(); ++it) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "Setting write permission for: " << it->path();
|
||||
fs::permissions(it->path(), fs::add_perms | fs::owner_write | fs::group_write | fs::others_write);
|
||||
}
|
||||
}
|
||||
|
||||
struct git_handler {
|
||||
public:
|
||||
git_handler() :
|
||||
@@ -58,7 +68,10 @@ namespace loot {
|
||||
buf({0}) {}
|
||||
|
||||
~git_handler() {
|
||||
string path(git_repository_path(repo));
|
||||
free();
|
||||
|
||||
FixRepoPermissions(path);
|
||||
}
|
||||
|
||||
void free() {
|
||||
@@ -131,15 +144,6 @@ namespace loot {
|
||||
return git_repository_open_ext(NULL, path.string().c_str(), GIT_REPOSITORY_OPEN_NO_SEARCH, NULL) == 0;
|
||||
}
|
||||
|
||||
// Removes the read-only flag from some files in git repositories created by libgit2.
|
||||
void FixRepoPermissions(const fs::path& path) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "Recursively setting write permission on directory: " << path;
|
||||
for (fs::recursive_directory_iterator it(path); it != fs::recursive_directory_iterator(); ++it) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "Setting write permission for: " << it->path();
|
||||
fs::permissions(it->path(), fs::add_perms | fs::owner_write | fs::group_write | fs::others_write);
|
||||
}
|
||||
}
|
||||
|
||||
int diffFileCallback(const git_diff_delta *delta, float progress, void * payload) {
|
||||
BOOST_LOG_TRIVIAL(trace) << "Checking diff for: " << delta->old_file.path;
|
||||
if (strcmp(delta->old_file.path, "masterlist.yaml") == 0) {
|
||||
|
||||
Reference in New Issue
Block a user