From: dev_dp@mfa.com (Dave Plonka)
Subject: Re: Cannot Set Owner & User-ID bit to Root via script
Date: 1996/08/16 [thread overview]
Message-ID: <4v24tp$8v4@homer.alpha.net> (raw)
In-Reply-To: 321333D2.41C6@sms.lmco.com
John G. Bury (jbury@sms.lmco.com) wrote:
> I'm sure this is an age old problem with a simple solution, but I can't
> figure it out...I have a need to provide several users with a way to
> change the ownership of their executables to root:system and to set the
> user-id bit on the executables.
First, an observation:
If you give anyone the ability to turn on set-uid root on something that
they authored, you are essentially giving them complete root privileges.
The reason this is the case is that something that is running effectively
as root, can set its real user id to root and can run any executable and
alter any file. If this is your intent, just give them a root account,
and let them do the chown(1), chgrp(1), chmod(1) themself.
> I'm having problems with a Korn shell script I originally wrote on a
> Sun Solaris box and ported to Digital UNIX v3.2. Yes, the script does
> work on Sun Solaris with path changes to the execuables chmod and chown,
> but the script will not work on Digital UNIX.
The issue is that chown(1) works differently under Digital Unix...
From the man page for chown(2) (this is the system call on which the
chown(1) command is based):
DESCRIPTION
A process can change the value of the owner ID of a file only if the pro-
cess has superuser privilege.
It doesn't want non-root users to be able to obtain root privilege by
capitalizing on your compromising system security by leaving such a
set-uid root executable laying around.
> For some reason (I am at a loss), the script will not change the owner
> of the file (file1) to root, but it will set the user-id bit. I have
> provided the source for trouble shooting or anyone to use... If you
> have any ideas why this is occurring, PLEASE FEEL FREE TO ENLIGHTEN ME!
Systems such as this don't allow you to "give away" files... ie. change the
owner to someone else. Since chmod "knows" that you're really not root
(only your effective id is root), it seems not to allow you to change the
owner to someone else.
> ALSO, IF ANYONE HAS ANOTHER WAY OF DOING THIS PLEASE LET ME KNOW!!!
You could get around the problem by setting your real user-id to root
(using setuid(2))... of course you can't do that in ksh, but you could
in C or perl. (I won't elaborate because it's the wrong thing to do...
people will be able to "steal" root on your machine if you implement
the script as you described.)
> set_sticky () {
BTW, "set_sticky" is a misnomer. The sticky bit (a.k.a. save-text-bit)
is not what you're turning on here. That high order octal digit (as
an argument to chmod) works like this:
421
^^^
||saved-text
|set-gid
set-uid
So, "chmod 4755" doesn't set the "sticky" bit, nor do you want to.
Dave
--
Dave.Plonka@mfa.com http://www.cc.edu/~plonka ARS:N9HZF Waukesha, WI
next prev parent reply other threads:[~1996-08-16 4:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-08-15 4:00 Cannot Set Owner & User-ID bit to Root via script John G. Bury
1996-08-15 4:00 ` Phil Farrell
1996-08-16 4:00 ` Brian S Hiles
1996-08-16 4:00 ` Christopher M. Conway
1996-08-16 4:00 ` Casper H.S. Dik - Network Security Engineer
1996-08-16 4:00 ` Dave Plonka [this message]
1996-09-05 4:00 ` J. Anderson
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox