Cílem cvičení jsou speciální přístupová práva a
pokročilejší nastavení přístupových práv.
r/w/x
- základní práva (read, write, execute)s/s/t
- speciální práva (set-UID, set-GID, sticky)
~alias p='stat -Lc "%A [%a] %U/%G %n"'
~p /etc/passwd
-rw-r--r-- [644] root/sys /etc/passwd
~get_id() {
"$@" &>/dev/null &
ps -f -o ruser,ruid,user,uid,rgroup,rgid,group,gid,args -p $!
kill $! 2>/dev/null
}
~get_id sleep 10
[1] 1234
RUSER RUID USER UID RGROUP RGID GROUP GID COMMAND
barinkl 10001 barinkl 10001 zam 1002 zam 1002 sleep 10
~
[1]+ Terminated "$@" &>/dev/null
~ps -f
UID PID PPID C STIME TTY TIME CMD
barinkl 3310 3047 0 11:33:11 pts/1 0:00 ps -f
barinkl 3047 3046 0 10:49:32 pts/1 0:01 -bash
~get_id ls
RUSER RUID USER UID RGROUP RGID GROUP GID COMMAND
barinkl 10001 barinkl 10001 zam 1002 zam 1002 ls
~ls -ld ~ ~root
~ls ~ ~root
~p $(type -P vim passwd) /etc/passwd
-r-xr-xr-x [555] root/bin /usr/bin/vim
-r-sr-sr-x [6555] root/sys /usr/bin/passwd
-rw-r--r-- [644] root/sys /etc/passwd
~{ get_id vim; get_id passwd; } | sort -u
RUSER RUID USER UID RGROUP RGID GROUP GID COMMAND
barinkl 10001 root 0 zam 1002 sys 3 passwd
barinkl 10001 barinkl 10001 zam 1002 zam 1002 vim
~p public_html
drwsr-sr-x [6750] barinkl/www-data public_html
~id -a
uid=1000(barinkl) gid=1000(barinkl) groups=1000(barinkl),
24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),...
~touch public_html/file
~mkdir public_html/dir
~ls -la public_html
~mkdir dir
~cd dir
~/dirtouch file1
~/dirnewgrp docker
~/dirtouch file2
~/dirp . *
~/dirchgrp audio .
~/dirchmod ug+s .
~/dirtouch file3
~/dirmkdir dir
~/dirp . *
~p /tmp
drwxrwxrwt [1777] root/sys /tmp
~cd /tmp
~/tmpfind . -maxdepth 1 -user "$USER"
~/tmpfor i in *; do [ -O "$i" ] && p "$i"; done
~/tmpfor i in *; do [ -O "$i" ] && rm -ri "$i"; done
root
getfacl
a setfacl
~ls -ld
rwx------+ 49 barinkl zam 86 led 24 11:32 .
# UNIX (ne GNU implementace)
~/bin/find . -acl
# LINUX (GNU implementace)
~getfacl -Rs . 2>/dev/null | sed -n 's/^# file: //p'
~getfacl -a /var/log/journal 2>/dev/null
# file: var/log/journal
# owner: root
# group: systemd-journal
# flags: -s-
user::rwx
group::r-x
group:adm:r-x
mask::r-x
other::r-x
~p /var/log/journal
drwxr-sr-x [2755] root/systemd-journal /var/log/journal
~touch file
~ls -l file
~getfacl file
~setfacl --set u::rw-,u:www-data:r--,g::rw-,o::r-- file
~getfacl file
~setfacl -m u:www-data:rw-,g:www-data:r-- file
~getfacl file
~setfacl -m u:saned:rw-,u:colord:rw- file
~getfacl file
~touch file2
~getfacl file | setfacl -M- file2
~getfacl file*
~getfacl file* >acl
~rm file*; touch file file2
~setfacl --restore acl
~getfacl file*
~setfacl -x u:saned file2
~getfacl file2
~setfacl -b file2
~getfacl file2
~ls -l file2
~touch /var/tmp/file.$USER
~/bin/chmod A+user:muzikar:read_data/write_data/read_attri\
butes:file_inherit:allow /var/tmp/file.$USER
~/bin/ls -v /var/tmp/file.barinkl
-rw-------+ 1 barinkl zam 0 led 24 18:17 /var/tmp/xfile
0:user:muzikar:read_data/write_data/read_attributes:file_inherit:allow
1:owner@:read_data/write_data/append_data/read_xattr/write_xattr
/read_attributes/write_attributes/read_acl/write_acl/write_owner
/synchronize:allow
2:group@:read_xattr/read_attributes/read_acl/synchronize:allow
3:everyone@:read_xattr/read_attributes/read_acl/synchronize:allow
~/bin/ls -V /var/tmp/file.$USER
-rw-------+ 1 barinkl zam 0 led 24 18:17 /var/tmp/file.barinkl
user:muzikar:rw----a-------:f------:allow
owner@:rw-p--aARWcCos:-------:allow
group@:------a-R-c--s:-------:allow
everyone@:------a-R-c--s:-------:allow
~getfacl file2
~setfacl -m u:www-data:r-- file2
~getfacl file2
~setfacl -m u:www-data:rwx file2
~getfacl file2
~setfacl -m m::r-- file2
~getfacl file2
Bez masky/U,G,OG | S maskou/U,G,OG |
---|---|
vlastník ⇔ user:: | vlastník ⇔ user:: |
skupina ⇔ group:: | skupina ⇔ mask:: |
ostatní ⇔ other:: | ostatní ⇔ other:: |
chown g=...
při ACL ovlivňuje masku
~g() { getfacl "$@"; p "$@"; }; g file2
~chmod g+w file2; g file2
~chmod g-w file2; g file2
~setfacl -m m::rwx file2; g file2
~mkdir dir
~touch dir/a
~setfacl -m d:u:www-data:r-x dir
~setfacl -d -m u:www-data:r-x dir
~touch dir/b
~mkdir dir/subdir
~getfacl -Rs dir