diff options
author | Michael I. Bushnell <mib@gnu.org> | 1995-03-07 23:01:34 +0000 |
---|---|---|
committer | Michael I. Bushnell <mib@gnu.org> | 1995-03-07 23:01:34 +0000 |
commit | 5d3a2951dd035d3b0fde7affbf8438354f7227c6 (patch) | |
tree | ecf6b888dcebf25ebf9ddff92e136015386749ab /libdiskfs | |
parent | 3adf2f665df28e7a150a64aa3bf1f818f307df23 (diff) |
(diskfs_S_file_chmod): Perform the permission check for each ID in the
chain.
Diffstat (limited to 'libdiskfs')
-rw-r--r-- | libdiskfs/file-chmod.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/libdiskfs/file-chmod.c b/libdiskfs/file-chmod.c index c5228d13..6e92822c 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 Free Software Foundation + Copyright (C) 1992, 1993, 1994, 1995 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,21 +22,30 @@ 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))) { - if (!diskfs_isuid (0, 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 (!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; + 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; + } } mode |= (np->dn_stat.st_mode & (S_IFMT | S_ISPARE)); np->dn_stat.st_mode = mode; |