summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorJennifer Averett <Jennifer.Averett@OARcorp.com>2003-11-25 17:26:45 +0000
committerJennifer Averett <Jennifer.Averett@OARcorp.com>2003-11-25 17:26:45 +0000
commitde691e68f72c525b1204e8e1a6ea24261ea6d124 (patch)
treedbe503fb3816bfd59d30ccb531435beeb3ff3101 /cpukit
parent2003-11-25 Joel Sherrill <joel@OARcorp.com> (diff)
downloadrtems-de691e68f72c525b1204e8e1a6ea24261ea6d124.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')
-rw-r--r--cpukit/libcsupport/ChangeLog6
-rw-r--r--cpukit/libcsupport/include/rtems/libio_.h5
-rw-r--r--cpukit/libcsupport/src/eval.c25
-rw-r--r--cpukit/libcsupport/src/rmdir.c6
-rw-r--r--cpukit/libcsupport/src/unlink.c6
5 files changed, 48 insertions, 0 deletions
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 <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-11-22 Ralf Corsepius <corsepiu@faw.uni-ulm.de>
* 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 );