1. 程式人生 > >解決 Mac OS X 10.11 安裝 sip 沒有權限的問題

解決 Mac OS X 10.11 安裝 sip 沒有權限的問題

python recommend ews 出現 party admin data- like 技術分享

在搭建 PYQT 的過程中我遇上了一個非常惡心的問題,在安裝 sip 的時候編譯源代碼之後的安裝過程中一直提示我:Operation not permitted ,我甚至重裝了系統也無濟於事,終於通過查資料攻克了問題。

安裝 sip

下載 sip 源代碼包解壓之後進入它的文件夾下:

python configure.py
sudo make
sudo make install

這時出現了一個非常惡心的報錯提示:

cp -f sip /System/Library/Frameworks/Python.framework/Versions/2.7
/bin/sip cp: /System/Library/Frameworks/Python.framework/Versions/2.7/bin/sip: Operation not permitted make[1]: *** [install] Error 1 make: *** [install] Error 2

於是乎,我用 su 登錄 Shell。在反復以上過程,無果。

之後,我又使用 brew install sip,報相同的錯誤。

然後我又進入 /System/Library/Frameworks/Python.framework 文件夾打算一探到底:

技術分享圖片

試圖改動它的權限。結果:

技術分享圖片

原因

經歷了XCode編譯器代碼被註入的事件後,這次 Mac OS X El Capitan系統的升級,啟用了更高的安全性保護機制:系統完整性保護System Integrity Protection (SIP)。簡單來講就是更加強制性的保護系統相關的文件夾。開發人員不能直接操作相關的文件內容。

蘋果官方給出的解釋:

System Integrity Protection is a security technology in OS X El Capitan that’s designed to help prevent potentially malicious software from modifying protected files and folders on your Mac.
In OS X, the “root” user account previously had no permission restrictions and could access any system folder or application on your Mac. Software gained root-level access when you entered your administrator name and password to install it and could then modify or overwrite any system file or application.
System Integrity Protection restricts the root account and limits the actions that the root user can perform on protected parts of OS X.
Paths and applications protected by System Integrity Protection include:
/System
/usr
/bin
/sbin
Apps that are pre-installed with OS X
Paths and applications that third-party apps and installers can write to include:
/Applications
/Library
/usr/local
System Integrity Protection is designed to allow modifications of these protected parts only by processes that are signed by Apple and have special entitlements to write to system files, like Apple software updates and Apple installers.
Apps that you download from the Mac App Store already work with System Integrity Protection. Other third-party software that conflicts with System Integrity Protection might be set aside when you upgrade to OS X El Capitan.
System Integrity Protection also helps prevent software from changing your startup volume. To boot your Mac from a different volume, you can use the Startup Disk pane in System Preferences or you can hold down the Option key while you reboot, and select a volume from the list.
Information about products not manufactured by Apple, or independent websites not controlled or tested by Apple, is provided without recommendation or endorsement. Apple assumes no responsibility with regard to the selection, performance, or use of third-party websites or products. Apple makes no representations regarding third-party website accuracy or reliability. Risks are inherent in the use of the Internet. Contact the vendor for additional information. Other company and product names may be trademarks of their respective owners.
https://support.apple.com/en-us/HT204899

解決方式

事實上解決方式就已經非常easy了,既然是系統中有 SIP 的問題,那麽我們把它關閉就好了:

  1. 重新啟動系統
  2. 按住 Command + R 進入 Recoverary 模式
  3. 點擊 有用工具 > 終端
  4. 輸入 csrutil disable
  5. 重新啟動系統

這時我們再又一次編譯安裝 sip 就沒有不論什麽問題了。

解決 Mac OS X 10.11 安裝 sip 沒有權限的問題