Disable OS X System Integrity Protection
不过今天要 fix 的是这个叫做 System Integrity Protection (SIP) 的东西,又叫 rootless,总之就是保护系统了。听上去感觉很有用的样子,似乎确实也很有用,不过刚出来的时候好像导致 homebrew 出了很多问题,然后最近由于 DYLD_LIBRARY_PATH
的问题终于忍无可忍决定要把它 disable 掉。
对 Linux 编程熟悉的同学应该都知道 LD_LIBRARY_PATH
,就是可以设置一些搜寻动态链接库的路径,通常安装一些第三方的库,如果不是直接安装到系统的 /usr/lib
之类的路径下面去(比如没有 root 权限,或者不想污染系统)的话,就可以把任意的路径加到 LD_LIBRARY_PATH
里去,让其他的程序还是可以找得到这个第三方库的 shared library。而 DYLD_LIBRARY_PATH
就是 OS X 的 LD_LIBRARY_PATH
对应物(好像直接用 LD_LIBRARY_PATH
也可以)。
然后现在 SIP 为了"安全起见",把 LD_LIBRARY_PATH
和所有 DYLD_
开头的环境变量全部禁用了。症状就是一个程序在启动一个子进程的时候,是会继承父进程的环境变量的,但是环境变量里的这几个项会被系统给屏蔽掉。我也不知道为什么这个会破坏系统安全,但是确实这样之后带来各种各样的麻烦,比如在 iPython 里要是用到 CUDA 的库之类的,就会找不到 shared library。如果想用 lldb
去调试一个依赖于一些第三方动态库的程序,或者用 Makefile
来启动一些 tests,也会发现找不到这些动态链接库。之前找到一个临时的解决办法是先用 otool -L
来列出你编译出来的程序依赖于哪些未 resolve 的动态链接库,比如这样的:
your-program-file
Read full article from Disable OS X System Integrity Protection
No comments:
Post a Comment