Index: openacs-4/packages/acs-tcl/acs-tcl.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/acs-tcl.info,v
diff -u -r1.95.2.50 -r1.95.2.51
--- openacs-4/packages/acs-tcl/acs-tcl.info 25 Aug 2022 11:25:10 -0000 1.95.2.50
+++ openacs-4/packages/acs-tcl/acs-tcl.info 25 Aug 2022 12:37:13 -0000 1.95.2.51
@@ -9,7 +9,7 @@
f
t
-
+
OpenACS
The Kernel Tcl API library.
2021-09-15
@@ -18,7 +18,7 @@
GPL version 2
3
-
+
Index: openacs-4/packages/acs-tcl/tcl/security-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/security-procs.tcl,v
diff -u -r1.126.2.71 -r1.126.2.72
--- openacs-4/packages/acs-tcl/tcl/security-procs.tcl 25 Aug 2022 11:25:10 -0000 1.126.2.71
+++ openacs-4/packages/acs-tcl/tcl/security-procs.tcl 25 Aug 2022 12:37:13 -0000 1.126.2.72
@@ -1172,7 +1172,10 @@
host_node_id $host_node_id]
}
-ad_proc security::safe_tmpfile_p {tmpfile} {
+ad_proc security::safe_tmpfile_p {
+ -must_exist:boolean
+ tmpfile
+} {
Checks that a file is a safe tmpfile, that is, it belongs to the
configured tmpdir.
@@ -1182,6 +1185,7 @@
- file must be readable and writeable by the current system user
@param tmpfile absolute path to a possibly existing tmpfile
+ @param must_exist make sure the file exists
@return boolean
} {
@@ -1194,9 +1198,10 @@
if {![ad_file exists $tmpfile]} {
#
- # File does not exist yet: safe
+ # File does not exist yet: safe, unless we demand for the file
+ # to exist.
#
- return true
+ return [expr {!$must_exist_p}]
}
if {![ad_file owned $tmpfile]} {
Index: openacs-4/packages/acs-tcl/tcl/test/security-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/security-procs.tcl,v
diff -u -r1.1.2.5 -r1.1.2.6
--- openacs-4/packages/acs-tcl/tcl/test/security-procs.tcl 25 Aug 2022 11:25:11 -0000 1.1.2.5
+++ openacs-4/packages/acs-tcl/tcl/test/security-procs.tcl 25 Aug 2022 12:37:14 -0000 1.1.2.6
@@ -108,11 +108,16 @@
aa_section {Path to a tmpfile that does not exist yet}
aa_true "A temporary filename is safe" [security::safe_tmpfile_p $tmpfile]
+ set tmpfile [ad_tmpnam]
+ aa_section {Path to a tmpfile that we demand to exist}
+ aa_false "A temporary filename is not safe if the file des not exist" \
+ [security::safe_tmpfile_p -must_exist $tmpfile]
+
aa_section {Path to an existing tmpfile}
set wfd [open $tmpfile w]
puts $wfd 1234
close $wfd
- aa_true "An existing tmpfile is safe" [security::safe_tmpfile_p $tmpfile]
+ aa_true "An existing tmpfile is safe" [security::safe_tmpfile_p -must_exist $tmpfile]
file delete -- $tmpfile
aa_section {Path to a tmpfile in a folder of the tmpdir}