shell bypass 403

UnknownSec Shell

: /scripts/ [ drwxr-xr-x ]

name : maildir_converter
#!/usr/local/cpanel/3rdparty/bin/perl

# cpanel - scripts/maildir_converter               Copyright 2022 cPanel, L.L.C.
#                                                           All rights reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

use strict;
use Cpanel::PwCache::PwEnt     ();
use Cpanel::AccessIds::SetUids ();
use Cpanel::Config::Users      ();
use Cpanel::Binaries           ();
use Cpanel::Usage              ();
use Cpanel::SafeRun::Errors    ();
use Cpanel::Sys::Setsid::Fast  ();

$| = 1;

my $do_conversion = 0;
my $to_dovecot    = 0;
my $to_courier    = 0;
my $overwrite     = 0;

# Argument processing
my %opts = (
    'forreal'    => \$do_conversion,
    'overwrite'  => \$overwrite,
    'to-dovecot' => \$to_dovecot,
    'to-courier' => \$to_courier,
);

Cpanel::Usage::wrap_options( \@ARGV, \&usage, \%opts );

if ( $to_dovecot && $to_courier ) {
    print "Can not convert to dovecot and to courier at the same time!\n";
    exit 1;
}

if ( $> != 0 ) {
    die "Conversion process must be performed as root";
}

@ARGV = ( grep( !/^--/, @ARGV ) );

my @users = Cpanel::Config::Users::getcpusers();
my %USERS = map { $_ => 1 } @users;

my @CARGS;
push @CARGS, '--convert'    if ($do_conversion);
push @CARGS, '--overwrite'  if ($overwrite);
push @CARGS, '--to-dovecot' if ($to_dovecot);
push @CARGS, '--to-courier' if ($to_courier);

my $convertuser = $ARGV[0];

my $now = time();

unless ( -d '/var/cpanel/logs' ) {
    mkdir '/var/cpanel/logs' || die "Couldn't create /var/cpanel/logs directory: $!";
    chmod oct(700), '/var/cpanel/logs' || die "Couldn't set permissions on /var/cpanel/logs directory: $!";
}

my $old_umask = umask(0077);    # Case 92381: Logs should not be world-readable.
open my $log_fh, '>', '/var/cpanel/logs/imap_conversion.log.' . $now;
umask($old_umask);

if ( !$log_fh ) {
    die "Couldn't open log file: $!";
}

my @conversion_failures;

$SIG{'INT'} = $SIG{'HUP'} = sub {
    print "maildir_converter Ignoring signal to avoid mail corruption\n";
    return;
};

my $quotaon_cmd  = Cpanel::Binaries::path('quotaon');
my $quotaoff_cmd = Cpanel::Binaries::path('quotaoff');

# Disable quotas
if ( -x $quotaoff_cmd ) {
    system $quotaoff_cmd, '-a';
}

Cpanel::PwCache::PwEnt::setpwent();
while ( my @PW = Cpanel::PwCache::PwEnt::getpwent() ) {
    my ( $user, $uid, $gid, $homedir ) = @PW[ 0, 2, 3, 7 ];
    next if ( $convertuser && $user ne $convertuser );
    next if ( !exists $USERS{$user} );

    $homedir =~ /(.*)/;    # Untaint
    $homedir = $1;

    if ( !-d $homedir ) { next; }
    my @maildirs = find_maildirs($homedir);
    foreach my $dir (@maildirs) {
        $dir =~ /(.*)/;
        $dir = $1;
        print "Converting $dir...";

        if ( my $pid = fork() ) {

            #parent
            waitpid( $pid, 0 );
            my $exitcode = $?;
            if ($exitcode) {
                print "failed\n";
                push @conversion_failures, $user . ':' . $dir . ':' . $now . "\n";
            }
            else {
                print "ok\n";
            }
        }
        else {
            Cpanel::Sys::Setsid::Fast::fast_setsid();
            Cpanel::AccessIds::SetUids::setuids( $uid, $gid );
            chdir $dir || exit 1;
            my $output = Cpanel::SafeRun::Errors::saferunallerrors( '/usr/local/cpanel/bin/maildir-migrate', @CARGS, '--recursive' );
            print $log_fh "\nDirectory: $dir\n";
            print $log_fh join( ' ', '/usr/local/cpanel/bin/maildir-migrate', @CARGS, '--recursive' ) . "\n";
            print $log_fh $output . "\n";
            my $exitcode = $?;
            exit $exitcode >> 8;
        }
    }
}
Cpanel::PwCache::PwEnt::endpwent();

