在 OS X 上修复 /bin/executable

Fixing /bin/executable on OS X

我相信 "brew update" 毁了我的 /bin/zipalign - 从那以后它就不再 运行 了。该盒子位于远程位置(10 小时时区差异,在服务器盒子中,因此我无法物理访问以推送 cmd+r)。我可以 sudo 但这并不能解决问题。

我该如何解决?

$ /bin/zipalign
dyld: warning, LC_RPATH @loader_path/../lib in /bin/zipalign being ignored in restricted program because of @loader_path
dyld: warning, LC_RPATH @loader_path/lib in /bin/zipalign being ignored in restricted program because of @loader_path
dyld: Library not loaded: @rpath/libc++.dylib
  Referenced from: /bin/zipalign
  Reason: image not found
Trace/BPT trap: 5

$ /Users/myuser/Library/Android/sdk/build-tools/23.0.1/zipalign
Zip alignment utility
Copyright (C) 2009 The Android Open Source Project
...
* So that works; I would like to have the that in /bin/zipalign; I though creating a symlink.

$ sudo rm -rf /bin/zipalign
rm: /bin/zipalign: Operation not permitted

$ otool -L /bin/zipalign
/bin/zipalign:
    @rpath/libc++.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)

$ sudo install_name_tool -change @rpath/libc++.dylib /share/android/build-tools/23.0.1/lib/libc++.dylib /bin/zipalign
error: 
install_name_tool: can't open input file: /bin/zipalign for writing (Operation not permitted)

$ sudo csrutil disable
csrutil: failed to modify system integrity configuration. This tool needs to be executed from the Recovery OS.

这是一个Jenkins slave, access: ssh only, sudo, cannot touch the real keyboard, 怎么解决?

因为它变成了解决方案:将文件复制到 /usr/bin 并确保它的优先级高于 /bin 然后拙劣的应用程序将不会 运行.