Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

Ticket #519: unlinkpatch.txt

File unlinkpatch.txt, 3.6 KB (added by sa, on 12/03/06 at 13:31:12)

unlinkpatch.txt

Line 
1? changes-XXX
2? unlinkpatch.txt
3Index: ChangeLog
4===================================================================
5RCS file: /usr1/CVS/rtems/cpukit/libcsupport/ChangeLog,v
6retrieving revision 1.74
7diff -c -r1.74 ChangeLog
8*** ChangeLog   22 Nov 2003 11:32:46 -0000      1.74
9--- ChangeLog   25 Nov 2003 17:17:56 -0000
10***************
11*** 1,3 ****
12--- 1,9 ----
13+ 2003-11-25    Jennifer Averett <jennifer@OARcorp.com>
14+
15+       PR 519/filesystem
16+       * include/rtems/libio_.h, src/eval.c, src/rmdir.c, src/unlink.c: Check
17+       write permissions in parent directory for file or directory delete
18+
19  2003-11-22    Ralf Corsepius <corsepiu@faw.uni-ulm.de>
20
21        * include/rtems/cdefs.h: Use _RTEMS_CDEFS_H guards.
22Index: include/rtems/libio_.h
23===================================================================
24RCS file: /usr1/CVS/rtems/cpukit/libcsupport/include/rtems/libio_.h,v
25retrieving revision 1.20
26diff -c -r1.20 libio_.h
27*** include/rtems/libio_.h      4 Sep 2003 18:54:13 -0000       1.20
28--- include/rtems/libio_.h      25 Nov 2003 17:17:56 -0000
29***************
30*** 227,232 ****
31--- 227,237 ----
32    int                                follow_link
33  );
34
35+ int rtems_filesystem_evaluate_parent(
36+   int                                flags,
37+   rtems_filesystem_location_info_t  *pathloc
38+ );
39+
40  void rtems_filesystem_initialize();
41
42  int init_fs_mount_table();
43Index: src/eval.c
44===================================================================
45RCS file: /usr1/CVS/rtems/cpukit/libcsupport/src/eval.c,v
46retrieving revision 1.10
47diff -c -r1.10 eval.c
48*** src/eval.c  4 Sep 2003 18:54:13 -0000       1.10
49--- src/eval.c  25 Nov 2003 17:17:56 -0000
50***************
51*** 97,99 ****
52--- 97,124 ----
53    return result;
54  }
55
56+
57+ int rtems_filesystem_evaluate_parent(
58+   int                                flags,
59+   rtems_filesystem_location_info_t  *pathloc
60+ )
61+ {
62+   rtems_filesystem_location_info_t  parent;
63+   int                               result;
64+
65+   if ( !pathloc )
66+     rtems_set_errno_and_return_minus_one( EIO );       /* should never happen */
67+
68+   if ( !pathloc->ops->evalpath_h )
69+     rtems_set_errno_and_return_minus_one( ENOTSUP );
70+
71+   parent = *pathloc;
72+   result = (*pathloc->ops->evalpath_h)( "..", flags, &parent );
73+   if (result != 0){
74+     return -1;
75+   }
76+   rtems_filesystem_freenode( &parent );
77+
78+   return result;
79+ }
80+
81Index: src/rmdir.c
82===================================================================
83RCS file: /usr1/CVS/rtems/cpukit/libcsupport/src/rmdir.c,v
84retrieving revision 1.10
85diff -c -r1.10 rmdir.c
86*** src/rmdir.c 4 Sep 2003 18:54:13 -0000       1.10
87--- src/rmdir.c 25 Nov 2003 17:17:56 -0000
88***************
89*** 39,44 ****
90--- 39,50 ----
91    if ( result != 0 )
92       return -1;
93
94+   result = rtems_filesystem_evaluate_parent(RTEMS_LIBIO_PERMS_WRITE, &loc );
95+   if (result != 0){
96+     rtems_filesystem_freenode( &loc );
97+     return -1;
98+   }
99+
100    /*
101     * Verify you can remove this node as a directory.
102     */
103Index: src/unlink.c
104===================================================================
105RCS file: /usr1/CVS/rtems/cpukit/libcsupport/src/unlink.c,v
106retrieving revision 1.10
107diff -c -r1.10 unlink.c
108*** src/unlink.c        4 Sep 2003 18:54:13 -0000       1.10
109--- src/unlink.c        25 Nov 2003 17:17:56 -0000
110***************
111*** 35,40 ****
112--- 35,46 ----
113    if ( result != 0 )
114       return -1;
115
116+   result = rtems_filesystem_evaluate_parent(RTEMS_LIBIO_PERMS_WRITE, &loc );
117+   if (result != 0){
118+     rtems_filesystem_freenode( &loc );
119+     return -1;
120+   }
121+
122    if ( !loc.ops->node_type_h ) {
123      rtems_filesystem_freenode( &loc );
124      rtems_set_errno_and_return_minus_one( ENOTSUP );