Viewing File: /usr/local/cpanel/whostmgr/docroot/cgi/imunify/handlers/Imunify/Acls.pm

package Imunify::Acls;

use Whostmgr::ACLS();

sub checkPermission
{
    if (_isAdmin()
        || (_isReseller()  && _isAvailablePluginForReseller())
    ) {
        return 1;
    }
    return 0;
}

sub _getUser {
    return $ENV{'REMOTE_USER'};
}

sub _isAdmin
{
    if (Whostmgr::ACLS::hasroot()) {
        return 1;
    }
    return 0;
}

sub _isReseller
{
    my $RESELLER_LIST_FILE = '/var/cpanel/resellers';
    my $result = 0;
    if (-e $RESELLER_LIST_FILE) {
        open my $f, $RESELLER_LIST_FILE or die "Could not open $RESELLER_LIST_FILE: $!";

        while( my $line = <$f>)  {
            my @data = split /:/, $line;
            if (_getUser() eq $data[0]) {
                $result = 1;
                last;
            }
        }
        close $f;
    }
    return $result;
}

sub _isAvailablePluginForReseller
{
    if (Whostmgr::ACLS::checkacl('software-imunify360') ) {
        return 1;
    }
    return 0;
}

# Treat the caller as the Imunify admin if WHM ACLs put them at root, OR
# if the hoster has opted resellers back into the admin SPA via the
# sentinel file. The sentinel is not in %files / conffiles, so it
# survives package operations.
sub isEffectiveAdmin
{
    return 1 if Whostmgr::ACLS::hasroot();
    return -e '/etc/sysconfig/imunify360/cpanel/grant_reseller_admin_ui'
        ? 1 : 0;
}

1;
Back to Directory File Manager