Script without read permission but execute the script


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Script without read permission but execute the script
# 8  
Old 01-06-2009
though the user is guest here - its running as root

which means read permission is inevitable, only when it can read it can execute
# 9  
Old 01-07-2009
Your statement is incorrect. The script is running as a different user, jlliagre here, not root.
The guest user is still unable to read the script he runs with the solution I suggest.

Code:
# cat hi.ksh
#!/bin/ksh -p
echo hello
id
# su - guest
$ /var/tmp/hi.ksh
hello
uid=10000(guest) gid=10000(guest) euid=20000(jlliagre)
$ cat /var/tmp/hi.ksh
cat: /var/tmp/hi.ksh: cannot open [permission denied]


Last edited by jlliagre; 01-07-2009 at 06:55 AM..
# 10  
Old 01-07-2009
Quote:
Originally Posted by jlliagre
It is possible by using the suid bit.
That might work - there is just one problem, though: scripts are NOT allowed to run suid, on no Unix platform. The reason is security.

I hope this helps.

bakunin
# 11  
Old 01-07-2009
Do you mean Solaris isn't a Unix platform or are you talking about security best practices ?
# 12  
Old 01-08-2009
It is not working.
Example

kganeshb@its04489:~/scripts $ cat ex.sh
#!/bin/ksh -p
echo hello
kganeshb@its04489:~/scripts $ sh ex.sh
hello
Different user
eravich1@its04489:/home/kganeshb/scripts $ ls -l ex.sh
-rws--x--x 1 kganeshb users 25 Jan 8 15:14 ex.sh
eravich1@its04489:/home/kganeshb/scripts $ ./ex.sh
/bin/ksh: ./ex.sh: Permission denied
eravich1@its04489:/home/kganeshb/scripts $ sh ex.sh
ex.sh: ex.sh: Permission denied
eravich1@its04489:/home/kganeshb/scripts $ cat ex.sh
cat: ex.sh: Permission denied
# 13  
Old 01-08-2009
Oh, it's my fault.

Script is really not working without r. But binary file can be executed without only x.

At the first time, I tried by a binary file, which results a wrong conclusion. sorry.
# 14  
Old 01-08-2009
Kingganesh04, it would help if you tell what Unix variant you are using.

While many Unix OSes will ignore suid scripts, my example certainly works under Solaris and possibly under other Unix implementations.

Although root suid scripts are certainly risky and a bad security practice, I don't see that much a risk suid'ing to another non privileged user like I show.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find list of files missing read & execute permission

Hi, I'm writing a post-upgrade script and I want to find which files don't have read and execute to everyone. I can run a find . ! -perm, but then I have to use a list of the possible permissions (777,775, 755 etc). Is there a more elegant solution? Thanks (2 Replies)
Discussion started by: Catullus
2 Replies

2. Shell Programming and Scripting

Batch script to execute shell script in UNIX server

Hi team, My requirement is to transfer pdf files from windows machine to unix server and then from that unix server we should sftp to another server. I have completed the first part i.e From windows to using to unix server with the help of psftp.exe code: psftp user@host -pw password <... (1 Reply)
Discussion started by: bhupeshchavan
1 Replies

3. Shell Programming and Scripting

Execute permission for shell script

Hi All, I am not able to figure out what is the problem with calling a shell script within a shell script. i have given all the permissions to both schell scripts. but when i am seeing the log file error is coming like weekly_us_push_rpts_tst.sh: ./vacation_quota_summary_detail.sh: Execute... (9 Replies)
Discussion started by: krupasindhu18
9 Replies

4. UNIX for Advanced & Expert Users

Allow user without dir write permission to execute a script that creates files

In our project we have several unix scripts that trigger different processes. These scripts write logs to a particular folder 'sesslogs', create output data files in a separate directory called 'datafiles' etc. Usually L1 support team re-run these scripts . We donot want L1 support team to have... (14 Replies)
Discussion started by: waavman
14 Replies

5. Solaris

Script running even after execute permission removed.

Hi All, I'm new to solaris and this site but the advices in this site have helped me a lot. Today i am facing a new issue. We have a script for BMCDashboard and this script is not supposed to run evrytime the server is booted so we disabled the services and removed the execute... (7 Replies)
Discussion started by: Rockyc3400
7 Replies

6. Shell Programming and Scripting

perl script to check read/write/execute permission for 'others'

I want to check access rights permissions not for 'user', not for 'group', but for 'others'. I want to do it by system command in which i want to use 'ls -l' and 'awk' command. I have written the following program : #!/usr/bin/local/perl #include <stdlib.h> system ("ls -l | awk... (1 Reply)
Discussion started by: shubhamsachdeva
1 Replies

7. Programming

CGI Perl script to execute bash script- unable to create folder

Hi I have a bash script which takes parameters sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash I have... (0 Replies)
Discussion started by: rakeshkumar
0 Replies

8. Shell Programming and Scripting

Dos batch script to execute unix shell script

Can anyone help me with a dos batch script to execute a shell script residing in an unix server. I am not able to use ssh. Thanks in advance (2 Replies)
Discussion started by: Shri123
2 Replies

9. Shell Programming and Scripting

Execute unix shell script to text file using the script

Hi all, I am beginner in UNIX...I want to use unix shell script to create text.file...I know how to use using by command...can anybody tell me for the script? Thanks i changed the threads title from "tex file" to "text file", because "tex" would probably be misunderstood as reference to... (4 Replies)
Discussion started by: mastercar
4 Replies

10. Shell Programming and Scripting

How to execute a script without giving x permission to the file?

How to execute a script with out giving x permission to the file? (7 Replies)
Discussion started by: praveen_b744
7 Replies
Login or Register to Ask a Question