Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.)


In reply to Re: Script not setting ownship of new directory by graff
in thread Script not setting ownership of new directory by bradcathey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found