9 #define perm_owner(m) ((m & S_IRWXU) >> 6) 10 #define perm_group(m) ((m & S_IRWXG) >> 3) 11 #define perm_other(m) (m & S_IRWXO) 12 #define check_mode(m, c) (((m) | (c)) == (m) ? 1 : 0) 13 #define checkpermission_root(m, c) check_mode(perm_owner(m) | perm_group(m) | perm_other(m), c) 20 int ngroups = getgroups(0, NULL);
21 gid_t *groups = (gid_t *)realloc(*g, ngroups *
sizeof(gid_t));
22 if(getgroups(ngroups, groups) < 0)
34 uid_t uid = geteuid();
37 else if(uid == st->st_uid)
43 for(i = 0; i < ngid; i++)
45 if(gid[i] == st->st_gid)
64 if(stat(path, &st) != 0)
int checkpermission(struct stat *st, mode_t mode)
int check_path_exists(const char *path, mode_t type, mode_t mode)
int read_all_groups(gid_t **g)
#define checkpermission_root(m, c)