]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: Ensure utab.lock mode 644
authorStanislav Brabec <sbrabec@suse.cz>
Tue, 11 Apr 2017 14:12:52 +0000 (16:12 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 18 Apr 2017 09:13:32 +0000 (11:13 +0200)
If utab.lock is created by a process with a restricted umask, utab.lock is
created with restricted permissions. It breaks userspace monitor.

Ensure that the mode is always 644.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
libmount/src/lock.c

index 06eff1344b9ce67fe3d34eb9a15cd8fd8a36b033..f9d0253fb66d2a0aa94ac8d8eb7adb46857e0272 100644 (file)
@@ -220,6 +220,11 @@ static int lock_simplelock(struct libmnt_lock *ml)
                rc = -errno;
                goto err;
        }
+       rc = fchmod(ml->lockfile_fd, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
+       if (rc < 0) {
+               rc = -errno;
+               goto err;
+       }
 
        while (flock(ml->lockfile_fd, LOCK_EX) < 0) {
                int errsv;