From de691e68f72c525b1204e8e1a6ea24261ea6d124 Mon Sep 17 00:00:00 2001 From: Jennifer Averett Date: Tue, 25 Nov 2003 17:26:45 +0000 Subject: 2003-11-25 Jennifer Averett PR 519/filesystem * include/rtems/libio_.h, src/eval.c, src/rmdir.c, src/unlink.c: Check write permissions in parent directory for file or directory delete --- cpukit/libcsupport/ChangeLog | 6 ++++++ cpukit/libcsupport/include/rtems/libio_.h | 5 +++++ cpukit/libcsupport/src/eval.c | 25 +++++++++++++++++++++++++ cpukit/libcsupport/src/rmdir.c | 6 ++++++ cpukit/libcsupport/src/unlink.c | 6 ++++++ 5 files changed, 48 insertions(+) (limited to 'cpukit') diff --git a/cpukit/libcsupport/ChangeLog b/cpukit/libcsupport/ChangeLog index 737f898507..24841054c4 100644 --- a/cpukit/libcsupport/ChangeLog +++ b/cpukit/libcsupport/ChangeLog @@ -1,3 +1,9 @@ +2003-11-25 Jennifer Averett + + PR 519/filesystem + * include/rtems/libio_.h, src/eval.c, src/rmdir.c, src/unlink.c: Check + write permissions in parent directory for file or directory delete + 2003-11-22 Ralf Corsepius * include/rtems/cdefs.h: Use _RTEMS_CDEFS_H guards. diff --git a/cpukit/libcsupport/include/rtems/libio_.h b/cpukit/libcsupport/include/rtems/libio_.h index 34fd0e9ee0..0d0e5ffd9b 100644 --- a/cpukit/libcsupport/include/rtems/libio_.h +++ b/cpukit/libcsupport/include/rtems/libio_.h @@ -227,6 +227,11 @@ int rtems_filesystem_evaluate_path( int follow_link ); +int rtems_filesystem_evaluate_parent( + int flags, + rtems_filesystem_location_info_t *pathloc +); + void rtems_filesystem_initialize(); int init_fs_mount_table(); diff --git a/cpukit/libcsupport/src/eval.c b/cpukit/libcsupport/src/eval.c index 1e970d47ca..4d57219e39 100644 --- a/cpukit/libcsupport/src/eval.c +++ b/cpukit/libcsupport/src/eval.c @@ -97,3 +97,28 @@ int rtems_filesystem_evaluate_path( return result; } + +int rtems_filesystem_evaluate_parent( + int flags, + rtems_filesystem_location_info_t *pathloc +) +{ + rtems_filesystem_location_info_t parent; + int result; + + if ( !pathloc ) + rtems_set_errno_and_return_minus_one( EIO ); /* should never happen */ + + if ( !pathloc->ops->evalpath_h ) + rtems_set_errno_and_return_minus_one( ENOTSUP ); + + parent = *pathloc; + result = (*pathloc->ops->evalpath_h)( "..", flags, &parent ); + if (result != 0){ + return -1; + } + rtems_filesystem_freenode( &parent ); + + return result; +} + diff --git a/cpukit/libcsupport/src/rmdir.c b/cpukit/libcsupport/src/rmdir.c index 52308f7b29..e0ca5956be 100644 --- a/cpukit/libcsupport/src/rmdir.c +++ b/cpukit/libcsupport/src/rmdir.c @@ -39,6 +39,12 @@ int rmdir( if ( result != 0 ) return -1; + result = rtems_filesystem_evaluate_parent(RTEMS_LIBIO_PERMS_WRITE, &loc ); + if (result != 0){ + rtems_filesystem_freenode( &loc ); + return -1; + } + /* * Verify you can remove this node as a directory. */ diff --git a/cpukit/libcsupport/src/unlink.c b/cpukit/libcsupport/src/unlink.c index ce9ce74295..95f2b064a1 100644 --- a/cpukit/libcsupport/src/unlink.c +++ b/cpukit/libcsupport/src/unlink.c @@ -35,6 +35,12 @@ int unlink( if ( result != 0 ) return -1; + result = rtems_filesystem_evaluate_parent(RTEMS_LIBIO_PERMS_WRITE, &loc ); + if (result != 0){ + rtems_filesystem_freenode( &loc ); + return -1; + } + if ( !loc.ops->node_type_h ) { rtems_filesystem_freenode( &loc ); rtems_set_errno_and_return_minus_one( ENOTSUP ); -- cgit v1.2.3