diff options
Diffstat (limited to 'libdiskfs')
-rw-r--r-- | libdiskfs/file-chmod.c | 27 | ||||
-rw-r--r-- | libdiskfs/file-chown.c | 23 | ||||
-rw-r--r-- | libdiskfs/file-getcontrol.c | 13 |
3 files changed, 21 insertions, 42 deletions
diff --git a/libdiskfs/file-chmod.c b/libdiskfs/file-chmod.c index 6e92822c..c5228d13 100644 --- a/libdiskfs/file-chmod.c +++ b/libdiskfs/file-chmod.c @@ -1,5 +1,5 @@ /* libdiskfs implementation of fs.defs: file_chmod - Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation + Copyright (C) 1992, 1993, 1994 Free Software Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -22,30 +22,21 @@ error_t diskfs_S_file_chmod (struct protid *cred, mode_t mode) { - struct userid *id; - mode &= ~(S_IFMT | S_ISPARE); CHANGE_NODE_FIELD (cred, ({ if (!(err = diskfs_isowner (np, cred))) { - /* Run through each ID in the chain - to see if it is allowed to do the operations - requested. Turn off bits as we find - that they are prohibited. */ - assert (cred->id); - for (id = cred->id; id; id = id->next) + if (!diskfs_isuid (0, cred)) { - if (!_diskfs_idhasuid (0, id)) - { - if (!S_ISDIR (np->dn_stat.st_mode)) - mode &= ~S_ISVTX; - if (!diskfs_idhasgid (np->dn_stat.st_gid, id)) - mode &= ~S_ISGID; - if (!diskfs_idhasuid (np->dn_stat.st_uid, id)) - mode &= ~S_ISUID; - } + if (!S_ISDIR (np->dn_stat.st_mode)) + mode &= ~S_ISVTX; + if (!diskfs_groupmember (np->dn_stat.st_gid, + cred)) + mode &= ~S_ISGID; + if (!diskfs_isuid (np->dn_stat.st_uid, cred)) + mode &= ~S_ISUID; } mode |= (np->dn_stat.st_mode & (S_IFMT | S_ISPARE)); np->dn_stat.st_mode = mode; diff --git a/libdiskfs/file-chown.c b/libdiskfs/file-chown.c index 58ea51cf..c0f685c7 100644 --- a/libdiskfs/file-chown.c +++ b/libdiskfs/file-chown.c @@ -1,5 +1,5 @@ /* libdiskfs implementetation of fs.defs: file_chown - Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation + Copyright (C) 1992, 1993, 1994 Free Software Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -24,24 +24,15 @@ diskfs_S_file_chown (struct protid *cred, uid_t uid, gid_t gid) { - struct userid *id; - CHANGE_NODE_FIELD (cred, ({ err = diskfs_isowner (np, cred); - if (!err) - { - assert (cred->id); - for (id = cred->id; id && !err; id = id->next) - { - if (diskfs_idhasuid (0, id)) - continue; - if (!diskfs_idhasuid (uid, cred) - || !diskfs_idhasgid (gid, cred)) - err = EPERM; - } - } - if (!err) + if (err + || ((!diskfs_isuid (uid, cred) + || !diskfs_groupmember (gid, cred)) + && !diskfs_isuid (0, cred))) + err = EPERM; + else { np->dn_stat.st_uid = uid; np->dn_stat.st_gid = gid; diff --git a/libdiskfs/file-getcontrol.c b/libdiskfs/file-getcontrol.c index 1d7dfa9b..4ea2ae8e 100644 --- a/libdiskfs/file-getcontrol.c +++ b/libdiskfs/file-getcontrol.c @@ -1,5 +1,5 @@ /* libdiskfs implementation of fs.defs:file_getcontrol.c - Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation + Copyright (C) 1992, 1993, 1994 Free Software Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -24,17 +24,14 @@ diskfs_S_file_getcontrol (struct protid *cred, mach_port_t *control, mach_msg_type_name_t *controltype) { - int error = 0; - struct userid *id; + int error = 0;; if (!cred) return EOPNOTSUPP; - assert (cred->id); - for (id = cred->id; id && !error; id = id->next) - if (!diskfs_idhasuid (0, id)) - error = EPERM; - if (!error) + if (!diskfs_isuid (0, cred)) + error = EPERM; + else { spin_lock (&_diskfs_control_lock); _diskfs_ncontrol_ports++; |