Server IP : 103.119.228.120 / Your IP : 18.220.206.141 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /scripts/ |
Upload File : |
#!/usr/local/cpanel/3rdparty/bin/perl # cpanel - scripts/update_local_rpm_versions 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 warnings; use Cpanel::RPM::Versions::File (); use Cpanel::Usage (); use Cpanel::SafeDir::MK (); # ACTIVATION: remove this activation piece when cPanel on CentOS 7 is officially available # use Cpanel::ConfigFiles::RpmVersions (); my $add = ''; my $edit = ''; my $del = ''; my $directory = ''; my $file = ''; my $key = 0; my $section = 1; my $value = ''; my $packages = ''; my %opts = ( 'directory' => \$directory, 'file' => \$file, 'add' => \$add, 'edit' => \$edit, 'del' => \$del, ); # --add section.key.key value my $cmdl_regex = { 'modify' => qr/-- # -- to begin the command (:?add|edit) # add or edit \s+ # one or more spaces (:?\S+?) # keys \s+ # one or more spaces (.+?) # value is the rest of the provided text. \s* # Ignore any trailing spaces $/x, # end of command 'delete' => qr/-- # -- to begin the command (:?del) # Delete command \s+ # one or more spaces (:?\S+?) # keys $/x, # end of command }; my $orig_cmdl = join ' ', @ARGV; my $return = Cpanel::Usage::wrap_options( \@ARGV, \&usage, \%opts ); exit $return if $return; $file ||= $Cpanel::ConfigFiles::RpmVersions::RPM_VERSIONS_FILE; $directory ||= '/var/cpanel/rpm.versions.d'; if ( !-d $directory ) { Cpanel::SafeDir::MK::safemkdir( $directory, '0750' ); } my $versions = Cpanel::RPM::Versions::File->new( { file => $file, directory => $directory } ); if ( $add || $edit ) { if ( $orig_cmdl !~ /$cmdl_regex->{'modify'}/ ) { usage(); exit 1; } my $cmdl = $add ? $add : $edit; my ( $section, $keys, $value ) = parse_cmd($cmdl); if ( !$section || !@{$keys} || !defined $value ) { usage(); exit 1; } my $set_method = "set_$section"; if ( $versions->can($set_method) ) { $value = [ split /\s*\,\s*/, $value ] if $value =~ /\,/; my $error = $versions->$set_method( { 'key' => $keys, 'value' => $value } ); if ($error) { print $error . "\n\n"; usage(); exit 2; } $versions->save(); } else { print "Section $section does not exist.\n"; usage(); exit 1; } exit(0); } elsif ($del) { if ( $orig_cmdl !~ /$cmdl_regex->{'delete'}/ ) { usage(); exit 1; } my ( $section, $keys ) = parse_cmd($del); if ( !$section || !$keys ) { usage(); exit 1; } my $del_method = "delete_$section"; if ( $versions->can($del_method) ) { $versions->$del_method( { 'key' => $keys } ); $versions->save(); } else { print "Section $section does not exist.\n\n"; usage(); exit 1; } exit(0); } print "Unknown arguments passed to $0\n\n"; usage(); exit 3; sub usage { my $prog = $0; $prog =~ s{^.+/(.+)$}{$1}; print <<EOF; Usage: $prog < --add <section.key> <value> | --edit <section.key> <value> | --del <section.key> > [--file <file>] [--drectory <directory>] [--<help|usage>] Where: --add: Add a <value> to <section>.<key> --edit: Edit a <value> in <section>.<key> --del: Delete <section>.<key> --file: Get default values from <file> (Default: $Cpanel::ConfigFiles::RpmVersions::RPM_VERSIONS_FILE) --directory: Write output to local.versions in <directory> (Default: /var/cpanel/rpm.versions.d) --help: This display --usage: This display EOF return; } sub parse_cmd { my ($cmd) = @_; my ( $section, @keys ) = split /\./, $cmd; my $value; $value = $ARGV[-1] if $ARGV[-1] ne $ARGV[0]; return ( $section, \@keys, $value ); }