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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting suid in a shell script

Status
Not open for further replies.

mabandrew

Technical User
Oct 3, 2003
4
US
I have a script that adds users if you are root. But I want only one person to addusers. So how would i set uid in the script for access to root? I have tried the ksh -r in the etc passwd file and created links to all the commands. This restricts the user from any command other than what is linked.

Example script:

#!/bin/ksh
echo Enter user login information with no special characters and no longer than 8 characters and all lower case. Example: jsmith
echo Enter user login '"TURN CAPS LOCK OFF "'
read loginID
echo Enter user information: Example: Joe Smith
read username
echo Enter Group information: Example: staff
read group
echo Enter groups used by the user seperated by commas: Example: staff,dba,accounting
read groups
grep $loginID /etc/passwd
if [ $? -ne 1 ]
then
echo 'already in system '
else
echo "Adding user..." $loginID
mkuser pgrp="$group" groups="$groups" gecos="$username" shell="/usr/bin/ksh" home="/home/$loginID" $loginID
echo "Making user directory..." $loginID
mkdir /usr/$loginID
chown $loginID:$group /home/$loginID
echo "Setting unix users password for " $loginID
passwd $loginID
echo "Set password
 
ksh does not allow SUID/SGID scripts. You would have t o compile a C program using setuid(0)/setgid(0).
 
Also you may try using sudo from bull, it is quite the handy program that would allow what you are trying.

AW
 
It may be easier to apply ACLs to /usr/bin/mkuser to allow only a specified user to operate on that domain.

Then your script should work.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top