in reply to writting new files in perl

I would think there would be a FAQ on how to give your CGIs access to write local files while minimizing security risks. But The Idiot's CGI Guide didn't mention this and pointed to The WWW Security FAQ, which also didn't mention it (that I could see).

So here are some things I consider important:

If, like many of us, asking questions of your web server administrator is difficult, you can figure out a lot about your server configuration with some experiments. Let's assume that your user name is "joe", the root of the web tree or subtree that you have control over is "~/webroot", it is served as "http:://www.x.com/~joe", your CGIs go in "~/webroot/cgi-bin", and they are served as "http://www.x.com/cgi-bin/cgiwrap/joe/script.pl".

cd ~/webroot chmod u=rwx,go=rx . mkdir test cd test chmod u=rwx,go=r . echo "<html><body>Nothing here.</body></html>" >index.html chmod ugo=r index.html mkdir hades chmod u=rw,go=r hades cd .. mkdir cgi-bin cd cgi-bin chmod u=rwx,go=rx .

Now you can put test scripts in your cgi-bin directory and figure out if your server chroot()s, what UID your CGIs run under, etc.

print "Content-type: text/html\r\n\r\n<HTML><BODY><PRE>\n"; print "$< $> $( $) $^X $] $0\n"; print join(":",getpwuid($<)),"\n"; print "$ENV{PATH}\n"; print `/bin/pwd`; # Not for Win32 #OR# print Win32::getcwd(),"\n"; # For Win32 print "</PRE></BODY></HTML>\n"; exit(0);

Then you can try creating files:

print "Content-type: text/html\r\n\r\n<HTML><BODY><PRE>\n"; if( ! chdir("~joe/webroot") ) { print "Can't chdir to ~joe/webroot: $!\n"; } elsif( ! open(TEST,"> hades/emptytest",0777) ) { print "Can't create emptytest: $!\n"; } else { close(TEST); } print "</PRE></BODY></HTML>\n"; exit(0);

Once you get files created, check the ownership and permissions on the created files to double check how your CGIs are being run, for example, what umask is set.

If you don't have shell access, then chmod via FTP will probably have to be run as quote site chmod (use quote help to check this).