Using the all_pre.sh script to do custom filtering on any function.


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


Top Level » DirectAdmin » Custom Scripting

Using the all_pre.sh script to do custom filtering on any function.Last Modified: Jun 10, 2008, 1:48 am
You can control what you want to allow or disallow at almost any level you wish using the script:
/usr/local/directadmin/scripts/custom/all_pre.sh
This script will be run before all /CMD accesses to DA.
If the script returns 0, the command is allowed.  Anything non-zero, the command is refused and the output from the script is shown to the user in DA.

For example, say we want to one particular domain from setting up an email account with a quota larger than 50 meg.  DA itself does not prevent this, but you can use the all_pre.sh to abort setting it before the command is executed in DA.

The code in the all_pre.sh for this example would be

#!/bin/sh

if [ "$command" = "/CMD_EMAIL_POP" ] && [ "$domain" = "thedomainyouwant.com" ]; then
    if [ "$action" = "create" ] || [ "$action" = "modify" ]; then
        if [ "$quota" -eq 0 ]; then
            echo "you cant have unlimited quota";
            exit 1;
        fi
        if [ "$quota" -gt 50 ]; then
            echo "you cant have more than a 50 meg quota";
            exit 2;
        fi
    fi
fi
exit 0;

Remember to chmod all_pre.sh to 755.

Now when a user tries to set the quota to 0 or anything higher than 50, he'll get an error preventing him from doing so.


This script/concept can be applied pretty much anywhere in DA (I can't think of any exceptions, other than HTM_ files)
Certain commands, like the filemanager for example, can be completely shut off for any user you want, or all users, or just users and not admins.. because you can code anything you want, your options are endless.
 
Related Helpfiles
Ability to limit the POST functions that an account can run.
How to setup a limit so that Users/Resellers cannot create more than 200 domains on a server.
How to prevent users from deleting certain files using the File Manager

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