個(gè)人博客地址
mac系統(tǒng)升級(jí)至12.0.1后,新建執(zhí)行腳本發(fā)現(xiàn)每次都提示
zsh: operation not permitted: ./xxx.sh
之前正常的腳本修改過(guò)后也變得無(wú)法執(zhí)行
hanchengxiao@hanchengxiaodeMacBook-Pro xxx % ls -ll
total 40
-rwxrwxrwx@ 1 hanchengxiao staff 94 11 5 11:11 xxx.sh
-rwxrwxrwx@ 1 hanchengxiao staff 223 11 5 10:52 xxx.sh
-rw-r--r--@ 1 hanchengxiao staff 1678 10 18 12:00 xxx.pem
-rwxrwxrwx@ 1 hanchengxiao staff 253 10 25 14:09 xxx.sh
-rwxrwxrwx@ 1 hanchengxiao staff 353 11 5 10:56 xxx.sh
發(fā)現(xiàn)權(quán)限似乎也沒(méi)什么問(wèn)題,可為什么變得不能執(zhí)行了呢
好奇心促使我進(jìn)一步探究@的隱藏內(nèi)容
hanchengxiao@hanchengxiaodeMacBook-Pro xxx % ls -ll@
total 40
-rwxrwxrwx@ 1 hanchengxiao staff 94 11 5 11:11 xxx.sh
com.apple.TextEncoding 15
com.apple.lastuseddate#PS 16
com.apple.macl 72
com.apple.metadata:kMDLabel_ovflhabut6jrmym5s5csdfq52e 89
↓↓↓↓↓↓↓↓↓↓注意這鬼東西↓↓↓↓↓↓↓↓↓↓↓
com.apple.quarantine 23
↑↑↑↑↑↑↑↑↑↑注意這鬼東西↑↑↑↑↑↑↑↑↑↑↑
-rwxrwxrwx@ 1 hanchengxiao staff 223 11 5 10:52 xxx.sh
com.apple.TextEncoding 15
com.apple.lastuseddate#PS 16
com.apple.macl 72
com.apple.metadata:kMDLabel_ovflhabut6jrmym5s5csdfq52e 89
-rw-r--r--@ 1 hanchengxiao staff 1678 10 18 12:00 xxx.pem
com.apple.TextEncoding 15
com.apple.lastuseddate#PS 16
com.apple.macl 72
com.apple.metadata:kMDLabel_ovflhabut6jrmym5s5csdfq52e 89
-rwxrwxrwx@ 1 hanchengxiao staff 253 10 25 14:09 xxx.sh
com.apple.TextEncoding 15
com.apple.lastuseddate#PS 16
com.apple.macl 72
com.apple.metadata:kMDLabel_ovflhabut6jrmym5s5csdfq52e 89
-rwxrwxrwx@ 1 hanchengxiao staff 353 11 5 10:56 xxx.sh
com.apple.TextEncoding 15
com.apple.lastuseddate#PS 16
com.apple.macl 72
com.apple.metadata:kMDLabel_ovflhabut6jrmym5s5csdfq52e 89
發(fā)現(xiàn)不能執(zhí)行的腳本比其他腳本多了一條屬性,雖然不知道這個(gè)屬性是做什么的但是不影響對(duì)它的好奇
百度得知
com.apple.quarantine 23
這個(gè)是mac的免疫隔離,系統(tǒng)根據(jù)這個(gè)附加屬性對(duì)這個(gè)文件作出限制
既然知道了問(wèn)題就好辦了
使用
sudo xattr -r -d com.apple.quarantine $filePath
將文件中的免疫隔離去除,再次執(zhí)行腳本,又可以愉快地執(zhí)行了