歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> passwd命令讀取的shadow文件沒有任何權限,為什麼普通用戶可以正常登錄

passwd命令讀取的shadow文件沒有任何權限,為什麼普通用戶可以正常登錄

日期:2017/3/1 15:36:28   编辑:關於Linux
passwd命令讀取的shadow文件沒有任何權限,為什麼普通用戶可以正常登錄 我們可以看到密碼文件沒有任何權限,用戶登錄時要需要讀取密碼文件,如果正確是怎樣通過驗證的呢? [plain] [root@serv01 learning]# ls /etc/shadow -l ----------. 1 root root 1155 Sep 20 22:11/etc/shadow 因為該文件具有s屬性。s:s針對命令,對與普通文件或者目錄沒有任何意義,特權位,命令執行的一瞬間具有root權限 [plain] [root@serv01 learning]# ls /etc/shadow -l ----------. 1 root root 1155 Sep 20 22:11/etc/shadow [root@serv01 learning]# which passwd /usr/bin/passwd [root@serv01 learning]# ls -l/usr/bin/passwd -rwsr-xr-x. 1 root root 25336 Jan 29 2010 /usr/bin/passwd 演示修改vim的權限,可以打開任何文件在任何地方修改文件 [plain] [root@serv01 learning]# which vim /usr/bin/vim [root@serv01 learning]# ls -l /usr/bin/vim -rwxr-xr-x. 1 root root 1933032 Feb 15 2011 /usr/bin/vim [root@serv01 learning]# chmod u+s/usr/bin/vim [root@serv01 learning]# ls -l /usr/bin/vim -rwsr-xr-x. 1 root root 1933032 Feb 15 2011 /usr/bin/vim 第一步 在當前目錄創建文件 [plain] [zhink@serv01 bbbb]$ vim file 第二步 查看文件的信息 [plain] [zhink@serv01 bbbb]$ ls -l file -rw-rw-r--. 1 root zhink 6 Sep 20 23:17file 第三步 在root的根目錄下創建文件,可以看到文件所有者時root [plain] [zhink@serv01 bbbb]$ vim /root/test.txt 第四步 查看test.txt的權限,可以看到文件所有者是root [plain] [root@serv01 learning]# ls /root/test.txt-l -rw-rw-r--. 1 root zhink 12 Sep 20 23:17/root/test.txt [root@serv01 learning]# cat bbbb/file hello [root@serv01 learning]# cat /root/test.txt hello,world 第五步 此時編輯shadow文件也可以 [plain] [zhink@serv01 bbbb]$ vim /etc/shadow #為了系統的安全性,還原vim命令的權限 [root@serv01 learning]# chmod u-s /usr/bin/vim [root@serv01 learning]# ls /usr/bin/vim -l -rwxr-xr-x. 1 root root 1933032 Feb 15 2011 /usr/bin/vim 第六步 還原vim的屬性,再次查看密碼文件,發現看不到內容 [plain] [zhink@serv01 bbbb]$ vim /etc/shadow 第七步 g+s後的實驗 [plain] #目錄繼承s,文件繼承w [root@serv01 learning]# chmod g+s cccc/ [root@serv01 learning]# cd cccc/ [root@serv01 cccc]# chmod g+w ../cccc/ [root@serv01 cccc]# mkdir oooo [zhink@serv01 cccc]$ ll total 8 drwxrwsr-x. 2 zhink root 4096 Sep 20 23:29ffff -rw-rw-r--. 1 zhink root 0 Sep 20 23:30 file drwxr-sr-x. 2 root root 4096 Sep 20 23:26 oooo
Copyright © Linux教程網 All Rights Reserved