From c12ff89783ecec965ea01abc7fb097abdec25d6d Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Thu, 14 Dec 1995 20:51:17 +0000 Subject: (diskfs_checkdirmod): Correctly return error code for failure, not 1. --- libdiskfs/diskfs.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h index 2b874178..3d5650aa 100644 --- a/libdiskfs/diskfs.h +++ b/libdiskfs/diskfs.h @@ -777,12 +777,20 @@ extern inline error_t diskfs_checkdirmod (struct node *dp, struct node *np, struct protid *cred) { + error_t err; + /* The user must be able to write the directory, but if the directory is sticky, then the user must also be either the owner of the directory or the file. */ - return (diskfs_access (dp, S_IWRITE, cred) - && (!(dp->dn_stat.st_mode & S_ISVTX) || !np || diskfs_isuid (0,cred) - || diskfs_isowner (dp, cred) || diskfs_isowner (np, cred))); + err = diskfs_access (dp, S_IWRITE, cred); + if (err) + return err; + + if ((dp->dn_stat.st_mode & S_ISVTX) && np && !diskfs_isuid (0, cred) + && !diskfs_isowner (dp, cred) && !diskfs_isowner (np, cred)) + return EACCES; + + return 0; } /* Reading and writing of files. this is called by other filesystem -- cgit v1.2.3