Link to home
Start Free TrialLog in
Avatar of hairylots
hairylotsFlag for Australia

asked on

set file permissions (2774) via perl upload script

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.
Avatar of Jan Bacher
Jan Bacher
Flag of United States of America image

Have you tried using perl's chmod?
Apache on AIX does not run as root, so it cannot change those permission bits.
Use sftp or something that allows to change permissions.
Avatar of hairylots

ASKER

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.
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
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.
ASKER CERTIFIED SOLUTION
Avatar of gheist
gheist
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
correct answer