Skip to content

Commit d32449f

Browse files
authored
Merge pull request #187 from Automattic/pltfrm-2068-permissionnot-found-errors-in-lando-entrypoint-scripts
fix: bugs in entrypoint scripts
2 parents 7d94e07 + 99ec53d commit d32449f

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

plugins/lando-core/scripts/lando-entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if [ ! -f "/tmp/lando-started" ]; then
2828
fi
2929

3030
# Executable all the helpers
31-
if [ -d "/helpers" ]; then
31+
if [ -d "/helpers" ] && [ -w "/helpers" ]; then
3232
chmod +x /helpers/* || true
3333
fi;
3434

plugins/lando-core/scripts/user-perm-helpers.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ perm_sweep() {
7777
local OTHER_DIR=$3
7878

7979
# Start with the directories that are likely blockers
80-
chown -R $USER:$GROUP /usr/local/bin
80+
if [ -d /usr/local/bin ]; then
81+
chown -R "${USER}:${GROUP}" /usr/local/bin
82+
fi
8183
chown $USER:$GROUP /var/www
8284
chown $USER:$GROUP /app
8385
chmod 755 /var/www
@@ -89,18 +91,19 @@ perm_sweep() {
8991

9092
# Do a background sweep
9193
nohup find /app -not -user $USER -execdir chown $USER:$GROUP {} \+ > /tmp/perms.out 2> /tmp/perms.err &
92-
nohup find /var/www/.ssh -not -user $USER -execdir chown $USER:$GROUP {} \+ > /tmp/perms.out 2> /tmp/perms.err &
9394
nohup find /user/.ssh -not -user $USER -execdir chown $USER:$GROUP {} \+ > /tmp/perms.out 2> /tmp/perms.err &
9495
nohup find /var/www -not -user $USER -execdir chown $USER:$GROUP {} \+ > /tmp/perms.out 2> /tmp/perms.err &
95-
nohup find /usr/local/bin -not -user $USER -execdir chown $USER:$GROUP {} \+ > /tmp/perms.out 2> /tmp/perms.err &
9696
nohup chmod -R 755 /var/www >/dev/null 2>&1 &
97-
98-
# Lets also make some /usr/locals chowned
99-
nohup find /usr/local/lib -not -user $USER -execdir chown $USER:$GROUP {} \+ > /tmp/perms.out 2> /tmp/perms.err &
100-
nohup find /usr/local/share -not -user $USER -execdir chown $USER:$GROUP {} \+ > /tmp/perms.out 2> /tmp/perms.err &
101-
nohup find /usr/local -not -user $USER -execdir chown $USER:$GROUP {} \+ > /tmp/perms.out 2> /tmp/perms.err &
97+
if [ -d /usr/local ]; then
98+
nohup find /usr/local -not -user $USER -execdir chown $USER:$GROUP {} \+ > /tmp/perms.out 2> /tmp/perms.err &
99+
fi
102100

103101
# Make sure we chown the $USER home directory
104-
nohup find $(getent passwd $USER | cut -d : -f 6) -not -user $USER -execdir chown $USER:$GROUP {} \+ > /tmp/perms.out 2> /tmp/perms.err &
102+
if command -v getent > /dev/null 2>&1; then
103+
home_dir="$(getent passwd $USER | cut -d : -f 6)"
104+
if [ -n "${home_dir}" ] && [ -d "${home_dir}" ]; then
105+
nohup find "${home_dir}" -not -user $USER -execdir chown $USER:$GROUP {} \+ > /tmp/perms.out 2> /tmp/perms.err &
106+
fi
107+
fi
105108
nohup find /lando -not -user $USER -execdir chown $USER:$GROUP {} \+ > /tmp/perms.out 2> /tmp/perms.err &
106109
}

plugins/lando-core/scripts/user-perms.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,4 @@ lando_info "$LANDO_WEBROOT_USER:$LANDO_WEBROOT_GROUP is now running as $(id $LAN
101101
# Make sure we set the ownership of the mount and HOME when we start a service
102102
lando_info "And here. we. go."
103103
lando_info "Doing the permission sweep."
104-
perm_sweep $LANDO_WEBROOT_USER $(getent group "$LANDO_HOST_GID" | cut -d: -f1) $LANDO_RESET_DIR
104+
perm_sweep $LANDO_WEBROOT_USER "${LANDO_HOST_GID}" $LANDO_RESET_DIR

0 commit comments

Comments
 (0)