MacOS – Delete file without permission

macos

I need to prevent a Mac user from deleting some files, so my idea is disable the user to sudo to the root user. I tested it in Terminal, it's OK there:

dst49700:salt ttest$ ls -al /etc/salt/111 
-rw-------  1 root  wheel  0 Apr 20 16:54 /etc/salt/111
dst49700:salt ttest$ rm /etc/salt/111 
override rw-------  root/wheel for /etc/salt/111? y
rm: /etc/salt/111: Permission denied

The staff group's user ttest can not delete this file.

But it's very strange: when I tested it in Finder, I dragged it to the Trash, I needed to enter a password and after that, the file had been moved to Trash.

Why can I move it to Trash without permission? Nobody can delete it, except root, can somebody help me or tell me a better idea to prevent a user from deleting a file?

Best Answer

You did need permission — Finder asked you for your password and you provided it. That gave Finder permission to use root access to delete the file, because the staff group are in sudoers.