Gossamer Forum
Home : General : Perl Programming :

The owner?

Quote Reply
The owner?
On unix (linux?) system, is there a way to change the owner of the file?
For example, if I got a file with owner "nobody", can I change it to user owner "jack"?

I am new to unix system, please help.

Pasha

------------------
The Flying Cranes, Inc:
http://www.theflyingcranes.com
Perl scripts & Web promotion:
http://find.virtualave.net
Quote Reply
Re: The owner? In reply to
Hi:

There is the 'chown' function but I believe you require 'superuser' (admin) status to use it. If you are on a dedicated server then probably yes. You might want to ask your web host.

Dan Smile
Quote Reply
Re: The owner? In reply to
No, I mean if there's a way to do it with CGI script.
Quote Reply
Re: The owner? In reply to
I believe you can use the 'chown' (=[ch]ange [own]ership) function within a script - but unlikely as a regular user. Give it a try and see what happens.

Dan Smile
Quote Reply
Re: The owner? In reply to
Okay, I got a similar question/problem. I have sendmail routines in my DBMAN cgi file. Most of the sendmail routines function properly with the exception of a few that sends out messages From: Unpriviledged user (nobody@myserver.com).

I did contact my ISP (who shall remain nameless, but boy am I tempted to make them look like jerks!) Tech Support and this is the response I got:

Quote:
Hi,

Since "index.cgi" is not technically allowed to be used on our servers, I can
offer you no support on the matter. Sorry.

Tom

I think this is a bunch of dog poo! Wink

Anyway, has anyone seen this before and also how can I fix it, since my ISP has definitely coped out of this one.

Thanks. Smile

Regards,


------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us

[This message has been edited by Eliot (edited August 16, 1999).]

[This message has been edited by Eliot (edited August 16, 1999).]

[This message has been edited by Eliot (edited August 16, 1999).]
Quote Reply
Re: The owner? In reply to
Dan, could you show me a short example of how to use that "chown".

Thank you.

------------------
The Flying Cranes, Inc:
http://www.theflyingcranes.com
Perl scripts & Web promotion:
http://find.virtualave.net
Quote Reply
Re: The owner? In reply to
From the perl docs:

chown LIST

Changes the owner (and group) of a list of files. The first two elements of the list must be the 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 "User: ";
chop($user = <STDIN> );
print "Files: ";
chop($pattern = <STDIN> );
($login,$pass,$uid,$gid) = getpwnam($user) or die "$user not in passwd file";
@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.

adam
Quote Reply
Re: The owner? In reply to
 
Quote:
Anyway, has anyone seen this before and also how can I fix it, since my ISP has definitely coped out of this one.

Smile I wonder why "technically" it's not allowed. Anyways, my experience has been that you'll see that if the From address is blank or invalid, so sendmail uses the userid of the person sending the mail (in this case the web server).

Hope that helps,

Alex
Quote Reply
Re: The owner? In reply to
Thanks, Alex. I have set the "From" field to be From: $admin_email, which $admin_email is career@anthrotech.com. I also tried using just From: career\@anthrotech.com.

Still getting that Unpriviledged User.

Yea, it is weird that my ISP is disallowing index.cgi files to run, while in their tech support pages, they encourage people to name default files in cgibin directories as index.cgi.

Regards,


------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us