Beefy Boxes and Bandwidth Generously Provided by pair Networks httptech
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Archive::Zip errors

by virtualsue (Vicar)
on Nov 04, 2005 at 09:25 UTC ( #505657=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Archive::Zip errors
in thread Archive::Zip errors

Then is this statement from your original post correct?

All my other cgi scripts happily write to these folders but archive::zip won't

Are you *sure* that www:apache can create files in the /delme/ directory?


Comment on Re^3: Archive::Zip errors
Re^4: Archive::Zip errors
by fluffyvoidwarrior (Monk) on Nov 04, 2005 at 09:57 UTC
    Just added :
    open(WOBBLE, ">/delme/flunk.txt"); print WOBBLE "Bugger!"; close(WOBBLE);
    to my cgi script and you're right apache wont write to the /delme directory. However, I then tested it on my actual real life directory with this code
    open(WOBBLE, ">/caralan_com/system/proofing/cam_proofs/steve/live/fl +unk.txt"); print WOBBLE "Bugger!"; close(WOBBLE);
    and the file is created as expected. It sounds like I have my permissions set wrong and that perhaps archive::zip is less forgiving than apache. I'll try opening my permissions and owner to something totally public all along that path and see what happens.
      I have not seen anything yet which indicates that this problem has anything to do with Archive::Zip. What is important here is the fact that your CGI scripts run as www, so the www user must have write permission in the locations specified in your scripts.

      You will make your life easier as well as more secure if you set up a development environment which has the same underlying directory structure & permissions as your target production environment, rather than writing test files in random places on your hard drive. :)

        Yes, That seems sensible and it is how I normally work. I use the /delme folder for shared junk with very loose security which is why I tested it there when I thought I had a permissions problem. Mainly I wanted to know that I wasn't doing anything dumb with archive::zip since I have about 20mins experience with it but was pretty certain of my code since it was lifted from the man page and the names changed. Thanks for your help. It doesm't seem like a perl or archive::zip problem so unless you have any other thoughts I'll "poke it with a stick" and trust to luck ...

      It sounds like I have my permissions set wrong and that perhaps archive::zip is less forgiving than apache. I'll try opening my permissions and owner to something totally public all along that path and see what happens.

      Well, you're getting *very* close. Archive::Zip has nothing to do with permissions directly. I'm almost postive that what you're missing is that apache runs on one user account, that quite likely has slightly different permissions than your login user account.

      When you execute a CGI manually, you're running as *you*. Meanwhile, when one is called via the Apache daemon, it's running as (apache|httpd|etc.).

        The apache daemon will write to these directories in response to events from remote users interaction via cgi. When the same remote connection to the same cgi script invokes archive::zip it wiill not write a file. This code will write to disk:
        open(WOBBLE, ">/caralan_com/system/proofing/cam_proofs/steve/live/fl +unk2.txt"); my $zip = Archive::Zip->new(); $zip->addTree( '/delme/wibble', 'customer_uploads' ); $zip_return_code = $zip->writeToFileHandle('WOBBLE'); close(WOBBLE);
        But this will not:
        my $zip = Archive::Zip->new(); $zip->addTree( '/delme/wibble', 'customer_uploads' ); $zip_return_code = $zip->writeToFileNamed('/delme/$proofstem.zip');

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://505657]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2014-04-19 06:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (478 votes), past polls