jmcnamara has asked for the wisdom of the Perl Monks concerning the following question:


I maintain a CPAN module that stores data in a temp file created via IO::File::new_tmpfile(). If it cannot create the temp file it falls back to storing the data in memory. Like this:
my $fh = IO::File->new_tmpfile(); if (defined $fh) { # Do something with the tmpfile } else { # Do something in memory }
Someone has written to me to say that on his IIS system the module cannot create the temp file via new_tmpfile() and that the in-memory option isn't suitable.

I appreciate that this is probably a rights/permissions problem but I do not have access to an IIS system to try to resolve the problem myself.

My question is: can new_tmpfile() be made to work on IIS and if so how.

John
--

How's my coding? Dial 1-800-345678

Replies are listed 'Best First'.
Re: IO::File::new_tmpfile on IIS
by hopes (Friar) on Oct 18, 2001 at 02:42 UTC
    Hello, I've just put this code
    use IO::File; print "Content-type: text/html\n\n"; print "Go..\n"; my $fh = IO::File->new_tmpfile(); if (defined $fh) { # Do something with the tmpfile print "Defined: $fh\n"; } else { # Do something in memory print "Not defined\n"; }

    in my site running IIS 4
    and it seems no work.
    If I run the code in a command window, the output is what I expect:

    Go..
    Defined: IO::File=GLOB(0x176f208)

    I think is a permissions problem, the user which is executing that .pl is an anonymous user, and it has no permissions except in a couple of directories.
    Hope this helps

    Hopes
      I can corroborate this. IIS will only write to files that reside in or beneath the web root (A-Z:\InetPub\wwwroot\ by default). I've gotten around this problem by creating a temp directory (D:\foo\temp)and making it into a IIS virtual directory (http://localhost/temp/).
Re: IO::File::new_tmpfile on IIS
by guha (Priest) on Oct 24, 2001 at 13:32 UTC
    My question is: can new_tmpfile() be made to work on IIS and if so how.

    IIS will try to write the temporary file to the system root which mostly translates to c:\. The file's owner will be either
    IUSR_{servername}, IUSR or IUSER depending on what is defined as the Anonymous http user on the server.

    By default, in W2k IIS 5.0 at least, the Everyone group, wherein the owner above is included, has all rights in systemroot and the new_tmpname function will work. Security conscientious admins might have revoked those rights and that will render new_tmpfile nonfunctional.

    Any further knowledge on this, brothers ?

    Another funny?? thing is that there seems to be a oneoff bug regarding the name of the tmp-file.

    For example Posix::tmpnam says \s3vvs9m3.6 but the file \t3vvs9m.6 is written to the system root and another example is \sa4.9 becomes \ta4.9

    So the answer to the original question is YES