]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4037] Replaced umask by fchmod
authorFrancis Dupont <fdupont@isc.org>
Sun, 3 Aug 2025 16:59:40 +0000 (18:59 +0200)
committerFrancis Dupont <fdupont@isc.org>
Wed, 20 Aug 2025 19:00:47 +0000 (21:00 +0200)
src/lib/log/interprocess/interprocess_sync_file.cc

index ed6a5b7e2f8fd57b9e57d676273e77d872b78d86..c77b9ea3f9e64409d449305b03c06b3089e042f5 100644 (file)
@@ -54,10 +54,14 @@ InterprocessSyncFile::do_lock(int cmd, short l_type) {
 
         // Open the lockfile in the constructor so it doesn't do the access
         // checks every time a message is logged.
-        const mode_t mode = umask(S_IXUSR | S_IXGRP | S_IXOTH); // 0111
         fd_ = open(lockfile_path.c_str(), O_CREAT | O_RDWR,
                    S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); // 0660
-        umask(mode);
+        if (fd_ != -1) {
+            if (fchmod(fd_, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) != 0) {
+                close(fd_);
+                fd_ = -1;
+            }
+        }
 
         if (fd_ == -1) {
             std::stringstream tmp;