From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1012a6,e0a9823ca423b93b,start X-Google-Attributes: gid1012a6,public X-Google-Thread: fee84,e0a9823ca423b93b,start X-Google-Attributes: gidfee84,public X-Google-Thread: 1020c6,e0a9823ca423b93b,start X-Google-Attributes: gid1020c6,public From: "John G. Bury" Subject: Cannot Set Owner & User-ID bit to Root via script Date: 1996/08/15 Message-ID: <321333D2.41C6@sms.lmco.com>#1/1 X-Deja-AN: 174392321 cc: jbury@DS01.aerosys.sms.lmco.com content-type: text/plain; charset=us-ascii organization: Lockheed Martin Corporation, Space Mission Systems mime-version: 1.0 newsgroups: comp.unix.osf.osf1,comp.unix.shell,comp.unix.admin x-mailer: Mozilla 2.02 (X11; I; OSF1 V3.2 alpha) 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 ... 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 ..." 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 *