package Cpanel::Easy::Apache::Fileprotect;

# cpanel - Cpanel/Easy/Apache/FileProtect.pm      Copyright(c) 2014 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

our $easyconfig = {
    'name'          => 'Fileprotect',
    'note'          => 'Prevent Users from reading other webroots',
    'when_i_am_off' => sub {
        my $self = shift;
        unlink '/var/cpanel/fileprotect';
        if ( -e '/var/cpanel/fileprotect' ) {
            $self->print_alert( q{Could not remove '[_1]': [_2],  that will need done manually!}, '/var/cpanel/fileprotect', $! );
        }
        elsif ( -x '/usr/local/cpanel/scripts/disablefileprotect' ) {
            $self->add_command( 'post-confgen-commands', ['/usr/local/cpanel/scripts/disablefileprotect'] );
        }
    },
    'dryrun' => {
        '0' => {
            'name'    => 'turning it on...',
            'command' => sub {
                my ($self) = @_;
                return $self->run_system_cmd_returnable( [qw(touch /var/cpanel/fileprotect)] );
            },
        },
    },
    'step' => {
        '0' => {
            'name'    => 'Run /usr/local/cpanel/scripts/enablefileprotect after Apache is installed',
            'command' => sub {
                my ($self) = @_;
                $self->add_command( 'post-confgen-commands', ['/usr/local/cpanel/scripts/enablefileprotect'] );
            },
        },
    },
};

1;
