From 3adf2f665df28e7a150a64aa3bf1f818f307df23 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 7 Mar 1995 23:01:01 +0000 Subject: (diskfs_S_file_chown): Perform the permission check for each ID in the chain. --- libdiskfs/file-chown.c | 23 ++++++++++++++++------- 1 file 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; -- cgit v1.2.3