3
我創建了這個簡單的腳本,允許用戶刪除由他的主目錄中的Web服務器創建的文件,而不給他「su」。這兩個腳本都設置爲"chmod 4750"。爲什麼我的setuid root bash shell腳本不起作用?
最瘋狂的是他們DID工作,現在他們沒有。這裏的腳本:
#!/bin/bash
# Ask for directory to delete
echo "Enter the file or directory you would like to delete, the assumed path is /home/user"
read DIRECTORY
rm -rf /home/user/"$DIRECTORY"
echo "Deleting /home/user/$DIRECTORY ..."
exit 0
2:
#!/bin/bash
# Reset permissions
echo "Resetting the ownership of the contents of /home/user to user."
chown -R user /home/user
exit 0
我會讓他們更先進一點的工作,併爲多個用戶,但現在我甚至不能簡單的版本工作。它當然是以root身份運行的。它以用戶'用戶'身份運行時用於工作,但現在不行。我得到這個:
[email protected]:/home/user$ delete.sh
Enter the file or directory you would like to delete, the assumed path is /home/user/[your input]
test-dir
rm: cannot remove ‘/home/user/test-dir/test-file’: Permission denied
Deleting /home/user/test-dir ...
和
chown: changing ownership of ‘/home/user/test-dir’: Operation not permitted
什麼都不可能是問題?
-rwsr-x--- 1 root user 291 Nov 6 05:23 delete.sh
-rwsr-x--- 1 root user 177 Nov 6 05:45 perms.sh
檢查SUID是否可以在腳本中添加:'echo whoami'輸出root? 。 – Noproblem
作爲一項安全措施,大多數系統不允許使用shell腳本。不知道他們爲什麼過去工作。 – chepner
奇怪的是,它今天早些時候在同一個系統上工作。我不知道我改變了什麼或者改變了什麼。我會試試這個。 – Bob