Sponsored Content
Full Discussion: File Permission
Top Forums UNIX for Advanced & Expert Users File Permission Post 18555 by halfling on Friday 29th of March 2002 06:33:32 PM
Old 03-29-2002
Quote:
No Unix that I know of will execute a shell script setuid, even if the setuid bit is on.
Here's an example. Script A and script B. Script A is set with 4755 "root : other" permissions, script B is set with 100 "root : other" permissions:

-rwsr-xr-x 1 root other 123 Mar 29 15:19 a
---x------ 1 root other 119 Mar 29 15:19 b

Script A is as follows:

#!/bin/ksh
echo "\nIn A"
echo "id --- \c"
id
echo "whoami --- \c"
/usr/ucb/whoami
echo "who am i --- \c"
who am i
./b

Last line, you'll see that A calls B.

Script B is as follows:

#!/bin/ksh
echo "\nin B"
echo "id --- \c"
id
echo "whoami --- \c"
/usr/ucb/whoami
echo "who am i --- \c"
who am i

Changing to login testme and attempting to run B:

$ ./b
ksh: ./b: cannot execute
$

And running A:

$ ./a

In A
id --- uid=100(testme) gid=20(testme) euid=0(root)
whoami --- root
who am i --- root pts/7 Mar 29 15:10 (machine hidden)

in B
id --- uid=100(testme) gid=20(testme) euid=0(root)
whoami --- root
who am i --- root pts/7 Mar 29 15:10 (machine name)
$

Fairly simple and quick test to setup Smilie. Notice the effective uid and read uid are different.

Glad you got your script working...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

The file permission

I have a file ( /tmp/file.txt ) , the file owner is user1:edp , the permission is 644 , I want everyone can overwrite the file but don't change the file owner and permssion , could suggest what can I do ? thx (2 Replies)
Discussion started by: ust
2 Replies

2. Shell Programming and Scripting

The file permission

there is a directory eg. /home/edp/ , all the files under this directory : 1. the file and directory owner is "user1" , 2. the permission is 644 I want everyone hv permission to overwrite all files and write a new file to it , but I want the file owner and permssion keep unchange , could... (1 Reply)
Discussion started by: ust
1 Replies

3. Solaris

File permission

Hi Folks I have a file with the following permission. -r-sr-lr-- 1 apps appsgp 7612 Dec 19 2001 startup Any idea what is the in the group means? In my mind I believe I need to be root to set l in the group. Am I right? I don't have root access now. When I (as apps) a chmod... (2 Replies)
Discussion started by: hlee411
2 Replies

4. UNIX for Dummies Questions & Answers

File Permission

Hi, When I listed one directory in Sun, it showed that : -rwsr-xr-x 1 root bsmbin 78004 Oct 21 2004 bsmprsm I don't know meaning of the character "s" in "rws" above. I have searched in Sun admin documents but no result. Would you please explain it ? :) Thank you so much. (1 Reply)
Discussion started by: msg098
1 Replies

5. Cybersecurity

file permission/acl: 2 users with write access on 1 file...

Hello, i need some help/advice on how to solve a particular problem. these are the users: |name | group | ---------- --------------- |boss | department1 | |assistant | department1 | |employee | department1 | |spy | department2 | this is the... (0 Replies)
Discussion started by: elzalem
0 Replies

6. Solaris

file permission

hi frnds can u explain /etc/shadow file have read and write permissions for root only but while normal user changes his passwd it also updated in that file whats the logic behind that. (2 Replies)
Discussion started by: sravan ega
2 Replies

7. Shell Programming and Scripting

file permission

Hi All, https://www.unix.com/unix-advanced-expert-users/105758-chmod-parent-sub-directories.html I have to change permission for the directories and subdirectories in single command when googled i found some updates but i understand what is switch. If there is a command please... (2 Replies)
Discussion started by: thelakbe
2 Replies

8. Shell Programming and Scripting

File permission

I have an application with the user mark and another user james is trying to run the application and ending up with file permission issues. The user mark has set the umask as 002, I wanted to have a setting so that anyone can run the application without any file permission issues. Can anyone... (2 Replies)
Discussion started by: Muthuraj K
2 Replies

9. Ubuntu

File permission

Hi Friends, I want to create one user on my server in such a way that when he logged in by ssh on server,he can able to access ONLY /var/www/drupal-6.2 this directory. Please tell me how should i do that. (4 Replies)
Discussion started by: paragnehete
4 Replies

10. Shell Programming and Scripting

MV file with other permission

Hello All I have a file with rw-rw-r permission I need to mv the file into different directory (dir has rwx-rwx-rwx permission) with an others permission The application which is moving the file falls in other group I am getting the error mv cannot renamed permission denied ... (12 Replies)
Discussion started by: Pratik4891
12 Replies
SETUID(1)						      General Commands Manual							 SETUID(1)

NAME
setuid - run a command with a different uid. SYNOPSIS
setuid username|uid command [ args ] DESCRIPTION
Setuid changes user id, then executes the specified command. Unlike some versions of su(1), this program doesn't ever ask for a password when executed with effective uid=root. This program doesn't change the environment; it only changes the uid and then uses execvp() to find the command in the path, and execute it. (If the command is a script, execvp() passes the command name to /bin/sh for processing.) For example, setuid some_user $SHELL can be used to start a shell running as another user. Setuid is useful inside scripts that are being run by a setuid-root user -- such as a script invoked with super, so that the script can execute some commands using the uid of the original user, instead of root. This allows unsafe commands (such as editors and pagers) to be used in a non-root mode inside a super script. For example, an operator with permission to modify a certain protected_file could use a super command that simply does: cp protected_file temp_file setuid $ORIG_USER ${EDITOR:-/bin/vi} temp_file cp temp_file protected_file (Note: don't use this example directly. If the temp_file can somehow be replaced by another user, as might be the case if it's kept in a temporary directory, there will be a race condition in the time between editing the temporary file and copying it back to the protected file.) AUTHOR
Will Deich local SETUID(1)
All times are GMT -4. The time now is 12:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy