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