[Chicago-talk] chown inside a script
Brian Katzung
briank at kappacs.com
Wed Dec 5 22:22:17 PST 2007
Jay,
A couple of alternatives come to mind, depending on what you're trying
to accomplish:
Have you ruled out the use of group-based access and a set-gid directory
rather than changing file ownership?
A sudo rule for the web-server user might be better than a suid "link"
to chown (or rules for whatever subsequent actions might be required by
users other than the owner).
If your system supports it, you could mount a file system (e.g. vfat)
that supports the uid= option so that all the files are owned by the
desired user regardless of who creates them.
Feel free to contact me directly if you want to discuss any of these
options.
- Brian
Jay Strauss wrote:
> Thanks.
>
> But I don't think that will work in my case, because I'm doing it from
> a web page, I had to create an suid link to chown, to call from my
> cgi.
>
> Unless there is some way to do it from inside perl, but still change
> ownership of file not owned by the webserver.
>
> Thanks
> Jay
>
> On Dec 5, 2007 8:42 PM, Brian Katzung <briank at kappacs.com> wrote:
>>
>>
>> Jonathan Rockway wrote:
>>> On Wed, 2007-12-05 at 15:58 -0600, Andy Lester wrote:
>>>> system( 'chown', 'whoever', glob( '/home/blah/blah/whatever*' ) );
>>> BTW, chown is a builtin function:
>>>
>>> chown $uid, $gid, </path/to/files/*>
>>>
>>> Regards,
>>> Jonathan Rockway
>> Putting it all together (except for error checking :-),
>>
>> chown scalar(getpwnam "jblum"), -1,
>> glob("/opt/montrose/private/active/PROSPECT/07120415*");
>>
>> Programming by committee. We should qualify for government work. :-)
>>
>> - Brian
--
Brian Katzung, Kappa Computer Solutions, LLC
Leveraging UNIX, GNU/Linux, open source, and custom
software solutions for business and beyond
Phone: 877.367.8837 x1 http://www.kappacs.com
More information about the Chicago-talk
mailing list