A little doubt regarding setgid and Unix access right flags.


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers A little doubt regarding setgid and Unix access right flags.
# 1  
Old 03-17-2010
A little doubt regarding setgid and Unix access right flags.

Hi all!

I have a folder with permissions 2770 (SETGID)

Code:
drwxrws---   2 loguser   admins            5 Mar 17 11:11 mydir

Inside that folder there are some files with permissions 0640:

Code:
-rw-r-----   1 loguser   admins            0 Mar 17 11:11 monday.log
-rw-r-----   1 loguser   admins            0 Mar 17 11:11 tuesday.log
-rw-r-----   1 loguser   admins            0 Mar 17 11:11 wednesday.log


"mike" is a member of the "admins" group.

When I login as mike, go through the above folder and try to delete a file it shows:

Code:
override protection 640 (yes/no)?

And if I input "yes" it will let me delete the file.

Why is it letting "mike" delete the file, even when the file uses "0640" (read-only for the group)

I hope you could help me clarify this. Smilie

Thanks.
# 2  
Old 03-17-2010
Because Mike has write permissions (2770) to the directory - being a member of the admins group. SETGIO really has nothing to do with it.

Code:
# useradd -d /home/test1 -g users -s $(which ksh) test1
# useradd -d /home/test2 -g users -s $(which ksh) test2
# su - test1

$ cd /home/test1
$ mkdir A
$ chmod 2777 A
$ touch A/1 A/2
$ exit

# su - test2

$ cd ~test1/A
$ ll
total 0
-rw-r--r-- 1 test1 users 0 Mar 17 05:43 1
-rw-r--r-- 1 test1 users 0 Mar 17 05:43 2

$ rm 1
rm: remove write-protected regular empty file `1'? y
$ ll
total 0
-rw-r--r-- 1 test1 users 0 Mar 17 05:43 2
$ exit

# su - test1

$ chmod 2755 A
$ exit

# su - test2
$ cd ~test1/A
$ rm 2
rm: remove write-protected regular empty file `2'? y
rm: cannot remove `2': Permission denied

# 3  
Old 03-17-2010
Wow, that really cleared my doubts. Thanks a lot.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Setuid and setgid and similar settings

so im writing a script for a android system. these types of systems are not the typical unix systems. what i need to do is basic. i have a script which I put in a directory and then zipped up the directory in a zip file. that way, when the script is unzipped, the person unzipping will see... (1 Reply)
Discussion started by: SkySmart
1 Replies

2. Shell Programming and Scripting

Basic doubt in UNIX

Hi, I'm new to this and very much interested to learn unix. Can any one explain me the symbols y we use this is scripting(~ and $). It would be great if some one explain with the eg. Thanks Naveen A (2 Replies)
Discussion started by: Pranaveen
2 Replies

3. UNIX for Dummies Questions & Answers

How can I re-enable the setuid or setgid bits ???

While I was looking for tips for hardening the security of my MAC OSX I found the following posting: "<How to disable Setuid and Setgid Binaries > Setuid programs run with the privileges of the file's owner (which is often root), no matter which user executes them. Bugs in these programs... (6 Replies)
Discussion started by: Vera
6 Replies

4. UNIX for Dummies Questions & Answers

Doubt in Unix ??

Is it possible to create unix or linux commands ? if it is then how to create ?:) (1 Reply)
Discussion started by: Santhosh Raju
1 Replies

5. Solaris

about setuid setgid permissions

hi.. why we go for setuid, setgid permissions? as a system admin ,when we use this ,except default solaris setuid,setgid files and dirs.. hopes that anyone can help me regarding this.. (1 Reply)
Discussion started by: saravananpalani
1 Replies

6. UNIX for Dummies Questions & Answers

int open(const char *pathname, int flags, mode_t mode) doubt...

hello everybody! I want to create a file with permissions for read, write, and execute to everybody using C, so I write this code: #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> int main(){ int fileDescriptor; fileDescriptor =... (2 Replies)
Discussion started by: csnmgeek
2 Replies

7. UNIX for Advanced & Expert Users

Unix Doubt

What is Primary Group & Secondary group and what is the difference between them. (5 Replies)
Discussion started by: harishankar
5 Replies

8. Programming

setgid

I have a setuid to root program that has now to be changed to setuid to oracle depending on who is running it. Oracle has only two groups, dba (primary) and osgrp1 (secondary). But running 'id' if oracle shows all the secondary groups belonging to root, and only dba or osgrp1 as the primary group... (2 Replies)
Discussion started by: blowtorch
2 Replies

9. Shell Programming and Scripting

flags to suppress column output, # of rows selected in db2 sql in UNIX

Hello, I am new to db2 SQL in unix so bear with me while I try to explain the situation. I have a text file that has the contents of the where condition that I am using for a db2 SQL in UNIX ksh. Here is the snippet. if ; then echo "Begin processing VALUEs" ... (1 Reply)
Discussion started by: jerardfjay
1 Replies

10. UNIX for Dummies Questions & Answers

Using setuid and setgid

Hi, I have been looking at setuid and setgid. I understand that setuid determines who owns the file and setgid determines which group of people can access the file... yeah?! But i need to know how to actually use setuid and setgid. I'm guessing chmod will feature somewhere.. Any help... (1 Reply)
Discussion started by: crispy
1 Replies
Login or Register to Ask a Question