Skip to content

Commit 412f56d

Browse files
committed
tweak(installer): set additional security constants to the wp-config (if wp installed)
changelog: tweaks
1 parent 530c95d commit 412f56d

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
## Script status
1212

13-
Version: v3.1.1.894
14-
Build: 894
13+
Version: v3.1.1.895
14+
Build: 895
1515

1616
[![MIT License](https://img.shields.io/badge/license-MIT%20License-blue.svg?style=flat-square)](https://github.com/JMSDOnline/vstacklet/blob/main/LICENSE)
1717

bin/www-permissions.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
################################################################################
33
# <START METADATA>
44
# @file_name: www-permissions.sh
5-
# @version: 3.1.1095
5+
# @version: 3.1.1096
66
# @description: This script will add a new www-data group on your server
77
# and set permissions for ${www_root:-/var/www/html/vsapp}.
88
# Please ensure you have read the documentation before continuing.
@@ -342,27 +342,27 @@ vstacklet::vsperms::adjust() {
342342
vstacklet::shell::text::error "failed to change directory permissions of ${www_root:-/var/www/html/vsapp} to 2755."
343343
exit 1
344344
}
345-
# @script-note: change the permissions of files under web root ${www_root} to 0664
346-
vstacklet::shell::text::white "changing file permissions of ${www_root:-/var/www/html/vsapp} to 0664 ... "
347-
find "${www_root:-/var/www/html/vsapp}" -type f -exec chmod -R 0664 {} + || {
348-
vstacklet::shell::text::error "failed to change file permissions of ${www_root:-/var/www/html/vsapp} to 0664."
345+
# @script-note: change the permissions of files under web root ${www_root} to 0444
346+
vstacklet::shell::text::white "changing file permissions of ${www_root:-/var/www/html/vsapp} to 0444 ... "
347+
find "${www_root:-/var/www/html/vsapp}" -type f -exec chmod -R 0444 {} + || {
348+
vstacklet::shell::text::error "failed to change file permissions of ${www_root:-/var/www/html/vsapp} to 0444."
349349
exit 1
350350
}
351351
# @script-note: change file permissions on config files (this is useful for WordPress installations)
352-
# Check the directory for wp-config.php and set the permissions to 0644
352+
# Check the directory for wp-config.php and set the permissions to 0444
353353
if [[ -n $(find "${www_root:-/var/www/html/vsapp}" -type f -name "wp-config.php") ]]; then
354-
vstacklet::shell::text::white "changing permissions of wp-config.php to 0644 ... "
355-
find "${www_root:-/var/www/html/vsapp}" -type f -name "wp-config.php" -exec chmod 0644 {} + || {
356-
vstacklet::shell::text::error "failed to change permissions of wp-config.php to 0644."
354+
vstacklet::shell::text::white "changing permissions of wp-config.php to 0444 ... "
355+
find "${www_root:-/var/www/html/vsapp}" -type f -name "wp-config.php" -exec chmod 0444 {} + || {
356+
vstacklet::shell::text::error "failed to change permissions of wp-config.php to 0444."
357357
exit 1
358358
}
359359
fi
360-
# @script-note: check the directories for any .conf files and set the permissions to 0644 (this is useful for Nginx configurations)
360+
# @script-note: check the directories for any .conf files and set the permissions to 0444 (this is useful for Nginx configurations)
361361
# Check several levels deep for .conf files
362362
if [[ -n $(find "${www_root:-/var/www/html/vsapp}" -type f -name "*.conf") ]]; then
363-
vstacklet::shell::text::white "changing permissions of ${www_root:-/var/www/html/vsapp}/*.conf to 0644 ... "
364-
find "${www_root:-/var/www/html/vsapp}" -type f -name "*.conf" -exec chmod 0644 {} + || {
365-
vstacklet::shell::text::error "failed to change permissions of ${www_root:-/var/www/html/vsapp}/*.conf to 0644."
363+
vstacklet::shell::text::white "changing permissions of ${www_root:-/var/www/html/vsapp}/*.conf to 0444 ... "
364+
find "${www_root:-/var/www/html/vsapp}" -type f -name "*.conf" -exec chmod 0444 {} + || {
365+
vstacklet::shell::text::error "failed to change permissions of ${www_root:-/var/www/html/vsapp}/*.conf to 0444."
366366
exit 1
367367
}
368368
fi

docs/bin/www-permissions.sh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# www-permissions.sh - v3.1.1095
1+
# www-permissions.sh - v3.1.1096
22

33

44
---

docs/setup/vstacklet-server-stack.sh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# vstacklet-server-stack.sh - v3.1.2237
1+
# vstacklet-server-stack.sh - v3.1.2238
22

33

44
---

setup/vstacklet-server-stack.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
##################################################################################
33
# <START METADATA>
44
# @file_name: vstacklet-server-stack.sh
5-
# @version: 3.1.2237
5+
# @version: 3.1.2238
66
# @description: Lightweight script to quickly install a LEMP stack with Nginx,
77
# Varnish, PHP7.4/8.1/8.3 (PHP-FPM), OPCode Cache, IonCube Loader, MariaDB, Sendmail
88
# and more on a fresh Ubuntu 20.04/22.04 or Debian 11/12 server for
@@ -912,7 +912,7 @@ vstacklet::dependencies::array() {
912912
# @script-note: install base dependencies
913913
declare -ga base_dependencies=("rsync" "dos2unix" "jq" "bc" "automake" "make" "cmake" "checkinstall" "nano" "zip" "unzip" "htop" "vnstat" "vnstati" "vsftpd" "subversion" "iptables" "iptables-persistent" "ssh")
914914
# @script-note: install php dependencies
915-
declare -ga php_dependencies=("php${php}-fpm" "php${php}-zip" "php${php}-cgi" "php${php}-cli" "php${php}-common" "php${php}-curl" "php${php}-dev" "php${php}-gd" "php${php}-bcmath" "php${php}-gmp" "php${php}-imap" "php${php}-intl" "php${php}-ldap" "php${php}-mbstring" "php${php}-opcache" "php${php}-pspell" "php${php}-readline" "php${php}-soap" "php${php}-xml" "php${php}-imagick" "php${php}-msgpack" "php${php}-igbinary" "libmcrypt-dev" "mcrypt" "libmemcached-dev" "php-memcached")
915+
declare -ga php_dependencies=("php${php}-fpm" "php${php}-zip" "php${php}-cgi" "php${php}-cli" "php${php}-common" "php${php}-curl" "php${php}-dev" "php${php}-gd" "php${php}-bcmath" "php${php}-gmp" "php${php}-imap" "php${php}-intl" "php${php}-ldap" "php${php}-mbstring" "php${php}-opcache" "php${php}-pspell" "php${php}-readline" "php${php}-soap" "php${php}-xml" "php${php}-imagick" "php${php}-msgpack" "php${php}-igbinary" "libmcrypt-dev" "mcrypt" "libmemcached-dev" "php-memcached" "php${php}-ssh2")
916916
[[ -n ${redis} ]] && php_dependencies+=("php${php}-redis")
917917
[[ -n ${mariadb} || -n ${mysql} ]] && php_dependencies+=("php${php}-mysql")
918918
# @script-note: install hhvm dependencies
@@ -3083,6 +3083,8 @@ vstacklet::wordpress::install() {
30833083
# @script-note: import updated salt keys
30843084
wp_salts=$(curl -s https://api.wordpress.org/secret-key/1.1/salt/)
30853085
sed -i "/#@-/r /dev/stdin" "${web_root:-/var/www/html/vsapp}/public/wp-config.php" <<<"${wp_salts}"
3086+
# @script-note: add security constants to wp-config.php (disable file editor and set FS_METHOD to ssh2 for secure file transfers)
3087+
sed -i "/Add any custom values between this line and the \"stop editing\" line./a \\\n/**\n * The plugins and themes file editor is a very convenient tool because it\n * enables you to make quick changes without the need to use FTP.\n *\n * Unfortunately, it's also a security issue because it not only shows the\n * PHP source code, it also enables attackers to inject malicious code into\n * your site if they manage to gain access to admin.\n * To prevent this, you can disable the file editor.\n *\n * @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/#disable-the-plugin-and-theme-file-editor\n */\n\ndefine('DISALLOW_FILE_EDIT', true);\ndefine('FS_METHOD', 'ssh2');\n" "${web_root:-/var/www/html/vsapp}/public/wp-config.php"
30863088
# @script-note: create the database
30873089
mysql -e "CREATE DATABASE ${wp_db_name};" >>"${vslog}" 2>&1 || vstacklet::error::display 102
30883090
if [[ "${db_user_present}" != "1" ]]; then

0 commit comments

Comments
 (0)