summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorikerexxe <ipedrosa@redhat.com>2020-06-15 09:52:11 +0200
committerTomáš Mráz <7125407+t8m@users.noreply.github.com>2020-06-17 14:33:23 +0200
commit395915dae1571e10e2766c999974de864655ea3a (patch)
tree96cc77944050582442ed487af4987f4939e93cbf /modules
parentefd2a79c11982d0feebebbf740506c9555120b97 (diff)
pam_faillock: change /run/faillock/$USER permissions to 0660
Nowadays, /run/faillock/$USER files have user:root ownership and 0600 permissions. This forces the process that writes to these files to have CAP_DAC_OVERRIDE capabilites. Just by changing the permissions to 0660 the capability can be removed, which leads to a more secure system. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1661822
Diffstat (limited to 'modules')
-rw-r--r--modules/pam_faillock/faillock.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/modules/pam_faillock/faillock.c b/modules/pam_faillock/faillock.c
index e492f5f9..4ea94cbe 100644
--- a/modules/pam_faillock/faillock.c
+++ b/modules/pam_faillock/faillock.c
@@ -76,7 +76,7 @@ open_tally (const char *dir, const char *user, uid_t uid, int create)
flags |= O_CREAT;
}
- fd = open(path, flags, 0600);
+ fd = open(path, flags, 0660);
free(path);
@@ -88,6 +88,18 @@ open_tally (const char *dir, const char *user, uid_t uid, int create)
if (st.st_uid != uid) {
ignore_return(fchown(fd, uid, -1));
}
+
+ /*
+ * If umask is set to 022, as will probably in most systems, then the
+ * group will not be able to write to the file. So, change the file
+ * permissions just in case.
+ * Note: owners of this file are user:root, so if the permissions are
+ * not changed the root process writing to this file will require
+ * CAP_DAC_OVERRIDE.
+ */
+ if (!(st.st_mode & S_IWGRP)) {
+ ignore_return(fchmod(fd, 0660));
+ }
}
}