Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting id of cgi program

Status
Not open for further replies.

LookingBeyond99

Programmer
Jul 2, 2001
18
0
0
US
How do i change the id of a program from nobody to a username. I want to do this so I can write to directories without chmoding it 777. I know theres a way to do this but I'm not sure how.

Thanks a lot!
 
Here is what the perldocs say about "chown":

Changes the owner (and group) of a list of files. The first two
elements of the list must be the I<NUMERICAL> uid and gid, in that order.
Returns the number of files successfully changed.

$cnt = chown $uid, $gid, 'foo', 'bar';
chown $uid, $gid, @filenames;

Here's an example that looks up nonnumeric uids in the passwd file:

print &quot;User: &quot;;
chop($user = <STDIN>);
print &quot;Files: &quot;;
chop($pattern = <STDIN>);

($login,$pass,$uid,$gid) = getpwnam($user)
or die &quot;$user not in passwd file&quot;;

@ary = glob($pattern); # expand filenames
chown $uid, $gid, @ary;

On most systems, you are not allowed to change the ownership of the
file unless you're the superuser, although you should be able to change
the group to any of your secondary groups. On insecure systems, these
restrictions may be relaxed, but this is not a portable assumption.

--------------------------------------

Note the last paragraph...

HTH.
Hardy Merrill
Mission Critical Linux, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top