Skip to content

Commit 56d7b87

Browse files
authored
Merge pull request #32 from menny/permissions-fix
Ensuring ACTUAL_USER has access to the right files
2 parents f356639 + 658528e commit 56d7b87

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

.github/versions.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
IMAGE_VERSION=1.21.6
1+
IMAGE_VERSION=1.21.7
22
NDK_VERSION=27.2.12479018
33
BAZELISK_VERSION=v1.26.0

android_dev/entrypoint.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,34 @@ git clone --branch "${GIT_BRANCH}" "https://${GIT_PROVIDER}/${GIT_REPO}" "${CLON
2626
echo "cd $CLONE_DIR" >> "/home/${ACTUAL_USER}/.zshrc"
2727

2828
# --- 2. Set Permissions ---
29+
30+
# Function to fix ownership and permissions for a directory
31+
fix_dir_permissions() {
32+
local dir_path=$1
33+
echo "Fixing permissions for ${dir_path}..."
34+
chown -R ${ACTUAL_USER}:${ACTUAL_USER} "${dir_path}"
35+
find "${dir_path}" -type d -exec chmod 700 {} +
36+
find "${dir_path}" -type f -exec chmod 600 {} +
37+
}
38+
39+
# Function to fix ownership for a file
40+
fix_file_owner() {
41+
local file_path=$1
42+
echo "Fixing ownership for ${file_path}..."
43+
chown ${ACTUAL_USER}:${ACTUAL_USER} "${file_path}"
44+
}
45+
2946
echo "Setting permissions for user '${ACTUAL_USER}' on '${CLONE_DIR}'..."
3047
# Give the user ownership of the newly cloned repository folder
3148
chown -R ${ACTUAL_USER}:${ACTUAL_USER} "${CLONE_DIR}"
3249

50+
# Fix permissions for mounted directories and files
51+
fix_dir_permissions "/home/${ACTUAL_USER}/.ssh"
52+
fix_dir_permissions "/home/${ACTUAL_USER}/.gnupg"
53+
fix_dir_permissions "/home/${ACTUAL_USER}/.gemini"
54+
fix_dir_permissions "/home/${ACTUAL_USER}/shared_srv"
55+
fix_file_owner "/home/${ACTUAL_USER}/.gitconfig"
56+
3357
# --- 3. Set User Password ---
3458
# Check if the ACTUAL_PASSWORD environment variable is provided
3559
if [ -n "$ACTUAL_PASSWORD" ]; then
@@ -39,8 +63,9 @@ if [ -n "$ACTUAL_PASSWORD" ]; then
3963
echo "Password has been set."
4064
else
4165
# Warn the user if the password is not set
42-
echo "WARNING: No 'ACTUAL_PASSWORD' environment variable found."
66+
echo "ERROR: No 'ACTUAL_PASSWORD' environment variable found."
4367
echo "User '${ACTUAL_USER}' will not have a password set, and password-based SSH may fail."
68+
exit 1
4469
fi
4570

4671
# --- 4. Start SSH Server ---

0 commit comments

Comments
 (0)