close $log_fh;

# Restore quotas
if ( -x $quotaon_cmd ) {
    system $quotaon_cmd, '-a';
}

if ( scalar @conversion_failures ) {
    my $old_umask = umask(0077);    # Case 92381: Logs should not be world-readable.
    open my $failure_fh, '>>', '/var/cpanel/logs/imap_conversion_failures';
    umask($old_umask);

    if ( !$failure_fh ) {
        die "Couldn't open log file: $!";
    }

    print $failure_fh @conversion_failures;
    close $failure_fh;
    print "\nSome failures were encountered during maildir conversion process.\n";
    print "Full log available at: /var/cpanel/logs/imap_conversion.log.$now\n";
    exit 1;
}
exit 0;

sub find_maildirs {
    my $homedir = shift;
    my @maildirs;
    if ( -d $homedir . '/mail/cur' && -d $homedir . '/mail/new' ) {
        push @maildirs, $homedir . '/mail';
        if ( opendir( my $base_dh, $homedir . '/mail' ) ) {
            my @base_dirlist = readdir($base_dh);
            closedir $base_dh;
            foreach my $base_dir (@base_dirlist) {
                next if ( $base_dir =~ /^(?:\.|cur\Z|tmp\Z|new\Z)/ );
                next unless ( -d $homedir . '/mail/' . $base_dir );
                if ( opendir( my $sub_dh, $homedir . '/mail/' . $base_dir ) ) {
                    my @sub_dirlist = readdir($sub_dh);
                    closedir $sub_dh;
                    foreach my $sub_dir (@sub_dirlist) {
                        next if ( $sub_dir =~ /^\./ );
                        next unless ( -d $homedir . '/mail/' . $base_dir . '/' . $sub_dir . '/cur' && -d $homedir . '/mail/' . $base_dir . '/' . $sub_dir . '/new' );
                        push @maildirs, $homedir . '/mail/' . $base_dir . '/' . $sub_dir;
                    }
                }
            }
        }
    }
    return @maildirs;
}

sub usage {
    print "Usage: maildir_converter [options] [user]\n\n";
    print "Options:\n";
    print "    --forreal       Perform conversion\n";
    print "    --overwrite     Overwrite existing files\n";
    print "    --to-dovecot    Conversion is from Courier to Dovecot\n";
    print "    --to-courier    Conversion is from Dovecot to Courier\n";
    print "\n";
    print "If no user is specified, maildirs for all accounts will be converted.\n";
    print "\n";
    print "When direction over conversion (dovecot/courier) is not specified\n";
    print "maildir files will be updated based on relative timestamps.\n";

    exit 0;
}

© 2025 UnknownSec
Web Design for Beginners | Anyleson - Learning Platform
INR (₹)
India Rupee
$
United States Dollar
Web Design for Beginners

Web Design for Beginners

in Design
Created by Linda Anderson
+2
5 Users are following this upcoming course
Course Published
This course was published already and you can check the main course
Course
Web Design for Beginners
in Design
4.25
1:45 Hours
8 Jul 2021
₹11.80

What you will learn?

Create any website layout you can imagine

Support any device size with Responsive (mobile-friendly) Design

Add tasteful animations and effects with CSS3

Course description

You can launch a new career in web development today by learning HTML & CSS. You don't need a computer science degree or expensive software. All you need is a computer, a bit of time, a lot of determination, and a teacher you trust. I've taught HTML and CSS to countless coworkers and held training sessions for fortune 100 companies. I am that teacher you can trust. 


Don't limit yourself by creating websites with some cheesy “site-builder" tool. This course teaches you how to take 100% control over your webpages by using the same concepts that every professional website is created with.


This course does not assume any prior experience. We start at square one and learn together bit by bit. By the end of the course you will have created (by hand) a website that looks great on phones, tablets, laptops, and desktops alike.


In the summer of 2020 the course has received a new section where we push our website live up onto the web using the free GitHub Pages service; this means you'll be able to share a link to what you've created with your friends, family, colleagues and the world!

Requirements

No prerequisite knowledge required

No special software required

Comments (0)

Report course

Please describe about the report short and clearly.

Share

Share course with your friends