diff options
author | Simo Sorce <simo@redhat.com> | 2014-04-19 16:11:47 -0400 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-04-28 21:57:01 +0200 |
commit | 9a592ee3fc195f20732c6b1f90894a0be25ccc19 (patch) | |
tree | 320d37f03789f3d938a51dae0aaec82c9ad5f9a4 /src/sbus/sssd_dbus_server.c | |
parent | 8e09148b68a3fd8b06fcb746054f3cfa250b40f8 (diff) | |
download | sssd-9a592ee3fc195f20732c6b1f90894a0be25ccc19.tar.gz sssd-9a592ee3fc195f20732c6b1f90894a0be25ccc19.tar.xz sssd-9a592ee3fc195f20732c6b1f90894a0be25ccc19.zip |
util: Change file check fns to use a mode mask
Instead of using a custom way to chck file type, use the system
provided macros and a mode mask to decide when we want to check.
Additionally a mask also allows us to selectively check permissions.
Related:
https://bugzilla.redhat.com/1089098
Resolves:
https://fedorahosted.org/sssd/ticket/2321
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Pavel Reichl <preichl@redhat.com>
Diffstat (limited to 'src/sbus/sssd_dbus_server.c')
-rw-r--r-- | src/sbus/sssd_dbus_server.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/sbus/sssd_dbus_server.c b/src/sbus/sssd_dbus_server.c index 39c315da5..3a7de8ff0 100644 --- a/src/sbus/sssd_dbus_server.c +++ b/src/sbus/sssd_dbus_server.c @@ -249,15 +249,16 @@ int sbus_new_server(TALLOC_CTX *mem_ctx, /* Both check_file and chmod can handle both the symlink and * the socket */ - ret = check_file(filename, getuid(), getgid(), -1, CHECK_SOCK, &stat_buf, true); + ret = check_file(filename, + getuid(), getgid(), S_IFSOCK, S_IFMT, &stat_buf, true); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, "check_file failed for [%s].\n", filename); ret = EIO; goto done; } - if ((stat_buf.st_mode & ~S_IFMT) != 0600) { - ret = chmod(filename, 0600); + if ((stat_buf.st_mode & ~S_IFMT) != (S_IRUSR|S_IWUSR)) { + ret = chmod(filename, (S_IRUSR|S_IWUSR)); if (ret != EOK) { DEBUG(SSSDBG_CRIT_FAILURE, "chmod failed for [%s]: [%d][%s].\n", filename, errno, |