How to prevent users from deleting certain files using the File Manager


Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"


Top Level » DirectAdmin » Custom Scripting

How to prevent users from deleting certain files using the File ManagerLast Modified: Aug 20, 2018, 7:09 am
Since Users often delete things they shouldn't, it may be wise to prevent them from deleting things they shouldn't.
In this example, we'll block them from deleting their /public_html symbolic link using the filemanager.

First, edit the following script which will be doing the work for us:
/usr/local/directadmin/scripts/custom/all_pre.sh

Inside this new script, add the code:

#!/bin/sh
if [ "${command}" = "/CMD_FILE_MANAGER/" ] || [ "${command}" = "/CMD_FILE_MANAGER" ]; then
   if [ "${button}" = "delete" ]; then
       if env|grep -m1 -q '=/public_html$'; then
           echo "You cannot delete your public_html link!"
           exit 1
       fi
   fi
fi
exit 0

save the changed.  Chmod the all_pre.sh to 755 and test it out.

You can all more paths for them not to delete, by adding another if statement after the check for public_html.
 
Related Helpfiles
Ability to limit the POST functions that an account can run.
Using the all_pre.sh script to do custom filtering on any function.
How to setup a limit so that Users/Resellers cannot create more than 200 domains on a server.

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST