5 * Daniel Pirkl <daniel.pirkl@email.cz>
6 * Charles University, Faculty of Mathematics and Physics
12 * Copyright (C) 1993, 1994, 1995
13 * Remy Card (card@masi.ibp.fr)
14 * Laboratoire MASI - Institut Blaise Pascal
15 * Universite Pierre et Marie Curie (Paris VI)
19 * This file will contain the Access Control Lists management for UFS
22 #include <linux/errno.h>
24 #include <linux/ufs_fs.h>
25 #include <linux/sched.h>
26 #include <linux/stat.h>
31 * Check for access rights
33 int ufs_permission (struct inode
* inode
, int mask
)
35 unsigned short mode
= inode
->i_mode
;
38 * Nobody gets write access to a file on a readonly-fs
40 if ((mask
& S_IWOTH
) &&
41 (S_ISREG(mode
) || S_ISDIR(mode
) || S_ISLNK(mode
)) &&
45 * Nobody gets write access to an immutable file
47 if ((mask
& S_IWOTH
) && IS_IMMUTABLE(inode
))
51 * If no ACL, checks using the file mode
53 else if (current
->fsuid
== inode
->i_uid
)
55 else if (in_group_p (inode
->i_gid
))
58 * Access is always granted for root. We now check last,
59 * though, for BSD process accounting correctness
61 if (((mode
& mask
& S_IRWXO
) == mask
) || capable(CAP_DAC_OVERRIDE
))
63 if ((mask
== S_IROTH
) ||
64 (S_ISDIR(mode
) && !(mask
& ~(S_IROTH
| S_IXOTH
))))
65 if (capable(CAP_DAC_READ_SEARCH
))