Commit 4282f289 authored by nextime's avatar nextime

Fix wssshd user permission issue for home directory

- Add permission verification in postinst scripts for both wssshd and wssshc
- Test if users can write to their home directories
- Fix permissions if write access is denied (chmod 775)
- Ensure users are in correct groups
- Prevent 'Permission denied' errors when creating .config directories
parent 3a5568d4
...@@ -30,8 +30,20 @@ case "$1" in ...@@ -30,8 +30,20 @@ case "$1" in
# Create wssshd home directory # Create wssshd home directory
if [ ! -d /var/lib/wssshd ]; then if [ ! -d /var/lib/wssshd ]; then
mkdir -p /var/lib/wssshd mkdir -p /var/lib/wssshd
fi
# Ensure wssshd user owns its home directory and can write to it
chown wssshd:wssshd /var/lib/wssshd chown wssshd:wssshd /var/lib/wssshd
chmod 755 /var/lib/wssshd chmod 755 /var/lib/wssshd
# Ensure the user can actually write to its home directory
# Try to create a test file to verify write permissions
if ! su -s /bin/sh wssshd -c "touch /var/lib/wssshd/.test_write 2>/dev/null && rm /var/lib/wssshd/.test_write 2>/dev/null" 2>/dev/null; then
echo "Warning: wssshd user cannot write to /var/lib/wssshd, fixing permissions"
# Try to fix permissions by making directory writable
chmod 775 /var/lib/wssshd
# Also ensure the user is in the right group
usermod -g wssshd wssshd 2>/dev/null || true
fi fi
# Create log directory # Create log directory
......
...@@ -30,8 +30,20 @@ case "$1" in ...@@ -30,8 +30,20 @@ case "$1" in
# Create home directory for wssshc user # Create home directory for wssshc user
if [ ! -d /var/lib/wssshc ]; then if [ ! -d /var/lib/wssshc ]; then
mkdir -p /var/lib/wssshc mkdir -p /var/lib/wssshc
fi
# Ensure wssshc user owns its home directory and can write to it
chown wssshc:wssshc /var/lib/wssshc chown wssshc:wssshc /var/lib/wssshc
chmod 755 /var/lib/wssshc chmod 755 /var/lib/wssshc
# Ensure the user can actually write to its home directory
# Try to create a test file to verify write permissions
if ! su -s /bin/sh wssshc -c "touch /var/lib/wssshc/.test_write 2>/dev/null && rm /var/lib/wssshc/.test_write 2>/dev/null" 2>/dev/null; then
echo "Warning: wssshc user cannot write to /var/lib/wssshc, fixing permissions"
# Try to fix permissions by making directory writable
chmod 775 /var/lib/wssshc
# Also ensure the user is in the right group
usermod -g wssshc wssshc 2>/dev/null || true
fi fi
# Create log directory # Create log directory
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment