Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Cannot Set Owner & User-ID bit to Root via script
@ 1996-08-15  4:00 John G. Bury
  1996-08-15  4:00 ` Phil Farrell
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: John G. Bury @ 1996-08-15  4:00 UTC (permalink / raw)
  Cc: jbury


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.

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 script itself is
owned by root:system with the user-id bit set, and does the following:

        -rwsr-xr-x   1 root     system       script_name

  1) Checks the usage/syntax
       Usage: script_name <filename1> <filename2> ...
  2) Checks if the user running the script has permissions to use it
     via a list of authorized users.
  3) Changes the owner and permissions on the files passed to the 
     script to owner root, group system, and sets the user-id bit. 
       /sbin/chmod 4755 filename1 filename2...
       /sbin/chown root:system filename1 filename2...

When I excute this script as an authorized user, I receive the
following error from the /sbin/chown command:

$ script_name filename1
Changing ownership and permission on filename1...
chown: filename1: Not owner
done
$

filename1 before executing the script:
        -rwxr-xr-x   1 name1   users       filename1

filename1 after executing the script:
        -rwsr-xr-x   1 name1   users       filename1

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!
ALSO, IF ANYONE HAS ANOTHER WAY OF DOING THIS PLEASE LET ME KNOW!!!

THANKS FOR YOUR TIME AND KNOWLEDGE...


#!/bin/ksh
#
########################################################################
#
# This script allows the AUTHORIZED_USER to change the owner of files
# to root:system and sets the user-id bit on the files.
#
########################################################################
#
set_sticky () {
     for FILES in "$@"
     do
        echo "Changing ownership and permission on ${FILES} ..."
        /sbin/chmod 4755 ${FILES}
        /sbin/chown root:system ${FILES}
     done
}
#
# Variable Definitions
#
set -A LIST_OF_AUTHORIZED_USERS name1 name2  # Load array of Auth-Users
DEBUG=0                                      # Debug flag; 0-off 1-on
#
# First check the usage of the command
#
if [[ $# -lt 1 ]]; then
  echo "Usage: $0 <filename1> <filename2> ..."
  exit
fi
#
# Next ensure that no one can execute this program except the AUTHORIZED
# _USERS
#
PARENT=`ps -af | awk '{ if ($2 == PID) print $3 }' PID=$$`

if [[ ${DEBUG} -eq 1 ]]; then
  echo "The PARENT process id is ${PARENT}"
fi

USER_NAME=`ps -af | awk '{ if ($3 == PPID) print $1 }' PPID=${PARENT}`

if [[ ${DEBUG} -eq 1 ]]; then
  echo "The users name is ${USER_NAME}"
fi
#
# The USAGE and AUTHORIZED_USER tests passed - Change the permissions
#
for AUTHORIZED_USER in "${LIST_OF_AUTHORIZED_USERS[@]}"
do
   if [[ ${USER_NAME} = ${AUTHORIZED_USER} ]]; then
     set_sticky $*
     echo "done" 
     exit
   fi
done
#
echo "Sorry - Unauthorized User. Permission Denied..."
 
-- 
* John G. Bury                                                       *	
* Globalstar Satellite Operations Control Center                     *
* Lockheed Martin Corporation       Voice:  (301) 805-0580           *
* 7375 Executive Place              FAX:    (301) 805-0371           *
* Seabrook, MD  20706               E-Mail: jbury@DS01.sms.lmco.com  *



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1996-09-05  4:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` Dave Plonka
1996-08-16  4:00 ` Casper H.S. Dik - Network Security Engineer
1996-09-05  4:00 ` J. Anderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox