#!/home/product/code/webui-perl/bin/perl -T -I /home/product/code/firmware/current/lib/perl5
#SUDOER_USERS: nobody
#SUDOER_RUNAS_USERS: root, mta
#SUDOER_TAGS: NOPASSWD, EXEC
use strict;
use warnings;
use Barracuda::Sudo::Lib;

###############################################################################

=pod

=head1 NAME

list_mount_files

=head1 DESCRIPTION

Lists the file name and size of the files in a specified directory

=cut

###############################################################################
use IPC::Run qw(run);

my $in_bcs_backup = dir_prefix("/mail/bcs_backup/");
my $in_mnt = dir_prefix("/mnt/");

my ($directory) = get_argv(sub {
    -d $_[0] && ($in_mnt->($_[0]) || $in_bcs_backup->($_[0]));
});

my $outfile = sudo_out();

# run's exit codes are reversed
my $undef;
exit !run(['/bin/ls', '-lt', $directory], \$undef, $outfile, \$undef);
