As you must know, "chown" on any unix or linux box is strictly a root-user activity. There is simply no way to provide chown access without also providing root access. If you want your web server to run a cgi process that does chown, it must run as root, or else you must violate a basic principle of OS security by creating a set-uid script that does chown. In either case, you will be fully entitled to all the risks and disasters that this could conceivably support.
It would be better for the web transaction to create some sort of signal or other symptom that could be picked up by a separate, root-owned process (not directly accessible via http), so that this root-owned process could do the right thing in terms of changing ownership on specific files, so that a web process does not need to do this.
Or, you could run a process under your "sftp" user account that copies the uploaded files and thereby assumes ownership of the copies. If you want to keep the files where they are with original names intact, and the "sftp" user is able to have write access in the directory where the "www-data" user puts uploaded files (e.g. if they are both included in a given group, and there's group write access on the directory), "sftp" can rename the uploaded files, copy them to the original names (thereby taking ownership) and then delete the www-owned originals. "Look, ma! No root privileges!" (Generally better and certainly safer that way, IMHO.)
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|