diff options
author | Jennifer Averett <Jennifer.Averett@OARcorp.com> | 2003-11-25 17:27:55 +0000 |
---|---|---|
committer | Jennifer Averett <Jennifer.Averett@OARcorp.com> | 2003-11-25 17:27:55 +0000 |
commit | 86042ae953485474e2bcdbf480658f74b3d9fe66 (patch) | |
tree | 4003abb9994c99b52028420fe61a8c6de6368f3b /cpukit/libcsupport | |
parent | 2003-11-25 Joel Sherrill <joel@OARcorp.com> (diff) | |
download | rtems-86042ae953485474e2bcdbf480658f74b3d9fe66.tar.bz2 |
2003-11-25 Jennifer Averett <jennifer@OARcorp.com>
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
Diffstat (limited to 'cpukit/libcsupport')
-rw-r--r-- | cpukit/libcsupport/ChangeLog | 7 | ||||
-rw-r--r-- | cpukit/libcsupport/include/rtems/libio_.h | 5 | ||||
-rw-r--r-- | cpukit/libcsupport/src/eval.c | 24 | ||||
-rw-r--r-- | cpukit/libcsupport/src/rmdir.c | 6 | ||||
-rw-r--r-- | cpukit/libcsupport/src/unlink.c | 6 |
5 files changed, 48 insertions, 0 deletions
diff --git a/cpukit/libcsupport/ChangeLog b/cpukit/libcsupport/ChangeLog index 5197a83b9d..ee2318652e 100644 --- a/cpukit/libcsupport/ChangeLog +++ b/cpukit/libcsupport/ChangeLog @@ -1,3 +1,10 @@ +2003-11-25 Jennifer Averett <jennifer@OARcorp.com> + + 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-10-22 Joel Sherrill <joel@OARcorp.com> PR 511/filesystem 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..ec6cf9d9b4 100644 --- a/cpukit/libcsupport/src/eval.c +++ b/cpukit/libcsupport/src/eval.c @@ -97,3 +97,27 @@ 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 ); |