diff options
Diffstat (limited to 'libdiskfs/file-chown.c')
-rw-r--r-- | libdiskfs/file-chown.c | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/libdiskfs/file-chown.c b/libdiskfs/file-chown.c index a0c4f225..ecb851f2 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, 1996 Free Software Foundation + Copyright (C) 1992, 1993, 1994, 1996, 1999 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,40 @@ diskfs_S_file_chown (struct protid *cred, uid_t uid, gid_t gid) { + if (uid == (uid_t) -1 && gid == (gid_t) -1) /* No change requested. */ + return 0; + CHANGE_NODE_FIELD (cred, ({ - err = diskfs_isowner (np, cred); + err = fshelp_isowner (&np->dn_stat, cred->user); if (err - || ((!diskfs_isuid (uid, cred) - || !diskfs_groupmember (gid, cred)) - && !diskfs_isuid (0, cred))) + || (((uid != (uid_t) -1 + && !idvec_contains (cred->user->uids, uid)) + || (gid != (gid_t) -1 + && !idvec_contains (cred->user->gids, gid))) + && !idvec_contains (cred->user->uids, 0))) err = EPERM; - else + else { - err = diskfs_validate_owner_change (np, uid); - if (!err) + if (uid != (uid_t) -1) + err = diskfs_validate_owner_change (np, uid); + if (!err && gid != (gid_t) -1) err = diskfs_validate_group_change (np, gid); if (!err) { - np->dn_stat.st_uid = uid; - np->dn_stat.st_gid = gid; + if (uid != (uid_t) -1) + { + np->dn_stat.st_uid = uid; + if (np->author_tracks_uid) + np->dn_stat.st_author = uid; + } + if (gid != (gid_t) -1) + np->dn_stat.st_gid = gid; np->dn_set_ctime = 1; + if (np->filemod_reqs) + diskfs_notice_filechange(np, + FILE_CHANGED_META, + 0, 0); } } })); |