Visit The New, Modern Unix Linux Community


Perl Uploading Files


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Perl Uploading Files
# 1  
Perl Uploading Files

Using perl 5.8.0, Linux 2.4.20-30.9, RedHat 9.0.
We have many .cgi's that allow privileged users to upload files to the server through a web browser. We've had these .cgi's for years and have never had any problems with them. Recently the files being uploaded are sometimes being given 600 permissions instead of 644 permissions, which they always used to be given. When you try to access the uploaded file set to 600 with a web browser you get a 403 Forbidden error. I was playing with it last night and uploaded the same file using the same .cgi about 10 times and every time it was given 600 permissions. Then, without changing anything, the next couple of times the file was uploaded with 644 permissions, then it went back to the 600 permissions. I'm really lost. Any help would be great.
# 2  
after you upload the file have perl change the perms on the file.

dont rely on the umask.

but it sounds like some other process is messing around with the files.
# 3  
We're working on changing the perl files to change the permissions manually. We just have so many that I was hoping there would be an easier way.

I agree it sounds like another process is screwing up the files, but I have no idea what process it would be or how to find it. If you have any insight on that I'd appreciate it. Thanks for your help.
# 4  
unfortunetly i never used perl to upload files. i always use FTP.

1) when files are uploaded are they always uploaded to the same directory no matter what user signs in?

2) is there any corrolation to the user sign in to the unix account on the machine?

3) are all the users umask the same?
# 5  
Optimus_P

First, I really appreciate you helping me out with this. I've been on other forums and nobody has tried to help as much as you have.

1) The files that are being uploaded can go to hundreds of different folders. We have multiple sites using the uploading scripts, and within those sites users can choose to upload the files in various places.

2) The users on our sites have no correlation to our unix users. On the sites we're having the most problems with, there's an average of about 50 users, with all usernames defined by the user.

3) I didn't even know about umask until your last post. The only thing I know how to do with it now is type it in and get 0022 in response, which I think means all uploaded files will be given 644 permissions. I did man umask but I couldn't even figure out where to find the umask info. It listed all the bash builtins and I got confused.

We did figure out that we only have this problem at certain times. The only times we know of so far is sometime around 11:00 pm MST and between 5:00 pm - 6:00 pm MST. Between 5:00 and 6:00 it's very rare that the file gets uploaded with the correct permissions. We must have done 30 uploads in that time span and only 3 or 4 were uploaded correctly. We were running top at the same time, but we couldn't find any odd-looking processes running.

Thanks again for your help.
# 6  
First, about umask... When a process creates a file, it uses the open() or creat() system calls. Both calls have a mode parameter to set the mode of the file. The mode is the number you're mentioning as 600 or 644. The kernel does not use the mode directly as it creates the file. Instead the file's mode is set to the expression "mode & ~umask". A process can change its umask value via the umask() system call. But it inherits its original umask from the parent.

This leads to my suspect: a faulty parent. The parent process, when overloaded or something, is spawning children incorrectly.

I'm not a web expert nor a perl expert. But I think that the parent of of cgi scripts is the webserver itself. The error in the parent should be researched. Maybe a new release or something is available?

If I'm right, a quick fix would be to modify the cgi scripts to set their umask to 0. This is probably as simple as inserting "umask(0)" or something like that as the first line. Maybe Optimus_P can chime in here with the perl syntax for that.
# 7  
Quote:
This leads to my suspect: a faulty parent. The parent process, when overloaded or something, is spawning children incorrectly
It really seems like that's the problem. We're still narrowing down any patterns, but it here's any consistency we've found so far.

Roughly 11:00 pm - consistently wrong permissions
5:00 pm - 6:00 pm - consistently wrong permissions
10:00 am - 10:30 am - not as consistent as 5-6, but still pretty bad

Maybe the parent is being hit with another process on the server at these times, and is causing it to do what you described above.

We don't have any crons running at these times. I'm using top during these times to try to find any wierd processes, but have been unsuccesfull. I'll start looking into the parent for .cgi's and see if I can find something.

Thanks.

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #787
Difficulty: Medium
In early 2019, Bill Gates responded to the public backlash against billionaires by demanding a lower estate tax.
True or False?

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

Featured Tech Videos