Handle hostnames with upper-case letters
[webmin.git] / maketemp.pl
1 # maketemp.pl
2 # Create the /tmp/.webmin directory if needed
3
4 $tmp_dir = $ENV{'tempdir'} || "/tmp/.webmin";
5
6 while($tries++ < 10) {
7         local @st = lstat($tmp_dir);
8         exit(0) if ($st[4] == $< && (-d _) && ($st[2] & 0777) == 0755);
9         if (@st) {
10                 unlink($tmp_dir) || rmdir($tmp_dir) ||
11                         system("/bin/rm -rf ".quotemeta($tmp_dir));
12                 }
13         mkdir($tmp_dir, 0755) || next;
14         chown($<, $(, $tmp_dir);
15         chmod(0755, $tmp_dir);
16         }
17 exit(1);