Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

set file permissions (2774) via perl upload script

Posted on 2014-04-17
7
Medium Priority
?
663 Views
Last Modified: 2014-06-07
Hello All

I have a script that uploads a file via HTTP on Apache and AIX.
The script works well.
Only issue is that the uploaded file is created with permissions 0644.
I need permissions 2774, note that 2 is Set GID. This is required by the 3rd party app that then takes the file after upload and imports it. When set only to 0644 the 3rd party app cannot read the file.
The file is an xml formatted file uploaded from a supplier.

I have tried adding the following command to the upload script but it does not make the required change, no error is returned.
my $mode = 2774;
system "chmod $mode, $filename";

Directory and file owner & group permissions are set to; nobody.users
The upload directory is not in the path of the Apache web service so security is not the first issue here.

Any assistance is appreciated.


Thanks in advance.
0
Comment
Question by:hairylots
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 29

Expert Comment

by:Jan Springer
ID: 40006460
Have you tried using perl's chmod?
0
 
LVL 62

Expert Comment

by:gheist
ID: 40006733
Apache on AIX does not run as root, so it cannot change those permission bits.
Use sftp or something that allows to change permissions.
0
 

Author Comment

by:hairylots
ID: 40008083
Hello gheist

Thankyou for that tip.
SFTP is not an option. I am stuck between 2x 3rd parties, 1st is the supply of xml data who state only via http upload and 2nd is the application owner who require the set GID bit.

If Apache will not allow this without running as root (very bad idea), then I need to think outside the square and use something like inotify or cron tasks as root. Open to suggestions.

Hello _jesper_
I am not familiar with perl chmod, is that different to system chmod?

Thanks in advance.
0
Optimum High-Definition Video Viewing and Control

The ATEN VM0404HA 4x4 4K HDMI Matrix Switch supports 4K resolutions of UHD (3840 x 2160) and DCI (4096 x 2160) with refresh rates of 30 Hz (4:4:4) and 60 Hz (4:2:0). It is ideal for applications where the routing of 4K digital signals is required.

 
LVL 3

Expert Comment

by:bigbed
ID: 40108660
Your command is "chmod $mode, $filename".
I think you need to remove the comma, to give "chmod $mode $filename"
I can't see anything in the AIX docs about it being limited to root (but I don't have an AIX machine to hand).
good luck,
Tim
0
 

Author Comment

by:hairylots
ID: 40110272
Hello bigbed

The command works as is in a perl script when run as root.
Issue is that other special users need to execute that script not as root, the HTTP upload does not set the correct permissions when it is uploaded to allow group users to make the change.
0
 
LVL 62

Accepted Solution

by:
gheist earned 1500 total points
ID: 40110330
Permosdion 0x2000 can be set only by root
0
 

Author Closing Comment

by:hairylots
ID: 40120062
correct answer
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question