mirror of
https://github.com/atmoz/sftp.git
synced 2024-11-17 12:51:33 -05:00
Merge branch 'fix_chown_on_alpine' of https://github.com/thoralf-gutierrez/sftp into thoralf-gutierrez-fix_chown_on_alpine
This commit is contained in:
commit
77c0fd7860
1 changed files with 6 additions and 2 deletions
|
@ -62,6 +62,10 @@ function createUser() {
|
||||||
chown root:root /home/$user
|
chown root:root /home/$user
|
||||||
chmod 755 /home/$user
|
chmod 755 /home/$user
|
||||||
|
|
||||||
|
# Retrieving user id to use it in chown commands instead of the user name
|
||||||
|
# to avoid problems on alpine when the user name contains a '.'
|
||||||
|
uid=`id $user -u`
|
||||||
|
|
||||||
if [ -n "$pass" ]; then
|
if [ -n "$pass" ]; then
|
||||||
echo "$user:$pass" | chpasswd $chpasswdOptions
|
echo "$user:$pass" | chpasswd $chpasswdOptions
|
||||||
else
|
else
|
||||||
|
@ -71,7 +75,7 @@ function createUser() {
|
||||||
# Add SSH keys to authorized_keys with valid permissions
|
# Add SSH keys to authorized_keys with valid permissions
|
||||||
if [ -d /home/$user/.ssh/keys ]; then
|
if [ -d /home/$user/.ssh/keys ]; then
|
||||||
cat /home/$user/.ssh/keys/* >> /home/$user/.ssh/authorized_keys
|
cat /home/$user/.ssh/keys/* >> /home/$user/.ssh/authorized_keys
|
||||||
chown $user /home/$user/.ssh/authorized_keys
|
chown $uid /home/$user/.ssh/authorized_keys
|
||||||
chmod 600 /home/$user/.ssh/authorized_keys
|
chmod 600 /home/$user/.ssh/authorized_keys
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -82,7 +86,7 @@ function createUser() {
|
||||||
dirPath=/home/$user/$dirPath
|
dirPath=/home/$user/$dirPath
|
||||||
echo "Creating and/or setting permissions on $dirPath"
|
echo "Creating and/or setting permissions on $dirPath"
|
||||||
mkdir -p $dirPath
|
mkdir -p $dirPath
|
||||||
chown -R $user:users $dirPath
|
chown -R $uid:users $dirPath
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue