container-xrdp
container-xrdp copied to clipboard
userlist / uid
Adding the username, password and sudo as argument is simple and very convenient.
Still, for more complicated setups, I would wish to define users and passwords as a list. Further, in my case, predefined UIDs are important to ensure access to shared volumes.
Would you accept a PR to run this script (link) when /etc/users.list
exists and go for the existing solution, with the arguments, in case the file is missing?
It is a good idea, but all containers must be zero-config for all users. The additional config can be added if someone wants more functionality. It looks only need to add this test:
test -f /etc/users.list || exit 0
Can you attach an example for user.list
?
The users.list
has the following format: id username password-hash list-of-supplemental-groups
E.g.: 1005 johndoe $1$6kLbPAuX$Wzw7rZNFedew3RLRCiXJb0 sudo
The following part would need to be added to your entrypoint script:
test -f /etc/users.list && {
while read id username hash groups; do
# Skip, if user already exists
grep ^$username /etc/passwd && continue
# Create group
addgroup --gid $id $username
# Create user
useradd -m -u $id -s /bin/bash -g $username $username
# Set password
echo "$username:$hash" | /usr/sbin/chpasswd -e
# Add supplemental groups
if [ $groups ]; then
usermod -aG $groups $username
fi
done < /etc/users.list
}
test -f /etc/users.list || {
# your user creation code
}
Sound good. Feel free to do a PR, and I will test it.