Filesystem: Remove superfluous permission checks

The permission is check by the upper layer.
This commit is contained in:
Sebastian Huber
2015-12-22 07:56:57 +01:00
parent 173c44eba4
commit f9f7321e0a
4 changed files with 21 additions and 37 deletions

View File

@@ -30,24 +30,10 @@ int IMFS_chown(
gid_t group
)
{
IMFS_jnode_t *jnode;
#if defined(RTEMS_POSIX_API)
uid_t st_uid;
#endif
IMFS_jnode_t *jnode;
jnode = (IMFS_jnode_t *) loc->node_access;
/*
* Verify I am the owner of the node or the super user.
*/
#if defined(RTEMS_POSIX_API)
st_uid = geteuid();
if ( ( st_uid != jnode->st_uid ) && ( st_uid != 0 ) )
rtems_set_errno_and_return_minus_one( EPERM );
#endif
jnode->st_uid = owner;
jnode->st_gid = group;

View File

@@ -274,9 +274,6 @@ rtems_rfs_rtems_chown (const rtems_filesystem_location_info_t *pathloc,
rtems_rfs_file_system* fs = rtems_rfs_rtems_pathloc_dev (pathloc);
rtems_rfs_ino ino = rtems_rfs_rtems_get_pathloc_ino (pathloc);
rtems_rfs_inode_handle inode;
#if defined (RTEMS_POSIX_API)
uid_t uid;
#endif
int rc;
if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_CHOWN))
@@ -289,20 +286,6 @@ rtems_rfs_rtems_chown (const rtems_filesystem_location_info_t *pathloc,
return rtems_rfs_rtems_error ("chown: opening inode", rc);
}
/*
* Verify I am the owner of the node or the super user.
*/
#if defined (RTEMS_POSIX_API)
uid = geteuid();
if ((uid != rtems_rfs_inode_get_uid (&inode)) && (uid != 0))
{
rtems_rfs_inode_close (fs, &inode);
return rtems_rfs_rtems_error ("chown: not able", EPERM);
}
#endif
rtems_rfs_inode_set_uid_gid (&inode, owner, group);
rc = rtems_rfs_inode_close (fs, &inode);

View File

@@ -441,6 +441,26 @@ static void test_premission02(void )
rtems_test_assert(user_id==statbuf.st_uid);
rtems_test_assert(group_id==statbuf.st_gid);
status = seteuid(user_id - 1);
rtems_test_assert(status == 0);
errno = 0;
status = chown(file01, user_id, group_id);
rtems_test_assert(status == -1);
rtems_test_assert(errno == EPERM);
status = seteuid(user_id);
rtems_test_assert(status == 0);
status = chown(file01, user_id, group_id);
rtems_test_assert(status == 0);
status = seteuid(0);
rtems_test_assert(status == 0);
status = chown(file01, user_id, group_id);
rtems_test_assert(status == 0);
status=mkdir(directory01,mode);
rtems_test_assert(status==0);
status=stat(directory01,&statbuf);

View File

@@ -160,7 +160,6 @@ rtems_task Init(
status = seteuid( 10 );
rtems_test_assert( status == 0 );
#if defined(RTEMS_POSIX_API)
puts( "Attempt chmod on /node -- expect EPERM" );
status = chmod( "/node", S_IRUSR );
rtems_test_assert( status == -1 );
@@ -170,10 +169,6 @@ rtems_task Init(
status = chown( "/node", 10, 10 );
rtems_test_assert( status == -1 );
rtems_test_assert( errno == EPERM );
#else
puts( "Attempt chmod on /node -- EPERM only when POSIX enabled" );
puts( "Attempt chown on /node -- EPERM only when POSIX enabled" );
#endif
puts( "Changing euid back to 0 [root]" );
status = seteuid( 0 );