passwd命令讀取的shadow檔案沒有任何許可權,為什麼普通使用者可以正常登入

來源:互聯網
上載者:User

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   

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.