?????????? ????????? - ??????????????? - /home/agenciai/public_html/cd38d8/lve.tar
???????
modlscapi/utils/getdocroots.pm 0000755 00000002416 15125566744 0012576 0 ustar 00 #!/usr/bin/sh eval 'if [ -x /usr/local/cpanel/3rdparty/bin/perl ]; then exec /usr/local/cpanel/3rdparty/bin/perl -x -- $0 ${1+"$@"}; else exec /usr/bin/perl -x $0 ${1+"$@"}; fi;' if 0; #!/usr/bin/perl # Copyright (c) Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2018 All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. BEGIN { unshift @INC, '/usr/local/cpanel', '/scripts'; } use strict; use Data::Dumper; use Cpanel::DomainLookup (); use Cpanel::Config::Users (); my @users =Cpanel::Config::Users::getcpusers(); foreach my $user (@users) { my @pathes = Cpanel::DomainLookup::getdocrootlist($user); foreach my $path (@pathes) { my @k = keys %{$path}; foreach my $path_i (@k) { print $path_i , "\n"; } } } modlscapi/utils/cpanel-make-lve 0000755 00000001734 15125566744 0012572 0 ustar 00 #!/usr/bin/bash # Copyright (c) Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2018 All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ##################################################### # Util for building modules by hands. Without hooks # ##################################################### . /usr/share/lve/modlscapi/include/cpanel-common-lve showBar 1 writeToLog "mod_lsapi module installation" installModule_lsapi showBar 2 writeToLog "End operation" echo modlscapi/utils/lsapi-cache 0000755 00000002056 15125566744 0012000 0 ustar 00 #!/usr/bin/bash # Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2021 All Rights Reserved # # Licensed under CLOUD LINUX LICENSE AGREEMENT # http://cloudlinux.com/docs/LICENSE.TXT # [ -z "$LSAPICACHE_LOAD_DIRS" ] && exit 0 [ -z "$LSAPICACHE_LOGFILE" ] && LSAPICACHE_LOGFILE=/usr/share/lve/modlscapi/logs/lsapi-cache.log D=`date`; echo "$D: the following dirs will be processed: $LSAPICACHE_LOAD_DIRS" >>$LSAPICACHE_LOGFILE OIFS="$IFS" IFS=":" for d in $LSAPICACHE_LOAD_DIRS do [ -d "$d" ] || continue D=`date`; echo "$D: loading shared libraries from ${d}..." >>$LSAPICACHE_LOGFILE /usr/bin/find "$d" -type f -executable -exec /usr/bin/ldd {} \; >/dev/null 2>&1 D=`date`; echo "$D: ${d} - done." >>$LSAPICACHE_LOGFILE done for d in $LSAPICACHE_LOAD_DIRS do [ -d "$d" ] || continue D=`date`; echo "$D: loading lsphp from ${d}..." >>$LSAPICACHE_LOGFILE /usr/bin/find "$d" -type f -executable -name lsphp -exec {} -i \; >/dev/null 2>&1 D=`date`; echo "$D: ${d} - done." >>$LSAPICACHE_LOGFILE done IFS="$OIFS" exit 0 modlscapi/utils/getuserdomains.pm 0000755 00000002557 15125566744 0013301 0 ustar 00 #!/usr/bin/sh eval 'if [ -x /usr/local/cpanel/3rdparty/bin/perl ]; then exec /usr/local/cpanel/3rdparty/bin/perl -x -- $0 ${1+"$@"}; else exec /usr/bin/perl -x $0 ${1+"$@"}; fi;' if 0; #!/usr/bin/perl # Copyright (c) Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2018 All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. BEGIN { unshift @INC, '/usr/local/cpanel', '/scripts'; } use strict; use Cpanel::DomainLookup (); use Data::Dumper; use Cpanel::Config::Users (); sub getdocrootlist_my { my $user = shift; # optional my %DOCROOTS = (); my $docroots_ref = Cpanel::DomainLookup::getdocroots($user); foreach my $domain ( keys %{$docroots_ref} ) { print $user, "\t",$domain, "\n"; } } my @users =Cpanel::Config::Users::getcpusers(); foreach my $user (@users) { getdocrootlist_my($user); } modlscapi/utils/cpanel-hooks-lve 0000755 00000010751 15125566744 0012777 0 ustar 00 #!/usr/bin/bash # Copyright (c) Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2018 All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. ################################################### # Utils for hooks installation or removing # ################################################### . /usr/share/lve/modlscapi/include/cpanel-common-lve function createHookHeader(){ #1 - hook name if [ ! -e "$common_path_of_cpanel/tmp" ]; then mkdir -p "$common_path_of_cpanel/tmp" fi if [ ! -e "$1" ];then touch "$1" fi if [ -e "$1" ];then chmod 755 "$1" tmp=$(cat "$1" | grep "#!/bin/bash") if [ -z "$tmp" ];then echo "#!/bin/bash" > "$common_path_of_cpanel/tmp/future_hook.tmp.$$" cat "$1" >> "$common_path_of_cpanel/tmp/future_hook.tmp.$$" cat "$common_path_of_cpanel/tmp/future_hook.tmp.$$" > "$1" rm -f "$common_path_of_cpanel/tmp/future_hook.tmp.$$" fi fi } function checkHookString(){ #1 - hook name #2 - pattern string #3 - comment srting if [ -e "$1" ];then tmp=$(cat "$1" | grep "$2") if [ -z "$tmp" ];then echo "$2 #$3" >> "$1" fi fi } function addHookStringFirst(){ #1 - hook name #2 - pattern string #3 - comment srting #4 - short hook name if [ -e "$1" ];then cat "$1" | sed /$4/d | sed 1a"$2 #$3" > "$common_path_of_cpanel/tmp/future_hook.tmp.$$" cat "$common_path_of_cpanel/tmp/future_hook.tmp.$$" > "$1" rm -f "$common_path_of_cpanel/tmp/future_hook.tmp.$$" fi } #################################################### # EasyApache hooks # #################################################### before_apache_make="/scripts/before_apache_make" before_httpd_restart_tests="/scripts/before_httpd_restart_tests" postupcp="/scripts/postupcp" after_apache_make_install="/scripts/after_apache_make_install" posteasyapache="/scripts/posteasyapache" #################################################### # Hooks list # #################################################### lsapi_HOOK="$common_path_of_cpanel/hooks/lsapi.hook" cpanelpostupcp_HOOK="$common_path_of_cpanel/hooks/cpanelpostupcp.hook" clearconf_HOOK="$common_path_of_cpanel/hooks/clearconf.hook" posteasyapache_HOOK="$common_path_of_cpanel/hooks/buildlsphp.hook" writeToLog "Install cPanel hooks" showBar 1 #Install new hooks createHookHeader "$before_apache_make" createHookHeader "$before_httpd_restart_tests" createHookHeader "$postupcp" createHookHeader "$after_apache_make_install" createHookHeader "$posteasyapache" showBar 2 writeToLog "Headers checked" addHookStringFirst "$before_apache_make" "$clearconf_HOOK" "mod_lsapi Version $VERSION. Required for LVE module recompilation" "clearconf.hook" removeEmptyStringsFromFile "$before_apache_make" showBar 3 writeToLog "before_apache_make checked" checkHookString "$before_httpd_restart_tests" "$lsapi_HOOK" "mod_lsapi Version $VERSION mod_lsapi module installation" checkHookString "$before_httpd_restart_tests" "$cpanelpostupcp_HOOK" "mod_lsapi Version $VERSION Rebuild Apache config hook" removeEmptyStringsFromFile "$before_httpd_restart_tests" showBar 4 writeToLog "before_httpd_restart_tests checked" checkHookString "$postupcp" "$cpanelpostupcp_HOOK" "mod_lsapi Version $VERSION Rebuild Apache config hook" removeEmptyStringsFromFile "$postupcp" showBar 5 writeToLog "postupcp checked" showBar 6 writeToLog "after_apache_make_install checked" checkHookString "$after_apache_make_install" "$lsapi_HOOK" "mod_lsapi Version $VERSION mod_lsapi module installation" removeEmptyStringsFromFile "$after_apache_make_install" showBar 7 writeToLog "after_apache_make_install checked" showBar 8 checkHookString "$posteasyapache" "$posteasyapache_HOOK" "mod_lsapi Version $VERSION mod_lsapi module installation" checkHookString "$posteasyapache" "$cpanelpostupcp_HOOK" "mod_lsapi Version $VERSION Rebuild Apache config hook" removeEmptyStringsFromFile "$posteasyapache" writeToLog "posteasyapache checked" showBar 9 writeToLog "Done installing hooks" echo modlscapi/utils/cpanel_hooks_manage.py 0000755 00000006774 15125566744 0014246 0 ustar 00 #!/usr/bin/python3 # Copyright (c) Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2018 All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #coding:utf-8 """ Mod_lsapi hooks manager for Cpanel EA4 -i - installs hooks -d - removes hooks """ import os import sys import syslog import yaml YAML_HOOK_BASE = "/var/cpanel/hooks.yaml" MANAGE_HOOK = "/usr/local/cpanel/bin/manage_hooks" def log_error(msg): """ Write message to log """ syslog.syslog("%s: %s" % (__file__, msg)) def is_hook_installed(category, event, hook_script_path): """ Check is hook installed in current cpanel """ try: stream = open(YAML_HOOK_BASE, "r") except (IOError, OSError): return False hook_base = yaml.load(stream) try: for i in hook_base[category][event]: if i["hook"] == hook_script_path: return True except KeyError: return False return False def install_hook(hook_script_path, category, event, stage): """ Install event hook for cpanel """ if not is_hook_installed(category, event, hook_script_path): cmd = "%s add script %s --category=%s --event=%s --stage=%s --manual" \ % (MANAGE_HOOK, hook_script_path, category, event, stage) if os.system(cmd): log_error("Can`t add hook to category:%s event:%s" % (category, event)) return 1 return 0 def remove_hook(hook_script_path, category, event, stage): """ Remove cpanel event hook """ cmd = "%s delete script %s --category=%s --event=%s --stage=%s --manual" \ % (MANAGE_HOOK, hook_script_path, category, event, stage) if os.system(cmd): log_error("Can't delete hook to category:%s event:%s" % (category, event)) return 1 return 0 def main(argv): """ Install or delete cpanel event hook """ result = 0 if "-i" in argv: # install hooks result = install_hook("/usr/share/lve/modlscapi/hooks/cpanel_post_upcp_lsapi_hook.py", "System", "upcp", "post") or result result = install_hook("/usr/share/lve/modlscapi/hooks/cpanel_post_upcp_check_handlers_hook.py", "System", "upcp", "post") or result result = install_hook("/usr/share/lve/modlscapi/hooks/cpanel_pre_upcp_check_handlers_hook.py", "System", "upcp", "pre") or result elif "-d" in argv: # remove hooks result = remove_hook("/usr/share/lve/modlscapi/hooks/cpanel_post_upcp_lsapi_hook.py", "System", "upcp", "post") or result result = remove_hook("/usr/share/lve/modlscapi/hooks/cpanel_post_upcp_check_handlers_hook.py", "System", "upcp", "post") or result result = remove_hook("/usr/share/lve/modlscapi/hooks/cpanel_pre_upcp_check_handlers_hook.py", "System", "upcp", "pre") or result return result if "__main__" == __name__: sys.exit(main(sys.argv[1:])) modlscapi/utils/checkconfdutil.pm 0000755 00000005045 15125566744 0013230 0 ustar 00 #!/usr/local/cpanel/3rdparty/bin/perl # Copyright (c) Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2018 All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. BEGIN { unshift @INC, '/usr/local/cpanel', '/scripts'; } my $pckg_name = 'Cpanel'; use strict; eval "use " .$pckg_name . "::CPAN::Hash::Merge ();"; if ($@){ $pckg_name = 'cPScript'; eval "use " .$pckg_name . "::CPAN::Hash::Merge ();"; } use strict; use warnings; #eval "use " .$pckg_name . "::CPAN::Hash::Merge ();"; eval "use " .$pckg_name . "::DataStore ();"; no warnings 'uninitialized'; my $main_conf_ref = Cpanel::DataStore::fetch_ref('/var/cpanel/conf/apache/main'); my $ref_type=ref($main_conf_ref->{'main'}{'include'}{'items'}); my $etalon_ref={"main"=>{"include"=>{"directive"=>"include","items"=>[{include=>"\"/usr/local/apache/conf/conf.d/*\""}]}}}; if ($ref_type eq 'ARRAY'){ my $res=$main_conf_ref->{'main'}{'include'}{'items'}; my $find=0; my $empty_find=0; for(my $index=0;$index<@$res;$index++) { my $item_ref=@$res[$index]; if ( !defined($item_ref->{'include'})) { $empty_find = 1; } else { if ( index($item_ref->{'include'},"/usr/local/apache/conf/conf.d/*.conf")!=-1 ){ $find=1; } } } if ( $find==0 ){ for(my $index=0;$index<@$res;$index++) { my $item_ref=@$res[$index]; if ( index($item_ref->{'include'},"/usr/local/apache/conf/conf.d/*")!=-1 ){ delete @$res[$index]; } } push(@$res,{ "include"=>"\"/usr/local/apache/conf/conf.d/*.conf\"" }); Cpanel::DataStore::store_ref( '/var/cpanel/conf/apache/main', $main_conf_ref ); } if( $empty_find==1 ) { @$res = grep { defined $_ } @$res; Cpanel::DataStore::store_ref( '/var/cpanel/conf/apache/main', $main_conf_ref ); } } else { $main_conf_ref->{'main'} = Cpanel::CPAN::Hash::Merge::merge($main_conf_ref->{'main'}, $etalon_ref->{'main'}); Cpanel::DataStore::store_ref( '/var/cpanel/conf/apache/main', $main_conf_ref ); } modlscapi/utils/getdocroot.pm 0000755 00000005516 15125566744 0012417 0 ustar 00 #!/usr/bin/sh eval 'if [ -x /usr/local/cpanel/3rdparty/bin/perl ]; then exec /usr/local/cpanel/3rdparty/bin/perl -x -- $0 ${1+"$@"}; else exec /usr/bin/perl -x $0 ${1+"$@"}; fi;' if 0; #!/usr/bin/perl # Copyright (c) Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2018 All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. BEGIN { unshift @INC, '/usr/local/cpanel', '/scripts'; } use strict; use Cpanel::Config::userdata::Load (); use Cpanel::Config::userdata::Cache (); use Cpanel::Logger (); use Cpanel::PwCache (); use Carp (); my ( $SubDomains, $MULTIPARKED, %DOCROOTS, %domainCache ); my $PERMIT_MEMORY_CACHE = 1; sub getmultiparked_my { my $user = $_[0]; if ( !$MULTIPARKED ) { $MULTIPARKED = {}; my $cache = Cpanel::Config::userdata::Cache::load_cache( $user, $PERMIT_MEMORY_CACHE ); # $cache is a HASHREF # $cache keys are domains # $cache values are a ARRAYREF with ( 0 $owner, 1 $reseller, 2 $type, 3 $parent, 4 $docroot ) if ( $cache && %$cache ) { for my $domain ( grep { $cache->{$_}->[2] eq 'parked' || $cache->{$_}->[2] eq 'addon' } keys %$cache ) { $MULTIPARKED->{ $cache->{$domain}->[3] }->{$domain} = $cache->{$domain}->[4]; } } } return %$MULTIPARKED; } sub getdocroot_my { my $domain = $_[0]; my $user = $_[1]; my $docroot; my $ud = Cpanel::Config::userdata::Load::load_userdata( $user, $domain ); if ( $ud && keys %$ud ) { $docroot = $ud->{'documentroot'}; } else { if ( !$MULTIPARKED ) { getmultiparked_my(); } for my $sub_domain ( keys %$MULTIPARKED ) { if ( exists $MULTIPARKED->{$sub_domain}->{$domain} ) { $docroot = $MULTIPARKED->{$sub_domain}->{$domain}; last; } } } if ( !$docroot ) { $docroot = $Cpanel::homedir . '/public_html'; } if (wantarray) { ( my $reldocroot = $docroot ) =~ s{^$Cpanel::homedir/}{}; return ( $docroot, $reldocroot ); } return $docroot; } my $num_args = $#ARGV + 1; if ($num_args != 2) { print ""; exit; } my $name = $ARGV[0]; my $dm = $ARGV[1]; my $path = getdocroot_my($dm, $name); if ($path eq "/public_html") { print ""; } else { print $path; } modlscapi/utils/cpanel-delete-lve 0000755 00000003672 15125566744 0013122 0 ustar 00 #!/usr/bin/bash # Copyright (c) Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2018 All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. . /usr/share/lve/modlscapi/include/cpanel-common-lve before_apache_make="/scripts/before_apache_make" before_httpd_restart_tests="/scripts/before_httpd_restart_tests" postupcp="/scripts/postupcp" after_apache_make_install="/scripts/after_apache_make_install" posteasyapache="/scripts/posteasyapache" showBar 1 rm -f /usr/local/apache/conf/conf.d/lsapi.conf writeToLog "LVE Config files deleted" showBar 2 deleteAllInclude "$before_httpd_restart_tests" "before_httpd_restart_tests" "/#mod_lsapi/d" showBar 3 deleteAllInclude "$before_apache_make" "before_apache_make" "/#mod_lsapi/d" showBar 4 deleteAllInclude "$postupcp" "postupcp" "/#mod_lsapi/d" showBar 5 deleteAllInclude "$after_apache_make_install" "postupcp" "/#mod_lsapi/d" showBar 6 deleteAllInclude "$posteasyapache" "posteasyapache" "/#mod_lsapi/d" writeToLog "Delete hooks" pathto="/usr/local/apache/modules" pathbak="/usr/share/lve/modlscapi/tmp" showBar 7 echo modlscapi/utils/inserphpconf.pm 0000755 00000005043 15125566744 0012737 0 ustar 00 #!/usr/local/cpanel/3rdparty/bin/perl # Copyright (c) Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2018 All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. BEGIN { unshift @INC, '/usr/local/cpanel', '/scripts'; } my $pckg_name = 'Cpanel'; use strict; eval "use " .$pckg_name . "::CPAN::Hash::Merge ();"; if ($@){ $pckg_name = 'cPScript'; eval "use " .$pckg_name . "::CPAN::Hash::Merge ();"; } use strict; use warnings; #eval "use " .$pckg_name . "::CPAN::Hash::Merge ();"; eval "use " .$pckg_name . "::DataStore ();"; no warnings 'uninitialized'; my $main_conf_ref = Cpanel::DataStore::fetch_ref('/var/cpanel/conf/apache/main'); my $ref_type=ref($main_conf_ref->{'main'}{'include'}{'items'}); my $etalon_ref={"main"=>{"include"=>{"directive"=>"include","items"=>[{include=>"\"/usr/local/apache/conf/php.conf\""}]}}}; if ($ref_type eq 'ARRAY'){ my $res=$main_conf_ref->{'main'}{'include'}{'items'}; my $find=0; my $empty_find=0; for(my $index=0;$index<@$res;$index++) { my $item_ref=@$res[$index]; if ( !defined($item_ref->{'include'})) { $empty_find = 1; } else { if ( index($item_ref->{'include'},"php.conf")!=-1 ){ $find=1; } } } if ( $find==0 ){ for(my $index=0;$index<@$res;$index++) { my $item_ref=@$res[$index]; if ( index($item_ref->{'include'},"php.conf")!=-1 ){ delete @$res[$index]; } } push(@$res,{ "include"=>"\"/usr/local/apache/conf/php.conf\"" }); Cpanel::DataStore::store_ref( '/var/cpanel/conf/apache/main', $main_conf_ref ); } if( $empty_find==1 ) { @$res = grep { defined $_ } @$res; Cpanel::DataStore::store_ref( '/var/cpanel/conf/apache/main', $main_conf_ref ); } } else { $main_conf_ref->{'main'} = Cpanel::CPAN::Hash::Merge::merge($main_conf_ref->{'main'}, $etalon_ref->{'main'}); Cpanel::DataStore::store_ref( '/var/cpanel/conf/apache/main', $main_conf_ref ); } modlscapi/user/lsphpchecker.ini 0000644 00000003067 15125566744 0012676 0 ustar 00 bool:eq,suhosin.simulation = Off bool:eq,suhosin.mail.protect = 1 bool:eq,suhosin.cookie.disallow_nul = no value suhosin.cookie.max_array_depth = 1000 suhosin.cookie.max_array_index_length = 500 suhosin.cookie.max_name_length = 500 suhosin.cookie.max_totalname_length = 500 suhosin.cookie.max_value_length = 200000 suhosin.cookie.max_vars = 16384 bool:eq,suhosin.get.disallow_nul = no value suhosin.get.max_array_depth = 1000 suhosin.get.max_array_index_length = 500 suhosin.get.max_name_length = 500 suhosin.get.max_totalname_length = 500 suhosin.get.max_value_length = 1000000 suhosin.get.max_vars = 16384 bool:eq,suhosin.post.disallow_nul = no value suhosin.post.max_array_depth = 1000 suhosin.post.max_array_index_length = 500 suhosin.post.max_name_length = 500 suhosin.post.max_totalname_length = 500 suhosin.post.max_value_length = 1000000 suhosin.post.max_vars = 16384 bool:eq,suhosin.request.disallow_nul = no value suhosin.request.max_array_depth = 1000 suhosin.request.max_array_index_length = 500 suhosin.request.max_totalname_length = 500 suhosin.request.max_value_length = 1000000 suhosin.request.max_vars = 16384 suhosin.request.max_varname_length = 524288 suhosin.upload.max_uploads = 300 bool:eq,suhosin.upload.disallow_elf = no value bool:eq,suhosin.session.cryptua = Off bool:eq,suhosin.session.encrypt = Off suhosin.session.max_id_length = 1024 bool:eq,suhosin.executor.allow_symlink = Off bool:eq,suhosin.executor.disable_eval = Off bool:eq,suhosin.executor.disable_emodifier = Off suhosin.executor.include.max_traversal = 8 apc.shm_segments = 1 mb:gte,apc.shm_size = 32 modlscapi/user/switch_lsapi 0000755 00000067434 15125566744 0012151 0 ustar 00 #!/usr/bin/bash #%copyright% VERBOSE=NO FORCE=NO for item in "$@" do if [ "$item" == "--verbose" ]; then VERBOSE=YES echo "Switching verbose level on... done" shift fi if [ "$item" == "--force" ]; then FORCE=YES echo "Using force-yes option..." shift fi done CMD="$1" function addString(){ HANDLR="$1" BINARY="$2" FL="$3" touch "$FL" if [ -e "$FL" ] && [ -e "$BINARY" ]; then RES=$(cat "$FL" | grep "$HANDLR") if [ -z "$RES" ]; then echo "$HANDLR $BINARY" >> "$FL" fi fi } function set_handler() { PHP="$1" HANDLER="$2" if [ -z "$PHP" ]; then return 1 fi if [ -z "$HANDLER" ]; then return 1 fi echo "Setting $PHP to $HANDLER handler..." /usr/sbin/whmapi1 php_set_handler version="$PHP" handler="$HANDLER" 2>/dev/null >/dev/null return 0 } function confirm() { if [ "$FORCE" == "YES" ]; then return 0 fi read -r -p "Do you want to proceed? [y/N] " response </dev/tty if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then return 0 else return 1 fi } function check_enable_global() { YES="$1" if [ -e /usr/share/lve/modlscapi/global.enabled -o -n "$YES" ]; then echo "mod_lsapi switched to turning on and off through the MultiPHP Manager(/Home/Software/MultiPHP Manager)" echo "You are using enabled globally mod_lsapi. Do you want to enable mod_lsapi through MultiPHP Manager?" echo "Current PHP will be switched to lsapi handler:" /usr/local/cpanel/bin/rebuild_phpconf --current | while read -r line; do echo "$line" | sed -n '/ cgi/p; /suphp/p' done echo "If you type N then mod_lsapi will be disabled and you can enable it again from MultiPHP Manager." if confirm; then /usr/local/cpanel/bin/rebuild_phpconf --current | while read -r line; do if [[ "$line" == *"suphp"* ]]; then set_handler "$(echo "$line" | cut -d ' ' -f1)" "lsapi" fi if [[ "$line" == *" cgi"* ]]; then set_handler "$(echo "$line" | cut -d ' ' -f1)" "lsapi" fi done fi fi if [ -e /etc/apache2/conf.d/lsapi.conf ]; then [ "$VERBOSE" = "YES" ] && echo -n "Switching old lsapi configuration off..." sed -i '/LoadModule/d' "/etc/apache2/conf.d/lsapi.conf" sed -i '/lsapi_engine/d' "/etc/apache2/conf.d/lsapi.conf" sed -i '/AddHandler/d' "/etc/apache2/conf.d/lsapi.conf" sed -i '/AddType/d' "/etc/apache2/conf.d/lsapi.conf" sed -i '/FilesMatch/d' "/etc/apache2/conf.d/lsapi.conf" [ "$VERBOSE" = "YES" ] && echo " done" fi # [ "$VERBOSE" = "YES" ] && echo "Enabling module..." # addString "# Enable mod_lsapi" "" "/etc/apache2/conf.modules.d/001_mod_lsapi.conf" # addString "LoadModule lsapi_module modules/mod_lsapi.so" "" "/etc/apache2/conf.modules.d/001_mod_lsapi.conf" # [ "$VERBOSE" = "YES" ] && echo " done" } function uninstall_lsapi_handler() { if [ -e /etc/apache2/conf.modules.d/90-suphp.conf ]; then HANDLER="suphp" elif [ -e /etc/apache2/conf.modules.d/005_mod_cgid.conf -o \ -e /etc/apache2/conf.modules.d/005_mod_cgi.conf ]; then HANDLER="cgi" else echo "[WARNING]: Cannot detect a valid handler" HANDLER="cgi" fi echo "You started the uninstallation of the mod_lsapi." echo "PHP with enabled lsapi handler will be switched to $HANDLER handler." /usr/local/cpanel/bin/rebuild_phpconf --current | while read -r line; do echo "$line" | sed -n '/lsapi/p' done /usr/local/cpanel/bin/rebuild_phpconf --current | while read -r line; do if [[ "$line" == *"lsapi"* ]]; then set_handler "$(echo "$line" | cut -d ' ' -f1)" "$HANDLER" fi done } function get_user_config() { DOMAIN="$1" CLEAN="$2" if [ -z "$DOMAIN" ]; then return 1 fi UN=$(/scripts/whoowns "$1" | tr -d '\n' | tr -d ' ') if [ -z "$UN" ]; then return 1 fi HD=$(/usr/share/lve/modlscapi/utils/getdocroot.pm "$UN" "$DOMAIN") if [ -z "$HD" ]; then return 1 fi if [ -e "$HD/.htaccess" ]; then if grep -E '[[:space:]]*lsapi_engine*[[:space:]]On' "$HD/.htaccess" | grep -vq "#"; then if grep -E '[[:space:]]*application/x-httpd-lsphp' "$HD/.htaccess" | grep -vq "#"; then if [ "$CLEAN" == "Yes" ]; then sed -i '/lsphp -- BEGIN/,/lsphp -- END/d' "$HD/.htaccess" sed -i '/mod_lsapi/d' "$HD/.htaccess" sed -i '/x-httpd-lsphp/d' "$HD/.htaccess" sed -i '/lsapi_engine/d' "$HD/.htaccess" fi return 0 fi fi fi return 1 } function count_lsapi_user() { ARRAY=( "$@" ) COUNTER=0 for vhost in "${ARRAY[@]}"; do if get_user_config "$vhost" "No"; then let COUNTER=COUNTER+1 fi done if [ $COUNTER -gt 0 ]; then return 0 else return 1 fi } function clean_user_conf() { ARRAY=( "$@" ) for vhost in "${ARRAY[@]}"; do get_user_config "$vhost" "Yes" done } function get_vhosts_by_version() { PHP="$1" INHERITED=$(/usr/local/cpanel/bin/rebuild_phpconf --current | grep DEFAULT | cut -d ' ' -f3) /usr/sbin/whmapi1 php_get_vhosts_by_version version="$PHP" | while read -r line; do echo "$line" | grep -e '- ' | sed 's/^[ \t]*- //' done if [ "$PHP" == "$INHERITED" ]; then /usr/sbin/whmapi1 php_get_vhosts_by_version version="inherit" | while read -r line; do echo "$line" | grep -e '- ' | sed 's/^[ \t]*- //' done fi } function check_enable_user() { /usr/local/cpanel/bin/rebuild_phpconf --current | while read -r line; do PHP=$(echo "$line" | cut -d ' ' -f1) HANDLER=$(echo "$line" | cut -d ' ' -f3) declare -a Array Array+=$(get_vhosts_by_version "$PHP") if count_lsapi_user ${Array[@]}; then echo "Domains that handled by $PHP:" for vhost in ${Array[@]}; do if get_user_config "$vhost" "No"; then echo "$vhost - lsapi" else echo "$vhost - $HANDLER" fi done echo "There are domains which are using mod_lsapi through --enable-domain option." echo "This option is deprecated for EA4 and mod_lsapi switched to turning on and off through" echo "the MultiPHP Manager(/Home/Software/MultiPHP Manager)" echo "Do you want to enable mod_lsapi through MultiPHP Manager for $PHP?" echo "Domains which are using $HANDLER will be switched to lsapi handler too." echo "If you type N then mod_lsapi will remain enabled on these domains." echo "However, enabling mod_lsapi for new domains is now possible only through MultiPHP Manager." if confirm; then clean_user_conf ${Array[@]} set_handler "$PHP" "lsapi" fi fi unset Array done } function oldUninstall() { [ "$VERBOSE" = "YES" ] && echo "Old mod_lsapi uninstall started" if [ -e /etc/apache2/conf.modules.d/90-suphp.conf.cpanel ]; then [ "$VERBOSE" = "YES" ] && echo -n "Restoring /etc/apache2/conf.modules.d/90-suphp.conf..." mv /etc/apache2/conf.modules.d/90-suphp.conf.cpanel /etc/apache2/conf.modules.d/90-suphp.conf [ "$VERBOSE" = "YES" ] && echo " done" fi if [ -e /etc/container/php.handler ]; then [ "$VERBOSE" = "YES" ] && echo -n "Cleaning /etc/container/php.handler" sed -i '/x-httpd-ea-php/d' "/etc/container/php.handler" [ "$VERBOSE" = "YES" ] && echo " done" fi } function add_handlers() { if [ ! -e /etc/container ]; then mkdir -p /etc/container fi addString "application/x-httpd-ea-php44-lsphp" "/opt/cpanel/ea-php44/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php51-lsphp" "/opt/cpanel/ea-php51/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php52-lsphp" "/opt/cpanel/ea-php52/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php53-lsphp" "/opt/cpanel/ea-php53/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php54-lsphp" "/opt/cpanel/ea-php54/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php55-lsphp" "/opt/cpanel/ea-php55/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php56-lsphp" "/opt/cpanel/ea-php56/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php70-lsphp" "/opt/cpanel/ea-php70/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php71-lsphp" "/opt/cpanel/ea-php71/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php72-lsphp" "/opt/cpanel/ea-php72/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php73-lsphp" "/opt/cpanel/ea-php73/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php74-lsphp" "/opt/cpanel/ea-php74/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-nf-php74-lsphp" "/opt/remi/php74/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php80-lsphp" "/opt/cpanel/ea-php80/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php81-lsphp" "/opt/cpanel/ea-php81/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php82-lsphp" "/opt/cpanel/ea-php82/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php83-lsphp" "/opt/cpanel/ea-php83/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php84-lsphp" "/opt/cpanel/ea-php84/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php44___lsphp" "/opt/cpanel/ea-php44/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php51___lsphp" "/opt/cpanel/ea-php51/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php52___lsphp" "/opt/cpanel/ea-php52/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php53___lsphp" "/opt/cpanel/ea-php53/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php54___lsphp" "/opt/cpanel/ea-php54/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php55___lsphp" "/opt/cpanel/ea-php55/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php56___lsphp" "/opt/cpanel/ea-php56/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php70___lsphp" "/opt/cpanel/ea-php70/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php71___lsphp" "/opt/cpanel/ea-php71/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php72___lsphp" "/opt/cpanel/ea-php72/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php73___lsphp" "/opt/cpanel/ea-php73/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php74___lsphp" "/opt/cpanel/ea-php74/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-nf-php74___lsphp" "/opt/remi/php74/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php80___lsphp" "/opt/cpanel/ea-php80/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php81___lsphp" "/opt/cpanel/ea-php81/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php82___lsphp" "/opt/cpanel/ea-php82/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php83___lsphp" "/opt/cpanel/ea-php83/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php84___lsphp" "/opt/cpanel/ea-php84/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php44___lsphp" "/opt/cloudlinux/alt-php44/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php51___lsphp" "/opt/cloudlinux/alt-php51/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php52___lsphp" "/opt/cloudlinux/alt-php52/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php53___lsphp" "/opt/cloudlinux/alt-php53/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php54___lsphp" "/opt/cloudlinux/alt-php54/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php55___lsphp" "/opt/cloudlinux/alt-php55/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php56___lsphp" "/opt/cloudlinux/alt-php56/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php70___lsphp" "/opt/cloudlinux/alt-php70/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php71___lsphp" "/opt/cloudlinux/alt-php71/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php72___lsphp" "/opt/cloudlinux/alt-php72/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php73___lsphp" "/opt/cloudlinux/alt-php73/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php74___lsphp" "/opt/cloudlinux/alt-php74/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php80___lsphp" "/opt/cloudlinux/alt-php80/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php81___lsphp" "/opt/cloudlinux/alt-php81/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php82___lsphp" "/opt/cloudlinux/alt-php82/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php83___lsphp" "/opt/cloudlinux/alt-php83/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php84___lsphp" "/opt/cloudlinux/alt-php84/root/usr/bin/lsphp" "/etc/container/php.handler" # Let's add version which still don't exist, for future addString "application/x-httpd-ea-php85-lsphp" "/opt/cpanel/ea-php85/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php86-lsphp" "/opt/cpanel/ea-php86/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php87-lsphp" "/opt/cpanel/ea-php87/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php88-lsphp" "/opt/cpanel/ea-php88/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php89-lsphp" "/opt/cpanel/ea-php89/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php90-lsphp" "/opt/cpanel/ea-php90/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php91-lsphp" "/opt/cpanel/ea-php91/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php92-lsphp" "/opt/cpanel/ea-php92/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php93-lsphp" "/opt/cpanel/ea-php93/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php94-lsphp" "/opt/cpanel/ea-php94/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php95-lsphp" "/opt/cpanel/ea-php95/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php96-lsphp" "/opt/cpanel/ea-php96/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php97-lsphp" "/opt/cpanel/ea-php97/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php98-lsphp" "/opt/cpanel/ea-php98/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php99-lsphp" "/opt/cpanel/ea-php99/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php85___lsphp" "/opt/cpanel/ea-php85/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php86___lsphp" "/opt/cpanel/ea-php86/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php87___lsphp" "/opt/cpanel/ea-php87/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php88___lsphp" "/opt/cpanel/ea-php88/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php89___lsphp" "/opt/cpanel/ea-php89/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php90___lsphp" "/opt/cpanel/ea-php90/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php91___lsphp" "/opt/cpanel/ea-php91/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php92___lsphp" "/opt/cpanel/ea-php92/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php93___lsphp" "/opt/cpanel/ea-php93/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php94___lsphp" "/opt/cpanel/ea-php94/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php95___lsphp" "/opt/cpanel/ea-php95/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php96___lsphp" "/opt/cpanel/ea-php96/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php97___lsphp" "/opt/cpanel/ea-php97/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php98___lsphp" "/opt/cpanel/ea-php98/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-ea-php99___lsphp" "/opt/cpanel/ea-php99/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php85___lsphp" "/opt/cloudlinux/alt-php85/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php86___lsphp" "/opt/cloudlinux/alt-php86/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php87___lsphp" "/opt/cloudlinux/alt-php87/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php88___lsphp" "/opt/cloudlinux/alt-php88/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php89___lsphp" "/opt/cloudlinux/alt-php89/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php90___lsphp" "/opt/cloudlinux/alt-php90/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php91___lsphp" "/opt/cloudlinux/alt-php91/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php92___lsphp" "/opt/cloudlinux/alt-php92/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php93___lsphp" "/opt/cloudlinux/alt-php93/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php94___lsphp" "/opt/cloudlinux/alt-php94/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php95___lsphp" "/opt/cloudlinux/alt-php95/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php96___lsphp" "/opt/cloudlinux/alt-php96/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php97___lsphp" "/opt/cloudlinux/alt-php97/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php98___lsphp" "/opt/cloudlinux/alt-php98/root/usr/bin/lsphp" "/etc/container/php.handler" addString "application/x-httpd-alt-php99___lsphp" "/opt/cloudlinux/alt-php99/root/usr/bin/lsphp" "/etc/container/php.handler" } if [ "$CMD" == "--uninstall" ]; then [ "$VERBOSE" = "YES" ] && echo "mod_lsapi uninstall started" # if [ -e /etc/apache2/conf.modules.d/001_mod_lsapi.conf ]; then # [ "$VERBOSE" = "YES" ] && echo -n "Removing /etc/apache2/conf.modules.d/001_mod_lsapi.conf..." # rm -f /etc/apache2/conf.modules.d/001_mod_lsapi.conf # [ "$VERBOSE" = "YES" ] && echo " done" # fi [ "$VERBOSE" = "YES" ] && echo -n "Changing enabled lsapi handler to default handler" uninstall_lsapi_handler [ "$VERBOSE" = "YES" ] && echo " done" #Disable all domains if exists in htaccess /usr/share/lve/modlscapi/utils/getdocroots.pm | while read line; do if [ -e "$line/.htaccess" ]; then [ "$VERBOSE" = "YES" ] && echo -n "Disabling mod_lsapi in $line..." sed -i '/lsphp -- BEGIN/,/lsphp -- END/d' "$line/.htaccess" sed -i '/x-httpd-lsphp/d' "$line/.htaccess" sed -i '/lsapi_engine/d' "$line/.htaccess" sed -i '/mod_lsapi/d' "$line/.htaccess" [ "$VERBOSE" = "YES" ] && echo " done" fi done ############ REMOVE PATCH FOR CPANEL, this part should be removed when cpanel will be provided with our patch # [ "$VERBOSE" = "YES" ] && echo -n "Restoring /usr/local/cpanel/Cpanel/WebServer/Supported/apache.pm..." # /usr/share/lve/modlscapi/utils/cpanel_hooks_manage.py -d # [ "$VERBOSE" = "YES" ] && echo " done" ###################### if [ -e /etc/container/php.handler ]; then [ "$VERBOSE" = "YES" ] && echo -n "Cleaning /etc/container/php.handler" sed -i '/x-httpd-ea-php/d' "/etc/container/php.handler" [ "$VERBOSE" = "YES" ] && echo " done" fi [ "$VERBOSE" = "YES" ] && echo "Rebuilding httpd config..." /scripts/rebuildhttpdconf [ "$VERBOSE" = "YES" ] && echo "Rebuilding httpd config done" echo "Reconfiguration completed" exit fi if [ "$CMD" == "--setup" ]; then oldUninstall [ "$VERBOSE" = "YES" ] && echo "mod_lsapi setup started" [ "$VERBOSE" = "YES" ] && echo -n "Adding php handlers..." add_handlers [ "$VERBOSE" = "YES" ] && echo " done" ############ INSTALL PATCH FOR CPANEL, this part should be removed when cpanel will be provided with our patch # if [ ! -e /usr/local/cpanel/Cpanel/WebServer/Supported/apache/Handler/lsapi.pm ]; then # [ "$VERBOSE" = "YES" ] && echo -n "Adding lsapi.pm to Cpanel..." # cp /usr/share/lve/modlscapi/tars/lsapi.pm /usr/local/cpanel/Cpanel/WebServer/Supported/apache/Handler/lsapi.pm # [ "$VERBOSE" = "YES" ] && echo " done" # fi # [ "$VERBOSE" = "YES" ] && echo -n "Patching Cpanel for lsapi handler..." # cp /usr/local/cpanel/Cpanel/WebServer/Supported/apache.pm /usr/local/cpanel/Cpanel/WebServer/Supported/apache.pm.bak # /usr/share/lve/modlscapi/hooks/lsapi_patch_cpanel_hook.sh # /usr/share/lve/modlscapi/utils/cpanel_hooks_manage.py -i # [ "$VERBOSE" = "YES" ] && echo " done" ######################## [ "$VERBOSE" = "YES" ] && echo "Checking for enabled global module..." check_enable_global [ "$VERBOSE" = "YES" ] && echo " done" [ "$VERBOSE" = "YES" ] && echo "Checking for enabled domain module..." check_enable_user [ "$VERBOSE" = "YES" ] && echo " done" [ "$VERBOSE" = "YES" ] && echo "Rebuilding httpd config..." /scripts/rebuildhttpdconf [ "$VERBOSE" = "YES" ] && echo "Rebuilding httpd config done" if [ ! -e /usr/local/bin/lsphp ]; then [ "$VERBOSE" = "YES" ] && echo "Setting up cl-selector for lsphp..." cp /opt/alt/php56/usr/bin/lsphp /usr/local/bin/ ln -s /usr/local/bin/lsphp /etc/cl.selector/lsphp if [ -e /usr/sbin/cagefsctl ]; then /usr/sbin/cagefsctl --update-etc fi RES="" if [ -e /etc/cl.selector/native.conf ]; then RES=`cat /etc/cl.selector/native.conf | grep lsphp=/usr/local/bin/lsphp ` fi if [ -z "$RES" ]; then echo "lsphp=/usr/local/bin/lsphp" >> /etc/cl.selector/native.conf fi if [ -e /usr/sbin/cagefsctl ]; then /usr/sbin/cagefsctl --setup-cl-selector fi [ "$VERBOSE" = "YES" ] && echo "Setting up cl-selector for lsphp done" fi CSF_CONFIG="/etc/csf/csf.pignore" CSF_MAIN_RULE="exe:/usr/local/bin/lsphp" CSF_ALT_RULE="pexe:/opt/alt/php.*/usr/bin/lsphp" CSF_SELECTOR_RULE="exe:/usr/selector/lsphp" CSF_EA_RULE="pexe:/opt/cpanel/ea-php*/root/usr/bin/lsphp" if [ -f "${CSF_CONFIG}" ]; then [ "$VERBOSE" = "YES" ] && echo "Setting up lfd service for lsphp..." [ -e "${CSF_CONFIG}.bkp" ] || cp "${CSF_CONFIG}" "${CSF_CONFIG}.bkp" grep -v '^[[:space:]]*#' "${CSF_CONFIG}" | grep -Fq "${CSF_MAIN_RULE}" || echo "${CSF_MAIN_RULE}" >> "$CSF_CONFIG" grep -v '^[[:space:]]*#' "${CSF_CONFIG}" | grep -Fq "${CSF_SELECTOR_RULE}" || echo "${CSF_SELECTOR_RULE}" >> "$CSF_CONFIG" grep -v '^[[:space:]]*#' "${CSF_CONFIG}" | grep -Fq "${CSF_EA_RULE}" || echo "${CSF_EA_RULE}" >> "$CSF_CONFIG" grep -v '^[[:space:]]*#' "${CSF_CONFIG}" | grep -Fq "${CSF_ALT_RULE}" || echo "${CSF_ALT_RULE}" >> "$CSF_CONFIG" service lfd restart 2>/dev/null >/dev/null [ "$VERBOSE" = "YES" ] && echo "Setting up lfd service for lsphp done" fi echo "Reconfiguration completed" exit fi if [ "$CMD" == "--setup-light" ]; then [ "$VERBOSE" = "YES" ] && echo -n "Adding php handlers..." add_handlers [ "$VERBOSE" = "YES" ] && echo " done" /usr/share/lve/modlscapi/utils/getdocroots.pm | while read HD; do if [ -e "$HD/.htaccess" ]; then [ "$VERBOSE" = "YES" ] && echo -n "Removing old mod_lsapi configuration (lsapi_engine off) in $HD..." if grep -qE '[[:space:]]*lsapi_engine*[[:space:]]*off' "$HD/.htaccess"; then sed -i '/[[:space:]]*lsapi_engine*[[:space:]]*off/d' "$HD/.htaccess" fi if grep -qE '[[:space:]]*lsapi_engine*[[:space:]]*Off' "$HD/.htaccess"; then sed -i '/[[:space:]]*lsapi_engine*[[:space:]]*Off/d' "$HD/.htaccess" fi fi [ "$VERBOSE" = "YES" ] && echo " done" done # [ "$VERBOSE" = "YES" ] && echo -n "Patching Cpanel for lsapi handler..." # cp /usr/local/cpanel/Cpanel/WebServer/Supported/apache.pm /usr/local/cpanel/Cpanel/WebServer/Supported/apache.pm.bak # /usr/share/lve/modlscapi/hooks/lsapi_patch_cpanel_hook.sh # /usr/share/lve/modlscapi/utils/cpanel_hooks_manage.py -i # [ "$VERBOSE" = "YES" ] && echo " done" exit fi if [ "$CMD" == "--enable-domain" ]; then echo "Deprecated for EA4, use MultiPHP Manager." exit fi if [ "$CMD" == "--disable-domain" ]; then echo "Deprecated for EA4, use MultiPHP Manager." exit fi if [ "$CMD" == "--enable-global" ]; then check_enable_global "YES" exit fi if [ "$CMD" == "--disable-global" ]; then echo "Deprecated for EA4, use MultiPHP Manager." exit fi if [ "$CMD" == "--build-native-lsphp" ]; then echo "Deprecated for EA4" exit fi echo "$0 [OPTION]" echo "utility for switching mod_lsapi on cPanel on or off (without mod_ruid2):" echo "--setup - setup mod_lsapi configurations for Apache" echo "--setup-light - setup only the EasyApache 4 feature" echo "--uninstall - uninstall mod_lsapi from Apache" echo "--enable-domain - enable mod_lsapi for an individual domain" echo "--disable-domain - disable mod_lsapi for an individual domain" echo "--enable-global - sets up mod_lsapi as a default way to serve PHP, making it enabled for all domains. Once that mode is enabled, you cannot disable mod_lsapi for individual domains" echo "--disable-global - disable mod_lsapi as a default way to serve PHP, disabling mod_lsapi for all domains, including those selected previously using --enable-domain" echo "--build-native-lsphp - build native lsphp for cPanel" echo "--verbose - switch verbose logging on" echo "--force - only with setup option (EA4)" echo "--help - show this help message" modlscapi/user/dashboard_malfunctions.py 0000644 00000002557 15125566744 0014610 0 ustar 00 # Copyright (c) Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2018 All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. criu_settings_malfunctions = { 'on_stopped': { 'reason': 'Criu service stopped', 'description': "Run 'service criu start' because lsapi_criu enabled through Apache configs" }, 'off_running': { 'reason': 'lsapi_criu disabled', 'description': "Set 'lsapi_criu On' through Apache configs because criu service is running" } } lsapi_settings_malfunctions = { 'disabled': { 'reason': 'Apache module lsapi_module is not loaded', 'description': "Enable mod_lsapi through Apache configs with 'LoadModule lsapi_module modules/mod_lsapi.so' directive" } } liblsapi_malfunctions = { None: { 'reason': 'No liblsapi found', 'description': "Install liblsapi package" } } modlscapi/user/stat_utils.py 0000644 00000022255 15125566744 0012267 0 ustar 00 # Copyright (c) Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2018 All Rights Reserved # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import string import sys import os import traceback import json import configparser from io import StringIO from pipes import quote import exec_command class StatUtilsException(Exception): pass def cpanel_whmapi(cmd, **kwargs): """ Perform cPanel WHM API console request and return data from result :param cmd: whm api command :return: data dict from result """ joined_kwargs = ' '.join([quote('{0}={1}'.format(k, v)) for k, v in kwargs.items()]) result = exec_command.exec_command("/usr/sbin/whmapi1 {cmd} {kw} --output json".format(cmd=cmd, kw=joined_kwargs)) try: dict_result = json.loads(''.join(result)) except ValueError: # if result is not JSON raise StatUtilsException( "Failed to get JSON from this API request: {0} {1}; output: {2}".format(cmd, joined_kwargs, ''.join(result))) try: return dict_result['data'] except KeyError: # if there are no data field in received JSON raise StatUtilsException("Failed to get data from this API result: {0}".format(dict_result)) def plesk_bin_php_handler(cmd, **kwargs): """ Perform Plesk php_handler utility console request and return result :param cmd: php_handler command :return: dict result """ # need to quote only value (-k 'v'), quoting full params ('-k v') causes API failure joined_kwargs = ' '.join(['-{0} {1}'.format(k, quote(v)) for k, v in kwargs.items()]) result = exec_command.exec_command("/usr/local/psa/bin/php_handler --{cmd} {kw} -json true".format(cmd=cmd, kw=joined_kwargs)) try: return json.loads(''.join(result)) except ValueError: raise StatUtilsException( "Failed to get JSON from this API request: php_handler {0} {1}; output: {2}".format(cmd, joined_kwargs, ''.join(result))) def get_da_domains(): """ Get domains per user :return: dict( user: list of domains ) """ da_users_path = '/usr/local/directadmin/data/users' da_domains_path = '/usr/local/directadmin/data/users/{user}/domains.list' da_users = os.listdir(da_users_path) domains = dict.fromkeys(da_users) try: for user in da_users: with open(da_domains_path.format(user=user), 'r') as domains_list_file: domains[user] = set([l.strip() for l in domains_list_file.readlines()]) except (OSError, IOError): raise StatUtilsException(''.join(traceback.format_exc().split('\n'))) return domains def get_da_php_options(): """ Get php settings from options.conf :return: dict( first php setting: {version, mode}, second php setting: {version, mode}, ) """ options_path = '/usr/local/directadmin/custombuild/options.conf' try: config_parser, global_section = read_da_config(options_path) php1_ver = config_parser.get(global_section, 'php1_release') php2_ver = config_parser.get(global_section, 'php2_release') php1_handler = config_parser.get(global_section, 'php1_mode') php2_handler = config_parser.get(global_section, 'php2_mode') except configparser.NoOptionError: raise StatUtilsException('No option found: {0}'.format(''.join(traceback.format_exc().split('\n')))) return { 1: { 'version': php1_ver, 'handler': 'lsapi' if php1_handler == 'lsphp' else php1_handler }, 2: { 'version': php2_ver, 'handler': 'lsapi' if php2_handler == 'lsphp' else php2_handler } } def read_da_config(conf_file, append_section_name='dummy_section'): """ Read DA config file with ConfigParser. Need to add dummy section for success :param conf_file: config file name :param append_section_name: name of section to place in the beginning of file :return: RawConfigParser instance """ try: with open(conf_file) as f: file_content = StringIO('[{s}]\n'.format(s=append_section_name) + f.read()) config_parser = configparser.RawConfigParser(strict=False) config_parser.read_file(file_content) except (OSError, IOError): raise StatUtilsException(''.join(traceback.format_exc().split('\n'))) return config_parser, append_section_name def pretty_version_keys(php_ver, pre='php'): """ Convert simple php versions to pretty format :param php_ver: {major}.{minor} version :param pre: desired key start :return: alt-php{major}{minor} or desired `pre`{major}{minor} """ template = '{0}%s%s'.format(pre) try: return template % tuple(php_ver.split('.')) except Exception: return php_ver def dump_lsapi(ctl_path='/usr/sbin/httpd'): """ Get `httpd -t -D DUMP_RUN_LSAPI` info For httpd24 this default path is `/opt/rh/httpd24/root/usr/sbin/httpd`, generated in make_from_templates.sh script :param ctl_path: path to httpd (also apachectl may be used) :return: dict( lsapi_option: value ) """ apache_conf_data = exec_command.exec_command('{ctl} -t -D DUMP_RUN_LSAPI'.format(ctl=ctl_path)) try: return dict([l.lower().split(' ') for l in apache_conf_data]) except: return dict() def dump_loaded_modules(ctl_path='/usr/sbin/httpd'): """ Get `httpd -M` For httpd24 this default path is `/opt/rh/httpd24/root/usr/sbin/httpd`, generated in make_from_templates.sh script :param ctl_path: path to httpd (also apachectl may be used) :return: dict( apache_module: value ) """ apache_modules = exec_command.exec_command('{ctl} -M'.format(ctl=ctl_path)) try: return dict([l.lower().split(' ') for l in apache_modules]) except: return dict() def liblsapi_path(): """ Retrieve path to liblsapi, depends on arch :return: path to liblsapi """ is_64bits = sys.maxsize > 2**32 return '/usr/lib{a}/liblscapi.so'.format(a='64' if is_64bits else '') def rpm_query(pkg): """ Get version-release from rpm -q `pkg` :param pkg: package name to query :return: version-release """ try: ver, rel = ''.join(exec_command.exec_command('/bin/rpm -q ' + pkg + ' --qf %{v}-%{r}')).split('-') return '{ver}-{rel}'.format(ver=ver, rel=rel.split('.')[0]) except ValueError: return None def query_strings(fname, template): """ Filter strings by given template Also split string upon given template :param fname: path to file :param template: template to find in string :return: first template occurrence splitted by template """ try: return [l for l in strings(fname) if template in l][0].split(template)[1].strip() except (IndexError, IOError, OSError): return None def strings(fname, n=6): """ Strings utility analog. Finds printable strings in executable :param fname: path to file :param n: minimum string length :return: generator, yeilds string """ with open(fname, errors='ignore') as f: result = "" for c in f.read(): if c in string.printable: result += c continue if len(result) >= n: yield result result = "" if len(result) >= n: # catch result at EOF yield result def count_domains(handler_struct, default_keys, only_lsapi=True): """ Count domains :param handler_struct: handler: version: set_of_domains structure :param default_keys: sequence of keys to add as default if no `lsapi` found :param only_lsapi: return only lsapi statistics :return: statistics - number of lsapi domains per version if only_lsapi=True number of lsapi domains per version per handler otherwise """ result_stat = dict() for h, data in handler_struct.items(): result_stat[h] = dict((k, len(v)) for k, v in data.items()) # if there are no lsapi handler domains, return 0 per each installed version try: return result_stat['lsapi'] if only_lsapi else result_stat except KeyError: return dict.fromkeys([x for x in default_keys if x != 'no'], 0) modlscapi/user/__pycache__/lve_diagnostic.cpython-39.pyc 0000644 00000032265 15125566744 0017357 0 ustar 00 a ��6i�5 � @ s� d dl Z d dlmZ dd� ZG dd� d�ZG dd� d�Zd d � Zdd� ZG d d� d�ZG dd� d�Z G dd� de �Z G dd� de �ZG dd� de �ZG dd� de �Z G dd� de �ZG dd� de �ZG dd� de �Zdd � Zd!d"� Zd#d$� ZdS )%� N)�versionc C s t �| �}|�� S �N)�os�popen�read)�strZhandle� r �//usr/share/lve/modlscapi/user/lve_diagnostic.py�myExec s r c @ s( e Zd ZdZdZdZdZdZdd� ZdS )� LiteSpeedF�Unknownc C s^ t j�d�| _t j�d�rZttd��d��dkrZd| _dtd�v | _d td �v| _td�}d S )Nz/usr/local/lswsz/usr/local/lsws/bin/litespeedzps aux|grep litespeed� � T�1z4grep enableLVE /usr/local/lsws/conf/httpd_config.xml�0z$grep -i phpSuexec\> httpd_config.xmlz%file -L /usr/local/lsws/bin/litespeed) r �path�isfile�exist�lenr �split�lve�suexec)�selfZarchr r r �__init__ s "zLiteSpeed.__init__N) �__name__� __module__�__qualname__r r r r ZcorrectArchr r r r r r s r c @ st e Zd ZdZdZdZdZdZdZdZ dZ dZdZdZ dZdZdZdd� Zdd� Zdd� Zd d � Zdd� Zd d� ZdS )� ApacheInfoFr c C s | � |� d S r )�detect)r r r r r r 8 s zApacheInfo.__init__c C s2 t �| j �t �d�krdS tdd| jj � dS d S )Nz2.2.0Ti� z=Unable to determine list of loaded modules, apache version %sF)r �LooseVersion� print_warning�apache�r r r r � check_version; s zApacheInfo.check_versionc C s t | j�d| d �dk�S )N� �_module���)r �modules�find)r �namer r r �isModuleB s zApacheInfo.isModulec C sv | j rr| �d�| _| �d�| _| �d�| _| �d�| _| �d�| _| �d�| _| �d�| _| �d�| _ | �d �| _ d S ) N� hostinglimits�fcgidZphp5�cgi�cgid�suPHP�fastcgi�disable_suexecr )� moduleInfor* r+ r, �php_dsor- r. r/ r0 r1 r r"