patch-2.2.6 linux/fs/open.c

Next file: linux/fs/proc/link.c
Previous file: linux/fs/ntfs/support.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.5/linux/fs/open.c linux/fs/open.c
@@ -69,6 +69,10 @@
 	int error;
 	struct iattr newattrs;
 
+	/* Not pretty: "inode->i_size" shouldn't really be "off_t". But it is. */
+	if ((off_t) length < 0)
+		return -EINVAL;
+
 	down(&inode->i_sem);
 	newattrs.ia_size = length;
 	newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
@@ -294,11 +298,16 @@
 	/* Clear the capabilities if we switch to a non-root user */
 	if (current->uid)
 		cap_clear(current->cap_effective);
-
+	else
+		current->cap_effective = current->cap_permitted;
+		
 	dentry = namei(filename);
 	res = PTR_ERR(dentry);
 	if (!IS_ERR(dentry)) {
 		res = permission(dentry->d_inode, mode);
+		/* SuS v2 requires we report a read only fs too */
+		if(!res && (mode & S_IWOTH) && IS_RDONLY(dentry->d_inode))
+			res = -EROFS;
 		dput(dentry);
 	}
 

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)