我想允許用戶執行包含敏感數據的bash腳本。因此,我不希望他們擁有閱讀權限。 「直接」的解決方案seems to be impossible,但我可能已經找到了解決辦法在expect man page:無需讀取權限即可執行腳本
Create the Expect script (that contains the secret data) as usual. Make its permissions be 750 (-rwxr-x---) and owned by a trusted group, i.e., a group which is allowed to read it. If necessary, create a new group for this purpose. Next, create a /bin/sh script with permissions 2751 (-rwxr-s--x) owned by the same group as before.
我試圖複製這一如下: 在一個文件夾中,我有兩個腳本:
腳本.SH:
#!/bin/sh
echo "targetscript echo"
runscript.sh:
#!/bin/sh
echo "runscript echo"
groups
./script.sh
我給他們的建議在手冊頁的權利:
groupadd scriptrunner
chown {myusername}:scriptrunner runscript.sh
chmod 2751 runscript.sh
chown root:scriptrunner script.sh
chmod 750 script.sh
的ls -l
輸出似乎是好的:
-rwxr-s--x. 1 {myusername} scriptrunner 51 Aug 25 13:04 runscript.sh
-rwxr-x---. 1 root scriptrunner 35 Aug 25 13:01 script.sh
然而,當我沒有root運行./runscript.sh
,我得到以下錯誤:
runscript echo
{myusername} wheel
./runscript.sh: line 4: ./script.sh: Permission denied
我不知道出了什麼問題。誰能幫我?
用戶是否將腳本執行爲「scriptrunner」組的成員? –
如果存在敏感數據,那麼它應該被加密 - 即使您成功運行沒有讀取權限的腳本或將其轉換爲可執行二進制文件(ELF)。任何使用運行該進程的相同用戶名的人都可以使用類似'truss','strace'或'ptrace'的工具查看數據。可能的解決方法是對運行在另一個用戶名下的守護進程運行請求。 – cdarke