summaryrefslogtreecommitdiffstats
path: root/src/util/util.h
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2014-04-19 16:11:47 -0400
committerJakub Hrozek <jhrozek@redhat.com>2014-04-28 21:57:01 +0200
commit9a592ee3fc195f20732c6b1f90894a0be25ccc19 (patch)
tree320d37f03789f3d938a51dae0aaec82c9ad5f9a4 /src/util/util.h
parent8e09148b68a3fd8b06fcb746054f3cfa250b40f8 (diff)
downloadsssd-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/util/util.h')
-rw-r--r--src/util/util.h26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/util/util.h b/src/util/util.h
index c74ff5b56..54c6c6c78 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -329,18 +329,6 @@ sss_get_domain_name(TALLOC_CTX *mem_ctx, const char *orig_name,
/* from backup-file.c */
int backup_file(const char *src, int dbglvl);
-/* from check_and_open.c */
-enum check_file_type {
- CHECK_DONT_CHECK_FILE_TYPE = -1,
- CHECK_REG,
- CHECK_DIR,
- CHECK_CHR,
- CHECK_BLK,
- CHECK_FIFO,
- CHECK_LNK,
- CHECK_SOCK
-};
-
/* check_file()
* Verify that a file has certain permissions and/or is of a certain
* file type. This function can be used to determine if a file is a
@@ -352,8 +340,8 @@ enum check_file_type {
* inode to minimize impact. Permission changes may have occurred,
* however.
*/
-errno_t check_file(const char *filename, const int uid, const int gid,
- const int mode, enum check_file_type type,
+errno_t check_file(const char *filename,
+ uid_t uid, gid_t gid, mode_t mode, mode_t mask,
struct stat *caller_stat_buf, bool follow_symlink);
/* check_fd()
@@ -363,8 +351,8 @@ errno_t check_file(const char *filename, const int uid, const int gid,
* is the safer way to perform file checks and should be preferred
* over check_file for nearly all situations.
*/
-errno_t check_fd(int fd, const int uid, const int gid,
- const int mode, enum check_file_type type,
+errno_t check_fd(int fd, uid_t uid, gid_t gid,
+ mode_t mode, mode_t mask,
struct stat *caller_stat_buf);
/* check_and_open_readonly()
@@ -372,9 +360,9 @@ errno_t check_fd(int fd, const int uid, const int gid,
* permissions and is of a certain file type. This function wraps
* check_fd(), and is considered race-condition safe.
*/
-errno_t check_and_open_readonly(const char *filename, int *fd, const uid_t uid,
- const gid_t gid, const mode_t mode,
- enum check_file_type type);
+errno_t check_and_open_readonly(const char *filename, int *fd,
+ uid_t uid, gid_t gid,
+ mode_t mode, mode_t mask);
/* from util.c */
#define SSS_NO_LINKLOCAL 0x01