Re: [Compilercache-general] oh boy...
Brought to you by:
erikyyy
From: Mike A. H. <mh...@re...> - 2001-11-01 08:36:24
|
On Wed, 31 Oct 2001, Erik Thiele wrote: >i got a problem that drives me nuts. > >it's all about temporary files creation in bash scripts. >compilercache needs to do two things. > >1) create a temporary file that is maximally fast > >2) create a temporary file in the cache directory that can be renamed >to the real entry by a single atomic "rename" system call. (i.e. mv >needn't copy) this is important because otherwise other users of your >cache will get half-ready (i.e. wrong) .o files. > >debian has the nicest fix for this task. it's the "tempfile" >program. unfortunately it is not installed in other distributions like >redhat, or even other unixes. I do not know if debian has mktemp or not, but the standard way in Red Hat Linux and most other RPM based distro's is to use mktemp. TEMPFILE=$(mktemp "/tmp/somefile.XXXXXX") >in compilercache-1.0.9 i was using > >FASTTMPFILE=/tmp/compilercache_$$ > >which is a VERY severe security hole since other users could install >link files there and manipulate the temporary files of other users... Correct, and we are constantly tracking down these horrible security problems too. ;o( >there exists a "mktemp" program which is not portable to HP-UX at least. Yep, that is what we use. >ok. i NEED the functionality (especially the --directory parameter) of >debian "tempfile". mktemp -d >either it is there or not. if not, i must include a tempfile >program in the compilercache distribution and tell the user he >must install it. but where to ??? /bin is not an option for >non-root users. so the user must put it somewhere in his path >and set the PATH variable accordingly in the .compilercacherc >config file. but where will he put it ? in the compilercache >bin dir? mktemp sources are very very small, I'd just include it in its entirety, and by default install it into the compilercache dir. >and who writes the tempfile program? maybe a perl script? i wrote one, >(without the --directory functionality) but it is very slow: > >use File::Temp qw/tempfile/; >($fh,$filename)=tempfile(); >print $filename."\n"; > >and by the way.... the current 1.0.10 version fixes this problem in a >somehow funny way. you just set your own private temporary directory >and all problems are gone away. With mktemp being open source and written in C, it would be a better choice. Any perl script or other script is going to defeat a lot of the purpose of compilercache, which is speed. Hope this helps. ---------------------------------------------------------------------- Mike A. Harris Shipping/mailing address: OS Systems Engineer 190 Pittsburgh Ave., Sault Ste. Marie, XFree86 maintainer Ontario, Canada, P6C 5B3 Red Hat Inc. Phone: (705)949-2136 http://www.redhat.com ftp://people.redhat.com/mharris Red Hat XFree86 mailing list: xfr...@re... General open IRC discussion: #xfree86 on irc.openprojects.org ---------------------------------------------------------------------- |