shell bypass 403

UnknownSec Shell

: /scripts/ [ drwxr-xr-x ]

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

# cpanel - scripts/userdata_wildcard_cleanup       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

package scripts::userdata_wildcard_cleanup;

use strict;

use Cpanel                              ();
use Cpanel::Config::userdata::Constants ();
use Cpanel::Config::userdata::Guard     ();
use Cpanel::FileUtils::TouchFile        ();
use Cpanel::SafeRun::Errors             ();
use Cpanel::ServerTasks                 ();
use Cpanel::WildcardDomain              ();
use Cpanel::WildcardDomain::Tiny        ();

use File::Basename ();

BEGIN { unshift @INC, '/usr/local/cpanel'; }

my @ssl_userdata_parts = qw(
  sslcertificatefile
  sslcertificatekeyfile
  sslcacertificatefile
);

our $TOUCH_FILE = '/var/cpanel/ssl/wildcard_cleanup_complete';

__PACKAGE__->script(@ARGV) unless caller();

########################################################################
# This script was created to fix an issue documented in case 67341
########################################################################

sub script {
    my ( $class, @argv ) = @_;

    my ( $rebuild_apache, $forced );
    for my $arg (@argv) {
        if ( $arg eq '--rebuildapache' ) {
            $rebuild_apache = 1;
        }
        if ( $arg eq '--force' ) {
            $forced = 1;
        }
    }

    return if -e $TOUCH_FILE && !$forced;

    my ( $httpd_conf_rebuild_needed, @migrated_servernames, @migrated_nobody_domains );

    @migrated_servernames      = _migrate_wildcard_encoded_userdata_files();
    @migrated_nobody_domains   = _migrate_nobody_userdata_files();
    $httpd_conf_rebuild_needed = 1 if @migrated_servernames || @migrated_nobody_domains;

    #Rebuild apache because previous rebuilds might have accidentally
    #deleted the wildcard SSL vhosts from being unable to find their
    #userdata files.
    if ($httpd_conf_rebuild_needed) {
        if ($rebuild_apache) {
            print "Rebuilding Apache\n";
            my $output = Cpanel::SafeRun::Errors::saferunallerrors("$Cpanel::root/bin/build_apache_conf");
            if ( $output !~ /OK$/ ) {
                warn "Error rebuilding the apache configuration: $output\n";
            }
            Cpanel::ServerTasks::queue_task( ['ApacheTasks'], 'apache_restart' );
        }
        else {
            print "Skipping Apache Rebuild\n";
        }
    }

    Cpanel::FileUtils::TouchFile::touchfile($TOUCH_FILE);

    return;
}

sub _migrate_nobody_userdata_files {
    my $userDir = $Cpanel::Config::userdata::Constants::USERDATA_DIR . "/nobody";
    if ( !-e $userDir ) {
        return;
    }
    my @domains_processed = ();

    {
        my $main_guard = Cpanel::Config::userdata::Guard->new( 'nobody', 'main' );
        my $maindata   = $main_guard->data();
        for my $domain ( $maindata->{'main_domain'}, @{ $maindata->{'sub_domains'} } ) {
            if ( !$domain || !Cpanel::WildcardDomain::Tiny::is_wildcard_domain($domain) || !-e $userDir . "/${domain}_SSL" ) {
                next;
            }

            my $guard    = Cpanel::Config::userdata::Guard->new( 'nobody', $domain . '_SSL' );
            my $userdata = $guard->data();

            _fix_userdata($userdata);

            push @domains_processed, $userdata->{'servername'};

            $guard->save();
        }

        $main_guard->abort();
    }

    return;
}

sub _migrate_wildcard_encoded_userdata_files {
    my @migrated_servernames            = ();
    my @wildcard_encoded_userdata_files = glob("$Cpanel::Config::userdata::Constants::USERDATA_DIR/*/_wildcard_*");

    for my $old_file (@wildcard_encoded_userdata_files) {
        next if !-f $old_file;

        if ( $old_file =~ m{\.cache\z} ) {
            unlink $old_file;
            next;
        }

        my ( $ok, %ret ) = _migrate_userdata_file($old_file);
        next if $ret{'deleted'};

        my $new_file = $old_file;

        #We *shouldn't* need the fussiness of anchoring this substitution
        #with / and \z, but just in case.
        $new_file =~ s{/_wildcard_([^/]+)\z}{/*$1};

        if ( !-f $new_file ) {
            if ( !rename( $old_file, $new_file ) ) {
                warn "The system failed to rename $old_file to $new_file because of an error: $!";
                next;
            }
            push @migrated_servernames, $ret{'servername'};
        }
    }

    return @migrated_servernames;
}

sub _migrate_userdata_file {
    my ($file) = @_;

    my ( $filename, $path, undef ) = File::Basename::fileparse($file);
    my $user        = File::Basename::basename($path);
    my %return_data = ();

    {
        my $guard    = Cpanel::Config::userdata::Guard->new( $user, $filename );
        my $userdata = $guard->data();
        if ( exists $userdata->{'servername'} ) {
            for my $ssl_part (@ssl_userdata_parts) {
                next if !$userdata->{$ssl_part};

                if ( !-e $userdata->{$ssl_part} ) {
                    $guard->abort();
                    unlink $file;
                    return ( 1, 'deleted' => 1 );
                }
            }

            _fix_userdata($userdata);

            $return_data{'servername'} = $userdata->{'servername'};

            $guard->save();
        }
        else {
            $guard->abort();
        }
    }

    return ( 1, %return_data );
}

sub _fix_userdata {
    my ($userdata) = @_;

    # Decodes wildcard encoded domains
    $userdata->{'servername'} = Cpanel::WildcardDomain::decode_wildcard_domain( $userdata->{'servername'} );
    $userdata->{'serveradmin'} =~ s{(\@)_wildcard_\.}{$1};
    $userdata->{'serveralias'} = $userdata->{'servername'};

    return;
}

1;

© 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