From 29c8201974cd55718736e871cde6f8fb0ac3ebe2 Mon Sep 17 00:00:00 2001 From: Chalith Desaman Date: Wed, 5 Jul 2023 11:07:39 +0530 Subject: [PATCH] Do a chmod to avoid umask (#377) --- src/hpfs/hpfs_sync.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hpfs/hpfs_sync.cpp b/src/hpfs/hpfs_sync.cpp index 6ed4b079..2979bd11 100644 --- a/src/hpfs/hpfs_sync.cpp +++ b/src/hpfs/hpfs_sync.cpp @@ -769,7 +769,11 @@ namespace hpfs { if (!is_dir && errno == ENOENT) // File does not exist. So we must create it with the given 'mode'. { - if (mknod(physical_path.data(), full_mode, 0) == -1) + // The permissions of a created file are restricted by the process's current umask, so group and world write are always disabled by default. + // We do the chmod seperatly after mknod the file. Because if we give the g+w permission in mknod() mode param, + // The file won't get that permission because of the above mentioned default umask. + + if (mknod(physical_path.data(), full_mode, 0) == -1 || chmod(physical_path.data(), mode) == -1) { LOG_ERROR << errno << ": Error in creating file node. " << physical_path; return -1;