Skip to content

Commit

Permalink
Merge pull request #314 from lonemadmax/noexec
Browse files Browse the repository at this point in the history
Templates: just add write permissions on copy
  • Loading branch information
Freaxed authored Feb 11, 2024
2 parents 245d0ab + 53069ca commit cc1501c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/helpers/FSUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ namespace fs = std::filesystem;


status_t
FSChmod(const fs::path& path, fs::perms perm, bool recurse)
FSMakeWritable(const fs::path& path, bool recurse)
{
fs::permissions(path, perm); // set permissions on the top directory
fs::permissions(path, fs::perms::owner_write, fs::perm_options::add);
if (recurse) {
for (auto& de : fs::recursive_directory_iterator(path)) {
fs::permissions(de, perm); // set permissions
fs::permissions(de, fs::perms::owner_write, fs::perm_options::add);
}
}
return B_OK;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/FSUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace fs = std::filesystem;
status_t FSCheckCopiable(BEntry *src, BEntry *dest);
status_t FSCopyFile(BEntry *src, BEntry *dest, bool clobber);
status_t FSMoveFile(BEntry *src, BEntry *dest, bool clobber);
status_t FSChmod(const fs::path& path, fs::perms perm, bool recurse = false);
status_t FSMakeWritable(const fs::path& path, bool recurse = false);
status_t FSDeleteFolder(BEntry *dirEntry);

#endif
6 changes: 3 additions & 3 deletions src/templates/TemplateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ TemplateManager::CopyFileTemplate(const entry_ref* source, const entry_ref* dest
BString err(strerror(status));
LogError("Error creating new file %s in %s: %s", sourcePath.Path(), destPath.Path(),err.String());
} else {
FSChmod(destPath.Path(), fs::perms::all);
FSMakeWritable(destPath.Path());
if (newFileRef != nullptr) {
get_ref_for_path(destPath.Path(), newFileRef);
}
Expand All @@ -79,8 +79,8 @@ TemplateManager::CopyProjectTemplate(const entry_ref* source, const entry_ref* d
LogError("Error creating new template %s in %s: %s", sourcePath.Path(), destPath.Path(),err.String());
} else {
// TODO: Default templates in a tipical HPKG installation are readonly
// we are setting all permissions recursively here
FSChmod(destPath.Path(), fs::perms::all, true);
// we are setting write permissions recursively here
FSMakeWritable(destPath.Path(), true);
}

return status;
Expand Down

0 comments on commit cc1501c

Please sign in to comment.