Herbert -
Here is another version of this patch. This is a patch against the
2.4.25-vs1.26 source tree (I know it's not the latest, but the patch is
so small, it will probably work on 1.27 just as well).
This one only disallows flag modification of immutable files only if
IMMUTABLE_LINK_FL is on, as you suggested.
I've got ext2, ext3 and reiserfs patched, my limited tests show it works
as it should.
The ext3 patch also reorders a couple of lines relating to journaling flag
which makes for more readable code IMHO.
Grisha
On Sat, 15 May 2004, Herbert Poetzl wrote:
> hum, interesting approach, but maybe it would be
> better to do the following:
>
> - check for IMMUTABLE + IUNLINK (unified file)
> and disallow changes on such files unless
> - CAP_IMMUTABLE is given
>
> this would keep existing behaviour for host and
> vserver without issues from unified files ...
>
--- linux-2.4.25-vs1.26/fs/ext2/ioctl.c 2004-05-17 11:15:14.000000000 -0400
+++ linux-2.4.25-vs1.26-attr/fs/ext2/ioctl.c 2004-05-17 10:33:23.000000000 -0400
@@ -38,6 +38,10 @@ int ext2_ioctl (struct inode * inode, st
oldflags = inode->u.ext2_i.i_flags;
+ if (oldflags & EXT2_IMMUTABLE_LINK_FL)
+ /* Immutable files cannot be changed */
+ if (oldflags & flags & EXT2_IMMUTABLE_FILE_FL)
+ return -EPERM;
/*
* The IMMUTABLE_* and APPEND_ONLY flags can only be changed
* by the relevant capability.
--- linux-2.4.25-vs1.26/fs/ext3/ioctl.c 2004-05-17 11:15:14.000000000 -0400
+++ linux-2.4.25-vs1.26-attr/fs/ext3/ioctl.c 2004-05-17 10:39:41.000000000 -0400
@@ -44,8 +44,10 @@ int ext3_ioctl (struct inode * inode, st
oldflags = inode->u.ext3_i.i_flags;
- /* The JOURNAL_DATA flag is modifiable only by root */
- jflag = flags & EXT3_JOURNAL_DATA_FL;
+ if (oldflags & EXT3_IMMUTABLE_LINK_FL)
+ /* Immutable files cannot be changed */
+ if (oldflags & flags & EXT3_IMMUTABLE_FILE_FL)
+ return -EPERM;
/*
* The IMMUTABLE_* and APPEND_ONLY flags can only be changed
@@ -58,6 +60,9 @@ int ext3_ioctl (struct inode * inode, st
return -EPERM;
}
+ /* The JOURNAL_DATA flag is modifiable only by root */
+ jflag = flags & EXT3_JOURNAL_DATA_FL;
+
/*
* The JOURNAL_DATA flag can only be changed by
* the relevant capability.
--- linux-2.4.25-vs1.26/fs/reiserfs/ioctl.c 2004-05-17 11:15:14.000000000 -0400
+++ linux-2.4.25-vs1.26-attr/fs/reiserfs/ioctl.c 2004-05-17 10:39:37.000000000
-0400
@@ -51,6 +51,11 @@ int reiserfs_ioctl (struct inode * inode
if (get_user(flags, (int *) arg))
return -EFAULT;
+ if ( inode->u.reiserfs_i.i_attrs & REISERFS_IMMUTABLE_LINK_FL )
+ /* Immutable files cannot be changed */
+ if ( flags & inode->u.reiserfs_i.i_attrs &
REISERFS_IMMUTABLE_FILE_FL )
+ return -EPERM;
+
if ( ( ( flags ^ inode->u.reiserfs_i.i_attrs) &
( REISERFS_IMMUTABLE_FILE_FL | REISERFS_IMMUTABLE_LINK_FL |
REISERFS_APPEND_FL )) &&
!capable( CAP_LINUX_IMMUTABLE ) )
_______________________________________________
Vserver mailing list
[EMAIL PROTECTED]
http://list.linux-vserver.org/mailman/listinfo/vserver