Perl Uploading Files


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Perl Uploading Files
# 8  
Old 02-20-2004
umask should be in your %ENV.

but befor we delv into that.

i would check the permissions of the parent directories.

also, if you happen to be writeing to a samba or sharity share permissions tend to get wacky from time to time.

being it happens at a semi regular intervel. (look like every 6-7 hours or so)

is it always the same upload directory you are haveing any errors? or is it always a random user in a random directory?

implamenting a new function to chmod the file in perl should just be adding a new function that accepts 1 paramerter and that should be the fullpath to the file.

at a command prompt umask -S should show you the current umask perms in a more readable format.

Code:
use@host$ perldoc -f umask
     umask EXPR
     umask   Sets the umask for the process to EXPR and returns
             the previous value.  If EXPR is omitted, merely
             returns the current umask.

             The Unix permission "rwxr-x---" is represented as
             three sets of three bits, or three octal digits:
             0750 (the leading 0 indicates octal and isn't one of
             the digits).  The "umask" value is such a number
             representing disabled permissions bits.  The
             permission (or "mode") values you pass "mkdir" or
             "sysopen" are modified by your umask, so even if you
             tell "sysopen" to create a file with permissions
             0777, if your umask is 0022 then the file will
             actually be created with permissions 0755.  If your
             "umask" were 0027 (group can't write; others can't
             read, write, or execute), then passing "sysopen"
             0666 would create a file with mode 0640 ("0666 &~
             027" is 0640).

             Here's some advice: supply a creation mode of 0666
             for regular files (in "sysopen") and one of 0777 for
             directories (in "mkdir") and executable files.  This
             gives users the freedom of choice: if they want
             protected files, they might choose process umasks of
             022, 027, or even the particularly antisocial mask
             of 077.  Programs should rarely if ever make policy
             decisions better left to the user.  The exception to
             this is when writing files that should be kept
             private: mail files, web browser cookies, .rhosts
             files, and so on.

             If umask(2) is not implemented on your system and
             you are trying to restrict access for yourself
             (i.e., (EXPR & 0700) > 0), produces a fatal error at
             run time.  If umask(2) is not implemented and you
             are not trying to restrict access for yourself,
             returns "undef".

             Remember that a umask is a number, usually given in
             octal; it is not a string of octal digits.  See also
             "oct", if all you have is a string.

# 9  
Old 02-20-2004
Thanks for the advice. To answer your question, it's always a random user in a random directory. We're about half-way through changing our scripts to manually chmod the uploaded file, so I think I'm going to just let this problem go. I have one last thing to post; maybe this will be the secret ingredient needed to figure out this problem. We ran into the problem consistently again (which makes it roughly every 3 hours now), so I did
Code:
ps -ef > psbad.txt

and restarted apache. We had tried this a couple of weeks ago and it fixed the problem then. Again, it fixed the problem. So I did
Code:
ps -ef > psgood.txt

I'll load those files zipped in case anyone wants to look at it to see if they can figure out what the problem is. It looks to me like the same processes are running at both times, which makes me all the more confused. Thanks everyone for helping me out with this.

I can't figure out how to link to the file I uploaded, so you can get to the .txt's at http://www.proinnov.com/psbad.txt and http://www.proinnov.com/psgood.txt

Last edited by sstevens; 02-20-2004 at 05:19 PM..
# 10  
Old 02-20-2004
Code:
apsedu   31656 28302  0 12:21 ?        00:00:00 [sideA.cgi <defunct>]
apsedu   31657 28302  0 12:21 ?        00:00:00 [sideB.cgi <defunct>]
chsmain  31658 31001  0 12:21 ?        00:00:00 [showfac2f.cgi <defunct>]

you dont happen to get any errors on your cgi scripts do you?
# 11  
Old 02-20-2004
No, we don't get errors with those scripts. I've always been curious why they occasionally come up as scriptname <defunct>, but have never really payed attention to it because they always work.
# 12  
Old 02-20-2004
being that they are httpd servers that are dieing befor the script closes could be a reason for your problem.

i would try and find out why the server is dieing befor the child. it could be a source of your problem.



Code:
the Ppid is 

root      8553     1  0 Feb19 ?        00:00:00 /usr/sbin/httpd
apache   31001  8553  0 12:19 ?        00:00:00 /usr/sbin/httpd
chsmain  31658 31001  0 12:21 ?        00:00:00 [showfac2f.cgi <defunct>]

# 13  
Old 02-20-2004
So I started roaming around looking for apache httpd bugs and found one that says
Quote:
mod_cgid in Apache before 2.0.48, when using a threaded MPM, does not properly handle CGI redirect paths,
which could cause Apache to send the output of a CGI program to the wrong client
We're running apache 2.0.40. Does that mean that when these files are being uploaded they could be given the umask of a user that doesn't exist, which in turn would give the file the 600 permissions?
# 14  
Old 02-23-2004
since the snipit specificly says that STDOUT can goto the wrong client when useing a redirect i would lean toward no i dont think this would be the problem. But it would be unwise to rule it all out.

the default umask should be in /etc/profile.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Web Development

Uploading files via php

I used the following code, which I found on the internet to upload files. <!-- The data encoding type, enctype, MUST be specified as below --> <form enctype="multipart/form-data" action="upload2.php" method="POST"> <!-- MAX_FILE_SIZE must precede the file input field --> <input... (2 Replies)
Discussion started by: jgt
2 Replies

2. UNIX for Dummies Questions & Answers

Plowshare Command In Uploading Files

OK i am completely new to this stuff!! let me start from the beginning!!! I Am connected to Whatbox.ca Via SSH!! Then I installed plowshare using their guide perfectly Now They Told Me To refer Plowshare site's Command list for uploading any files to Various... (4 Replies)
Discussion started by: anime12345
4 Replies

3. UNIX and Linux Applications

Need help on uploading Video files on Mediawiki and embed to page

I am working on to uploading Video files on Mediawiki and embed to page but not getting success. I tried plugin like MediaPlayer and HTML5Player but these plugins seems having extension limitation as i need to embed files like .wmv, .mpg etc. I am using mediawiki1.17 and CentOS5.8 x64 bit ... (1 Reply)
Discussion started by: sunnysthakur
1 Replies

4. Shell Programming and Scripting

Perl , uploading empty file.

Hi The below script used to work fine. Suddenly it's uploading empty file. I am very new to perl. Please help me to find out the problem. #!/usr/bin/perl #script: upload.pl use CGI qw/:standard/; print header, start_html('File upload'); print_form(); print_results() if... (2 Replies)
Discussion started by: Anupam_Halder
2 Replies

5. Shell Programming and Scripting

Uploading excel sheet to sharepoint portal using perl

Thourgh Perl scripting, Is it possible to upload excel sheet to sharepoint portal ? If the answer is YES.. Could you please share your thoughts and required CPAN modules or any examples to proceed further? Regards, Giridhar S ---------- Post updated at 04:26 AM ---------- Previous update... (0 Replies)
Discussion started by: giridhar276
0 Replies

6. UNIX for Advanced & Expert Users

Shell Script for uploading files to multiupload.com

Hi Please help me writing a shell script for multiupload. result should look like: $ ./multiupload.sh /tmp/file.avi http://www.multiupload.com/P1R9BZ4X3Q http://i.imgur.com/a2vhH.png There seems to be no official API. (3 Replies)
Discussion started by: slashdotweenie
3 Replies

7. UNIX for Dummies Questions & Answers

Uploading files from Mac to Unix/Linux via ssh

Ok. I am using the Terminal window to ssh into a unix server. I am not sure how to copy a file from my mac onto the unix server. What command do I enter and how do I type the file I want to upload Example. Say my file is named Test1.doc and it is on the usr/me/test/working/ directory and I want... (3 Replies)
Discussion started by: libertyforall
3 Replies

8. Shell Programming and Scripting

to block the files uploading via the port

Hi Folks, I am not good in shell scripting. Please help me with my problem. Is it possible to block the file named "ss.cgi" using the port 25 to upload. (4 Replies)
Discussion started by: gsiva
4 Replies

9. UNIX for Advanced & Expert Users

Uploading files in chronological order

Thanks for your help. (3 Replies)
Discussion started by: circuit.muni
3 Replies

10. UNIX for Dummies Questions & Answers

uploading Zipped files get 553 error

I am trying to upload .zip files to Unix server and get the error 553 qmerev2002.zip: Permission denied, what is my problem?? I am able to load other files and folders fine. (3 Replies)
Discussion started by: CoastGuard1970
3 Replies
Login or Register to Ask a Question