GoAdmio Command Line: disablefunctions with /go/disablefunctions

/go/disablefunctions manages PHP's disable_functions setting, the list of PHP functions that scripts are not allowed to call. Blocking risky functions such as exec or shell_exec is a common way to limit the damage if a website is compromised. The command writes the same list into every php.ini it finds, for all installed PHP versions, and then schedules a PHP-FPM reload so the change takes effect. Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.

Quick start

# Show the current list
/go/disablefunctions return

# Set the list
/go/disablefunctions "exec,passthru,shell_exec,system,proc_open,popen"

# Clear the list (allows every function)
/go/disablefunctions

Arguments

Argument Required Notes
return No Prints the current list and changes nothing. Not case-sensitive.
<functions> No The functions to disable. Use one quoted, comma-separated argument, as in "exec,shell_exec". If you pass several separate arguments, they are joined with spaces.
(none) No Sets the list to empty, so no function is disabled.

The new list replaces the old one. It is not added to it. Run return first and copy the current list if you want to keep its entries.

Examples

# Save the current list, then replace it
/go/disablefunctions return > /root/disable_functions.bak
/go/disablefunctions "exec,passthru,shell_exec,system,proc_open,popen"

# Check the value that PHP on the command line is using
php -r 'echo ini_get("disable_functions"), PHP_EOL;'

# Compare the value in every php.ini
sudo grep -H '^disable_functions' /etc/php.ini /etc/opt/remi/*/php.ini 2>/dev/null

# Remove all restrictions
/go/disablefunctions

Output

When setting or clearing the list, the command prints nothing. If the at package has to be installed first, the package manager’s output is shown.

With return, it prints the current list on one line, for example:

exec,passthru,shell_exec,system

A blank line means no value is set. The command then exits with status 1, even though nothing went wrong.

Message Meaning
Unknown operating system. The OS is not AlmaLinux, Rocky, CentOS, Red Hat, Fedora, Debian, or Ubuntu. Nothing is changed.

See the full reference at /go/disablefunctions and the GoAdmio command index.

GoAdmio is free and open source, with no license fees and no account limits. Read the GoAdmio docs, or see why it is a free cPanel alternative at goadmio.com.

By:

Posted in:


Leave a Reply

Your email address will not be published. Required fields are marked *