set-GID for collaboration sticky bit
additional permission
SGID - group ownership of directory is inherited to items created inside
sticky bit - user can delete only file created by himself or user is owner of directory
with sticky bit you can remove file if you are
a) owner of directory
b) owner of file
===========
usermod lisa -aG sales
usermod lisa -G sales - will override secondary group assignments
===========
[root@localhost test]# chmod g+s sales/
[root@localhost test]# ls -lart
total 4
dr-xr-xr-x. 25 root root 4096 Oct 14 16:34 ..
drwxr-xr-x. 3 root root 19 Oct 15 09:29 .
drwxrws---. 2 root sales 48 Oct 15 09:32 sales
[root@localhost test]#
[linda@localhost sales]$ su - lisa
Password:
[lisa@localhost ~]$ cd /test/sales/
[lisa@localhost sales]$ rm -f linda*
[lisa@localhost sales]$ ls -lart
total 0
drwxr-xr-x. 3 root root 19 Oct 15 09:29 ..
-rw-r--r--. 1 root sales 0 Oct 15 09:34 root1
drwxrws---. 2 root sales 19 Oct 15 09:38 .
[lisa@localhost sales]$
=============
in order to prevent delete linda's files by lisa, we need sticky bit
=============
[root@localhost sales]# chmod +t .
[root@localhost sales]# ls -lartd
drwxrws--T. 2 root sales 19 Oct 15 09:38 .
[root@localhost sales]#
- set user id
- set group id
- sticky bit
SGID - group ownership of directory is inherited to items created inside
sticky bit - user can delete only file created by himself or user is owner of directory
with sticky bit you can remove file if you are
a) owner of directory
b) owner of file
===========
usermod lisa -aG sales
usermod lisa -G sales - will override secondary group assignments
===========
[linda@localhost sales]$ ls -lart
total 0
drwxr-xr-x. 3 root root 19 Oct 15 09:29 ..
-rw-rw-r--. 1 linda linda 0 Oct 15 09:32 linda1
-rw-rw-r--. 1 linda linda 0 Oct 15 09:32 linda3
-rw-rw-r--. 1 linda linda 0 Oct 15 09:32 linda2
drwxrwx---. 2 root sales 48 Oct 15 09:32 .
[linda@localhost sales]$
===========
user lisa from the same group sales cannot modify files created by user linda===========
[root@localhost test]# chmod g+s sales/
[root@localhost test]# ls -lart
total 4
dr-xr-xr-x. 25 root root 4096 Oct 14 16:34 ..
drwxr-xr-x. 3 root root 19 Oct 15 09:29 .
drwxrws---. 2 root sales 48 Oct 15 09:32 sales
[root@localhost test]#
============
[root@localhost test]# cd sales/;touch root{1..2}
[root@localhost sales]# ls -lart
total 0
drwxr-xr-x. 3 root root 19 Oct 15 09:29 ..
-rw-rw-r--. 1 linda linda 0 Oct 15 09:32 linda1
-rw-rw-r--. 1 linda linda 0 Oct 15 09:32 linda3
-rw-rw-r--. 1 linda linda 0 Oct 15 09:32 linda2
-rw-r--r--. 1 root sales 0 Oct 15 09:34 root2
-rw-r--r--. 1 root sales 0 Oct 15 09:34 root1
drwxrws---. 2 root sales 74 Oct 15 09:34 .
[root@localhost sales]#
=============
[root@localhost sales]# su - linda
Last login: Sun Oct 15 09:31:44 EDT 2017 on pts/0
[linda@localhost ~]$ cd /test/sales/
[linda@localhost sales]$ touch linda4
[linda@localhost sales]$ ls -lart
total 0
drwxr-xr-x. 3 root root 19 Oct 15 09:29 ..
-rw-rw-r--. 1 linda linda 0 Oct 15 09:32 linda1
-rw-rw-r--. 1 linda linda 0 Oct 15 09:32 linda3
-rw-rw-r--. 1 linda linda 0 Oct 15 09:32 linda2
-rw-r--r--. 1 root sales 0 Oct 15 09:34 root1
-rw-rw-r--. 1 linda sales 0 Oct 15 09:37 linda4
drwxrws---. 2 root sales 75 Oct 15 09:37 .
[linda@localhost sales]$ ls -d
.
[linda@localhost sales]$ ls -ladrt
drwxrws---. 2 root sales 75 Oct 15 09:37 .
[linda@localhost sales]$
=============
lisa can delete linda's files because lisa is member of group sales which has write permissions on directory
Password:
[lisa@localhost ~]$ cd /test/sales/
[lisa@localhost sales]$ rm -f linda*
[lisa@localhost sales]$ ls -lart
total 0
drwxr-xr-x. 3 root root 19 Oct 15 09:29 ..
-rw-r--r--. 1 root sales 0 Oct 15 09:34 root1
drwxrws---. 2 root sales 19 Oct 15 09:38 .
[lisa@localhost sales]$
=============
in order to prevent delete linda's files by lisa, we need sticky bit
=============
[root@localhost sales]# chmod +t .
[root@localhost sales]# ls -lartd
drwxrws--T. 2 root sales 19 Oct 15 09:38 .
[root@localhost sales]#
owner of the sales directory is root, not sales group
[lisa@localhost sales]$ echo text >> linda1
[lisa@localhost sales]$ cat linda1
text
[lisa@localhost sales]$ rm -f linda1
rm: cannot remove ‘linda1’: Operation not permitted
Comments
Post a Comment