Skip to content

Commit

Permalink
Merge branch 'fix/permissions-after-unpack' of github.com:nzbgetcom/n…
Browse files Browse the repository at this point in the history
…zbget into feature/test-fix-permissions
  • Loading branch information
phnzb committed Apr 11, 2024
2 parents 13ad0c9 + 3e8bb6c commit 5103801
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions daemon/util/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "nzbget.h"
#include "FileSystem.h"
#include "Util.h"
#include "Log.h"

const char* RESERVED_DEVICE_NAMES[] = { "CON", "PRN", "AUX", "NUL",
"COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9",
Expand Down Expand Up @@ -960,11 +961,15 @@ void FileSystem::FixExecPermission(const char* filename)

void FileSystem::SetFilePermissionsWithUmask(const char* filename, mode_t umask)
{
struct stat buffer;
if (!stat(filename, &buffer))
mode_t permissions = buffer.st_mode & ~umask;
info("%s %o %s %s", "Setting permissons ", permissions, "on", filename);
if (!chmod(filename, permissions))
{
info("%s", "Success");
}
else
{
mode_t permissions = buffer.st_mode & ~umask;
chmod(filename, permissions);
error("%s", "Failure");
}
}
#endif
Expand Down

0 comments on commit 5103801

Please sign in to comment.