Question on Set User ID on Execution


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Question on Set User ID on Execution
# 1  
Old 10-07-2005
Question on Set User ID on Execution

I want group to run one of my unix script as me . I when the script is run it should have my permission's not the group .

I tried this :
1.Have a file called y.ksh

cat y.ksh
echo $LOGNAME >ak_test

2.Output file has this permission
-rwx------ ak_test

3.Then I chnaged the permission on the y.ksh like
this

chmod 4750 y.ksh

4. When I try to run y.ksh from other user id but member of same group . Script gives a error
ak_test can't create

Am i missing something on this or Is there any other way to achive this

I did looked into the other question on this forum .

Thanks
Ashok
# 2  
Old 10-07-2005
Most of the modern operating systems do not support setuid shell scripts. So your script is still running with the your id and not the one that you want it to.

Please post the output of uname -a. Also the output of the command: ls -l y.ksh
# 3  
Old 10-07-2005
I probably remember of reading somewhere that Sunos 5.7 onwards supports this

uname -a
SunOS acbusd1 5.9 Generic_118558-06 sun4u sparc SUNW,Sun-Fire-480R

ls -l y.ksh
-r-sr-x--- 1 akrathi acbudev 23 Oct 7 10:39 y.ksh
# 4  
Old 10-07-2005
SunOS does support suid scripts. Howevet the exec must succeed. Read this thread.
# 5  
Old 10-07-2005
SunOS may support setuid scripts, but many others dont - and with good reason too. Here are two sites that explain how setuid shell scripts can be used to gain root access.
How can I get setuid shell scripts to work?
Shell Scripting Languages (sh and csh Derivatives)
# 6  
Old 10-07-2005
Sun is using the /dev/fd driver trick mentioned in your first link. This does not mean that suid shell scripts are safe....a secure script is hard to write. But running a script under sudo is almost as dangerous. All sudo can add is to protect the script from the environment and a good programmer will do that anyway.
# 7  
Old 10-07-2005
That is true. But it is an undeniable fact that many times shell scripts that run with root privileges are necessary and as admins we just have to live with that.
Anyway, back to the OP's question.
Quote:
Originally Posted by akrathi
I probably remember of reading somewhere that Sunos 5.7 onwards supports this

uname -a
SunOS acbusd1 5.9 Generic_118558-06 sun4u sparc SUNW,Sun-Fire-480R

ls -l y.ksh
-r-sr-x--- 1 akrathi acbudev 23 Oct 7 10:39 y.ksh
According to the ownerships, the script will run as user akrathi. Now, what are the permissions on ak_test? Does the user akrathi have permissions to create/remove files in the directory where ak_test exists?
Check the output of ls -ld command on the directory where ak_test exists. If akrathi does not have permissions to write to the directory, you will not be able to create the ak_test file.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Dumb question on script execution

Hi Folks - I have a dumb question. Why does this work: pushd "/apps/scripts" ./script.sh popd But this doesn't: ./apps/scripts/script.shIs it that obvious where I'm overlooking it? (7 Replies)
Discussion started by: SIMMS7400
7 Replies

2. Programming

Perl script remote execution as another user

Hi gurus, I have a requirement where I need to remotely run a perl script as another user. Running the script locally as the required user is fine, however I need to su with the script due to filesystem permission issues. I do not want to update permissions on the remote server due to security... (5 Replies)
Discussion started by: melias
5 Replies

3. UNIX for Advanced & Expert Users

How to set the SGE job execution order for nested qsub?

Dear All I am trying to write a script to set the SGE job execution order. I named each job with 'job1', 'job2' and 'job3'. I want my script to do: When 'job1' execution is complete, 'job2' is executed; when both 'job1' and 'job2' are complete, 'job3' is executed. First, I tried this... (0 Replies)
Discussion started by: cliffyiu
0 Replies

4. UNIX for Dummies Questions & Answers

Question on execution

Hello All, 1) I have 2 questions, when i try to execute the below shell script through putty it does not showing me whole syntax rather its trimming of some part may be due to some buffer issues. Could you please tell me any work around for this. ... (2 Replies)
Discussion started by: Ariean
2 Replies

5. Shell Programming and Scripting

Execution problem with repeat the same program with two set of same data

I got a program named as "fastq_to_fasta". I got a long list of file all named as AB1 and AB2. My input file is : 071022_L1_AB1.fq 012121_L1_AB1.fq 021213_L1_AB1.fq 012153_L1_AB1.fq 071022_L1_AB2.fq 012121_L1_AB2.fq 021213_L1_AB2.fq 012153_L1_AB2.fq . . . . . . My desired... (10 Replies)
Discussion started by: patrick87
10 Replies

6. Shell Programming and Scripting

User input for execution of script

Hi, I need to get the user input and execute a particular script based on the input provided. For E.g. When I execute the script say Test.sh it should prompt "For which country I need to execute the script? (US/India)" Based on the input as US or India from the user the execution of... (8 Replies)
Discussion started by: yoursdavinder
8 Replies

7. Shell Programming and Scripting

Problem while execution of second set of commands

Hi, I have a shell script with code . perf.env cd $QRY_DIR for SHELL_FILE in sql1 do export SNAME=$SHELL_FILE ${SCRIPT_DIR}/perf_qry.sh ${SPOOL_DIR} ${DB_ENVNAME} ${NAME} & RC=$(expr ${RC:-0} + $? ) sleep 60 if then echo sysdate>test1 echo query1.txt>>test1 grep -i... (6 Replies)
Discussion started by: ran16
6 Replies

8. Shell Programming and Scripting

Problem while execution of second set of commands

Hi, I have a shell script with code . perf.env cd $QRY_DIR for SHELL_FILE in sql1 do export SNAME=$SHELL_FILE ${SCRIPT_DIR}/perf_qry.sh ${SPOOL_DIR} ${DB_ENVNAME} ${NAME} & RC=$(expr ${RC:-0} + $? ) sleep 60 if then echo sysdate>test1 echo query1.txt>>test1 grep -i... (0 Replies)
Discussion started by: ran16
0 Replies

9. Shell Programming and Scripting

echo just 1 line before execution/set +-x

Suppose that you want to mostly not echo commands inside your script during execution (e.g. to not bog the user down with details that they do not care about) but that there is the occaisional script line that you would like to echo before you execute it. Is there an elegant way to achieve this?... (3 Replies)
Discussion started by: fabulous2
3 Replies

10. UNIX for Dummies Questions & Answers

Set User ID on execution mode.

I have a directory. To this directory, for Group bits combination, it is showing as 's'. Which I found out, it means "Set User ID on execution mode". Within this directory I am not able to create subfolder. Does it mean, only the Owner of this directory will be able to create subdirectories &... (5 Replies)
Discussion started by: videsh77
5 Replies
Login or Register to Ask a Question