From 9a592ee3fc195f20732c6b1f90894a0be25ccc19 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 19 Apr 2014 16:11:47 -0400 Subject: 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 Reviewed-by: Pavel Reichl --- src/sbus/sssd_dbus_server.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/sbus/sssd_dbus_server.c') 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, -- cgit