File manager - Edit - /usr/share/l.v.e-manager/utils/plesk-cgi.sh
Back
#!/bin/bash # Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2019 All Rights Reserved # # Licensed under CLOUD LINUX LICENSE AGREEMENT # http://cloudlinux.com/docs/LICENSE.TXT mkdir -p /usr/share/lve/plesk/script/domini-cgi cd /usr/share/lve/plesk/script/domini-cgi || exit 1 # Reject any path component that is not a plain domain label (letters, # digits, dot, dash, underscore). Customer-writable subdomains/ trees # allow leading dashes or whitespace in directory names; expanding those # unquoted into the privileged psa CLI is argument injection. _is_valid_name() { case "$1" in -*|*[!a-zA-Z0-9._-]*|"") return 1 ;; *) return 0 ;; esac } # Use a NUL-delimited find listing instead of `ls | for` so spaces and # newlines in directory names cannot word-split. while IFS= read -r -d '' domini_path; do domini=$(basename "$domini_path") _is_valid_name "$domini" || continue touch "/usr/share/lve/plesk/script/domini-cgi/$domini" done < <(find /var/www/vhosts -mindepth 1 -maxdepth 1 -type d -print0 2>/dev/null) # rm -rf /usr/share/lve/plesk/script/domini-cgi/default rm -rf /usr/share/lve/plesk/script/domini-cgi/chroot ############################################## ls -1 /usr/share/lve/plesk/script/domini-cgi/ > /usr/share/lve/plesk/script/domini_cgi.txt ############################################## while IFS= read -r sottodomini_cgi; do _is_valid_name "$sottodomini_cgi" || continue sub_dir="/var/www/vhosts/$sottodomini_cgi/subdomains" [ -d "$sub_dir" ] || continue while IFS= read -r -d '' sub_path; do sub_name=$(basename "$sub_path") _is_valid_name "$sub_name" || continue printf '%s\n' "$sub_name" >> "/usr/share/lve/plesk/script/domini-cgi/$sottodomini_cgi" done < <(find "$sub_dir" -mindepth 1 -maxdepth 1 -type d -print0 2>/dev/null) done < /usr/share/lve/plesk/script/domini_cgi.txt ############################################### while IFS= read -r cgi; do _is_valid_name "$cgi" || continue cgi_file="/usr/share/lve/plesk/script/domini-cgi/$cgi" [ -f "$cgi_file" ] || continue while IFS= read -r cgic; do _is_valid_name "$cgic" || continue # No `--` end-of-options marker here: /usr/local/psa/bin/{subdomain,domain} # uses non-GNU single-dash long options (-domain, -cgi, -nginx-serve-php), # and inserting `--` ahead of them risks Plesk's parser treating the # single-dash names as positionals. The leading-dash defence is already # handled by _is_valid_name above (rejects any "$cgi"/"$cgic" that # starts with '-'), so the privileged CLI sees only well-formed names. /usr/local/psa/bin/subdomain --update "$cgic" -domain "$cgi" -cgi true done < "$cgi_file" /usr/local/psa/bin/domain --update "$cgi" -cgi true /usr/local/psa/bin/domain --update-web-server-settings "$cgi" -nginx-serve-php false done < <(find /usr/share/lve/plesk/script/domini-cgi -mindepth 1 -maxdepth 1 -printf '%f\n' 2>/dev/null) ################################################ rm -rf /usr/share/lve/plesk/script/domini-cgi/ rm -rf /usr/share/lve/plesk/script/domini_cgi.txt ################################################ exit
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings