View Single Post
Old 06-05-2002, 09:12 AM  
salsbury
Confirmed User
 
Join Date: Feb 2002
Location: Seattle
Posts: 1,070
careful with the cron solution, if it's the one i've seen before, it's wiped out many a .htpasswd file.

what a lot of programs fail to do is test to see if what they think they wrote out to a file actually made it there. this is unbelievably common. say for example your drive is somehow full (hey, shit happens). your script opens up the merged .htpasswd file and truncates it to 0 bytes, as is normal. then it starts trying to write to it. it doesn't check if the writes succeed. it doesn't matter though, since the file is already truncated, the data is lost. i've seen this kind of code in ccbill's scripts and the pwmerge scripts out there, amongst others.

what scripts need to do is write out to a temporary file, keeping track of how many bytes it thinks its writing out. then, compare the size of the temporary file to the number of bytes. if it's right, rename the temporary file to the real file (ie mv .htpasswd.tmp .htpasswd).

if you need help with this hit me up via <a href="mailto:[email protected]">email</a>.
__________________

Last edited by salsbury; 06-05-2002 at 09:13 AM..
salsbury is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote