summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1995-03-07 23:01:01 +0000
committerMichael I. Bushnell <mib@gnu.org>1995-03-07 23:01:01 +0000
commit3adf2f665df28e7a150a64aa3bf1f818f307df23 (patch)
tree6c92bfeea2a330c690fd878c9857289fbf6bf048
parented22a9fde99d5c37358fc449a3a1c58efa9907f8 (diff)
(diskfs_S_file_chown): Perform the permission check for each ID in the
chain.
-rw-r--r--libdiskfs/file-chown.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/libdiskfs/file-chown.c b/libdiskfs/file-chown.c
index c0f685c7..58ea51cf 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 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
@@ -24,15 +24,24 @@ 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
- || ((!diskfs_isuid (uid, cred)
- || !diskfs_groupmember (gid, cred))
- && !diskfs_isuid (0, cred)))
- err = EPERM;
- else
+ 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)
{
np->dn_stat.st_uid = uid;
np->dn_stat.st_gid = gid;