These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for Change file owner on php uploaded file on the new forum.
Not sure if this has anything to do with Virtualmin...
I have a PHP application that is encrypted, so I cannot modify the code.
It is running in a virtual server, as user www1. When this php app uploads a file, it is given the ownership of www1.
Is there a way in virtualmin to tell the virtual server what owner it should be running as so I can change the ownership of these uploaded files?
Thanks,
And sorry if this does not pertain to VirtualMin, I have been looking at other options and wonder if this is one of them.
your php application should change permissions.
However you can try using webmins filemanager and select the upload directory. then set your permissions for it (under info) and click "files inherit values" or however it's called exactly..this might do the trick as well.
you might want to set ownership on that folder first, if not preferred then create a folder in it and set ownership on that one.
that sounds like a browser problem
per haps you can try firefox, it has a plugin for java.
Or other different modern browsers like opera, or chrome.
Also make sure it is activated in the properties of your browser
I once had the permissions changed by setting this through the filemanager, described above. It is odd that it didn't work for you on your server.
I needed that for a specific folder used by dolphin software which uploaded mediafiles.
On Joes comment,
Any idea on configuring the php.ini file? I am googling because that seems the corect route,
However, I worry my tmp folder might get in the way before transferring to the actual upload folder...
Still googling. :)
Hmmm...I'm not seeing anything about it at the moment. Looks like maybe your application needs to handle setting the file mode, as there doesn't seem to be a mask setting in php.ini.
--
Check out the forum guidelines!
can you not create a php file and run that as a cron job every 5 minutes?
[code:1]
<?php
// Everything for owner, read and execute for owner's group
chmod("/somedir/somefile", 0750);
?>
[/code:1]
chmod would be preferred over umask, yes?
Thanks for the idea that sounds close to what I need, however,
When I go to Webmin -> Other -> File Manager, it says:
This module requires java to function, but your browser does not support java
And I have java installed and I use it on other sites, so I wonder why it is not detecting that properly now.
<div class='quote'>And I have java installed and I use it on other sites, so I wonder why it is not detecting that properly now.</div>
Are you sure? ;-)
In Firefox, you can check to see whether you have it by looking in the plugins page. Type "about:plugins" into the URL bar, and hit enter. I don't know how to do this in any other browser.
But, it seems to work with pretty much any of the official Sun Java plugins I've tried over the past several years. (It tries to work with the GNU Java plugin, but fails to actually run--the page just goes gray. But, so few of our users use that Java plugin version, it hasn't been a priority.)
--
Check out the forum guidelines!
Don't mind me, it is friday I guess :P
I had to reinstall it because I think I disabled it at some point.
Anyhoo, I found "Files Inherit Group" but that had no effect. I don't know if this really is a virtualmin thing so much as a linux/apache/php thing, but was hoping virtualmin could make it easy for me.
I just have no clue how to make this one php app upload as a different user.
To reitterate, I do not have access to the php code to modify the owner because the source is encrypted, so I have to do this some other way...
Anyone? :) Thanks for the help.
Well, suexec is a tool that has Apache execute code for a given Virtual Server as a given user.
Generally, said user is the Virtual Server owner.
What you might be able to do is create a Virtual Server for this particular application, and simply make sure that the suexec user for Virtual Server is the user you want it uploading files as.
That'd be easiest if that user were the Virtual Server owner, but you can also edit the Apache config and manually add the UID/GID you want it to switch to (but of course, you'll need to make sure the dir and files associated with it are the same).
-Eric
Sorry I am confusing things.
I actually need the app to upload a file with different permissions, not a different user.
Anyway, thanks for your guys' input.
Ahh, perhaps setting a umask will do what you're after. It allows you to change the default permissions for a directory and all directories under it for when files are created.
Some details are here:
http://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage...
http://linux.die.net/man/1/umask
Ahhh good idea I'm learning lots!
I tried it but the uploaded files seem to ignore the umask. :(
Logged in as root and touching a new file listens to the umask, but still not the php app.
Hrm.
Yeah.
You may need to set the umask in Apache's init script.
It doesn't matter where in the init script, just somewhere near the top, and before Apache itself is launched. Then restart Apache and try it again.
-Eric
PHP doesn't respect the shell umask, I believe. I think you'll need to set it explicitly in the php.ini.
--
Check out the forum guidelines!