pyth0n3 Posted May 19, 2011 Report Posted May 19, 2011 (edited) The linux ext* filesystem support some extra attributes for filesand directoriesThese attributes provide a range of additional capabilities that can beactivated for each file, some of them can only be set by the administrator,in particular those which allow special access restrictions.The command "ls" will display only the standard UNIX/LINUX style filepermissions, in this case the special attributes of the file can not bedisplayed with "ls" but this can be done using the "lsattr" command."lsattr" will list file attributes on a Unix / Linux system second extended filesystem (this means that not all file systems support this option, like i saidbefore the ext* has the support for extra flags )Example: [pyth0n3@mc:~]$ lsattr test------------------- testThe output shows us that no special attribute is set to the file "test"List of special attributes:"A" This will block the update time of the file, when a file with the 'A' attribute set is accessed, its atime record is not modified."a" This will permit to open the file only in append mode for writing,the current content can not be changedNote: Only the superuser can set or clear this attribute"c" The file using this attribute is automatically compressed on the disk bythe kernel .A read from this file returns uncompressed data ,awrite to this file compresses data before storing them on the disk."D" When a directory with this attribute set is modified the changesare written synchronously on the disk"d" The file using this attribute is not candidate for backup when thedump(8) program is run"E" Will report an error in compression if a compressed file has a compressionerror it is activatedNote : This will only work if the compression is activated"e" This attribute indicates that the file is using extents for mappingthe blocks on disk"I" is used by the htree code to indicate that a directory is being indexedusing hashed trees"h" This attribute indicates the file is storing its blocks in units ofthe filesystem blocksize instead of in units of sectors"i" A file using this attribute cannot be modified: it cannot be deletedor renamed, no link can be created to this file and no data can bewritten to the fileNote:The file using this attribute cannot be deleted even by the superuser, todo this the attribute must be removed firstOnly the superuser can set or clear this attribute."s" When a file using this attribute is deleted its blocks arezeroed and written back to the diskNote:This feature in some case could be important ,since by default the kernelwill simply mark the block as free but does not erase the contents"S" When a file with this attribute is modified the changes arewritten synchronously on the disk"u" When a file with this attribute set is deleted its contents aresaved. This allows the user to ask for its undeletion"X" It allows direct access to the contents of the compressed file bydisabling decompression (aw contents of a compressed file can be accesseddirectly)"Z" This attribute is used by the experimental compression patches toindicate a compressed file is dirtyThe command used to set special attributes is "chattr""chattr" takes as first argument a string that identifies whichattributes to enable or disable and subsequent arguments as a list of filesNote:The chattr command uses the logical operator "+" to enable the attribute,otherwise use the logical operator "-" to disable the attribute.Purpose:Set an immutable parameter to a file [root@mc:pyth0n3]# chattr +i testDisplay results:[root@mc:pyth0n3]# lsattr test----i-------------- testNow the file test cannot be changed or deleted even by the superuserTo do this the attribute must be removed first[root@mc:pyth0n3]# rm -rf testrm: cannot remove `test': Operation not permittedNote:To delete a file the "rm" command uses a system call called "unlink" and infact does not erase the data file ,it just simply delete the entry from thedirectory and decreases the reference number of the inodeTo delete files safely you should use another command like srmsecure remove (secure_deletion toolkit)References:man lsattr , man chattr Source:No Security: Advanced File Permissions (extended attributes) Edited May 19, 2011 by pyth0n3 1 Quote
Nytro Posted May 19, 2011 Report Posted May 19, 2011 Foarte util, mai ales acel atributele "a-c-i-s" Deci daca setez "+s", cand sterg un fisier, pe langa faptul ca va fi sters din ierarhia de fisiere, spatiul ocupat pe hard va fi setat la 0? Adica datele nu vor mai putea fi "recuperate". Quote
hammerfall Posted May 19, 2011 Report Posted May 19, 2011 @nytro, din cate am citit eu acolo, da, sterge toate blocurile de pe HDD si le supra scrie cu "gol". E misto ideea si cred ca deja i-am gasit utilitate. Avantajul de a lucra in interfata grafica a terminalului. Mersi de lista, bookmarked and learned. LE: +A inseamna ca daca eu editez un fisier, data nu i se modifica sau e valabil doar pentru accesare? Quote
Nytro Posted May 19, 2011 Report Posted May 19, 2011 nytro@rst:/tmp/test$ echo "Plm" > plmnytro@rst:/tmp/test$ lsplmnytro@rst:/tmp/test$ chattr +i plmchattr: Operation not permitted while setting flags on plmnytro@rst:/tmp/test$ suPassword: root@rst:/tmp/test# chattr +i plmroot@rst:/tmp/test# rm plmrm: cannot remove `plm': Operation not permittedroot@rst:/tmp/test# ls -latotal 12drwxr-xr-x 2 nytro nytro 4096 2011-05-20 01:18 .drwxrwxrwt 13 root root 4096 2011-05-20 01:17 ..-rw-r--r-- 1 nytro nytro 4 2011-05-20 01:18 plmroot@rst:/tmp/test# lsattr plm----i------------e- plmroot@rst:/tmp/test# chattr +A plmroot@rst:/tmp/test# lsattr plm----i--A---------e- plmroot@rst:/tmp/test# cat plmPlmroot@rst:/tmp/test# ls -latotal 16drwxr-xr-x 2 nytro nytro 4096 2011-05-20 01:20 .drwxrwxrwt 13 root root 4096 2011-05-20 01:20 ..-rw-r--r-- 1 nytro nytro 4 2011-05-20 01:18 plmroot@rst:/tmp/test# touch plmtouch: cannot touch `plm': Permission deniedroot@rst:/tmp/test# Pentru +A, nu se poate modifica data ultimei accesari.Si eu nu am "+XEZ"root@rst:/tmp/test# chattr +Z plmUsage: chattr [-RVf] [-+=AacDdeijsSu] [-v version] files...Dar imi place Quote
pyth0n3 Posted May 20, 2011 Author Report Posted May 20, 2011 din cate am citit eu acolo, da, sterge toate blocurile de pe HDD si le supra scrie cu "gol". E misto ideea si cred ca deja i-am gasit utilitate. Presupun ca te referi la atributul "s" , oricum p?rerea mea este ca in sistemele de fisiere care utilizeaz? o tehnologie numita journaling chiar daca vine setat asta nu inseamna ca fisierul pe care vrei sa il stergi o sa dispar? in mod definitiv In sistemele Unix/Linux pe lîng? permisiile ordinare exista diverse alte tipuri de permisii , unele le-am descris mai sus acestea pot fi activate doar in unele sisteme de fisiere cum ar fi ext*Permisiile ordinare vin grupate în blocuri de 3 bi?i în octal, pe langa acestea exista inca 3 permisii chemate speciale "suid" Cu acest atribut activat fisierul va rula cu drepturile user-ului a carui apartine Un exemplu este comand-ul "passwd" care permite modificarea password-ului oricarui user pe care il foloseste dar ruleaza cu drepturi administrative Atentie cum folositi acest atribut ."sgid" Cu acest atribut activat asupra unui director fi?ierele create vor mo?teni grupul directorului unde vin create in loc sa le fie atribuit grupul user-ului cu care vin create "sticky" Cu acest atribut activat asupra unui director , oricare fisier se afla in acest director poate fi sters doar de catre userul pe care l-a creat Un exemplu este directorul "tmp" , daca ii observati atent permisiile veti vedea un "t" Toate permisiile specificate in acest tutorial fac parte dintrun Access Control numit DAC (Discretionary access control) care vine de default cu majoritatea sistemelor Unix/LinuxEste un sistem simplu, traditional , root nu are nici un fel de restric?ie Deci kernelul identifica fiecare user in baza UID , daca e divers de 0 vine supus la restric?iile care vin impuse daca nu inseamna ca userul e root si nu vine supus la nici un fel de restrictie Mai simplu explicat: Daca UID = null nu vine efectuat nici un fel de control (asta inseamna ca userul e root)De aceea DAC vine considerat un sistem de acces simplu Daca un intrus obtine root face ce vrea el Un alt tip de Access Control vine numit MAC (Mandatory Access Control) , pe aceasta baza a fost construit un modul chemat Selinux care permite restrictii mult mai complicate Se poate restrictiona access-ul si pentru user-ul root in multe locuri Mandatory Access Control este un sistem complex care merita studiat , iar acest topic estre prea mic pentru a explica fiecare feature Pentru cei care cunosc SELINUX stiu foarte bine despre ce vorbesc Apropo , vine implementat de default cu optiunea enforcing in sistemele RedHat based Un alt tip de restrictii MAC se pot gasi in sistemele SUSE Linux (AppArmor)Pentru a intelege diferentele intre DAC si MAC uitati-va peste urmatoarele link-uri Discretionary access control - Wikipedia, the free encyclopediaMandatory access control - Wikipedia, the free encyclopedia Quote