Separate temporary directories for different users
on UNIX systems so each user has it's own temp directory under
`/tmp`. Otherwise users may compete over ovnership of some files
in case names are hardcoded (bad, but man, there's such code in
2016)
--- a/Filename.st Thu Oct 27 19:49:24 2016 +0000
+++ b/Filename.st Thu Oct 27 23:11:43 2016 +0000
@@ -827,22 +827,22 @@
otherwise, '/tmp' is used. (at least on unix ...).
Notice: do not hardcode '/tmp' into your programs - things may be
- different on other operating systems. Also, the user may want to set the
- TMPDIR environment variable to have her temp files somewhere else."
+ different on other operating systems. Also, the user may want to set the
+ TMPDIR environment variable to have her temp files somewhere else."
|tempDir|
TempDirectory isNil ifTrue:[
- tempDir := self named:(self defaultTempDirectoryName pathName).
- tempDir exists ifFalse:[
- tempDir
- makeDirectory;
- addAccessRights:#(readUser readGroup readOthers
- writeUser writeGroup writeOthers
- executeUser executeGroup executeOthers
- removeOnlyByOwner).
- ].
- TempDirectory := DefaultTempDirectory := tempDir construct:'stx_tmp'.
+ tempDir := self named:(self defaultTempDirectoryName pathName).
+ tempDir exists ifFalse:[
+ tempDir
+ makeDirectory;
+ addAccessRights:#(readUser readGroup readOthers
+ writeUser writeGroup writeOthers
+ executeUser executeGroup executeOthers
+ removeOnlyByOwner).
+ ].
+ TempDirectory := DefaultTempDirectory := tempDir construct:('stx_tmp_' , OperatingSystem getLoginName)
].
"Make sure, that the TempDirectory exists - it might have been removed
@@ -850,12 +850,12 @@
Since it is shared between users, it must be accessible by all users."
TempDirectory exists ifFalse:[
- TempDirectory
- makeDirectory;
- addAccessRights:#(readUser readGroup readOthers
- writeUser writeGroup writeOthers
- executeUser executeGroup executeOthers
- removeOnlyByOwner).
+ TempDirectory
+ makeDirectory;
+ addAccessRights:#(readUser readGroup readOthers
+ writeUser writeGroup writeOthers
+ executeUser executeGroup executeOthers
+ removeOnlyByOwner).
].
^ TempDirectory
@@ -870,6 +870,7 @@
"Created: / 07-03-1996 / 14:51:18 / cg"
"Modified: / 07-10-2011 / 18:39:25 / cg"
+ "Modified: / 27-10-2016 / 23:06:51 / jv"
!
tempDirectory:aFilename
@@ -6577,6 +6578,11 @@
version_CVS
^ '$Header$'
+!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
! !
--- a/UnixFilename.st Thu Oct 27 19:49:24 2016 +0000
+++ b/UnixFilename.st Thu Oct 27 23:11:43 2016 +0000
@@ -61,8 +61,7 @@
tempDirString notNil ifTrue:[
tempDir := self named:tempDirString.
(tempDir exists and:[ tempDir isWritable ]) ifTrue:[
- ('Filename [info]: using tmp folder "%1" as specified by environment: "%2"'
- bindWith:tempDir pathName with:envVar) infoPrintCR.
+ Logger info: 'using tmp folder "%1" as specified by environment: "%2"' with:tempDir pathName with:envVar.
^ tempDir asFilename.
].
].
@@ -77,6 +76,8 @@
Filename defaultTempDirectoryName exists
Filename defaultTempDirectoryName isWritable
"
+
+ "Modified: / 27-10-2016 / 23:09:08 / jv"
! !
!UnixFilename class methodsFor:'queries'!