0
0
Fork 0
mirror of https://github.com/atmoz/sftp.git synced 2024-12-22 13:14:42 -05:00

Use getent to check the existence of user/group

This commit is contained in:
Adrian Dvergsdal 2017-10-13 23:31:17 +02:00
parent f315792bd7
commit 0fba0da794
No known key found for this signature in database
GPG key ID: C1E9E2D9552A42D2

View file

@ -51,7 +51,7 @@ function createUser() {
gid="${args[$[$index+3]]}"; validateArg "GID" "$gid" "$reGid" || return 1
dir="${args[$[$index+4]]}"; validateArg "dirs" "$dir" "$reDir" || return 1
if $(cat /etc/passwd | cut -d: -f1 | grep -q "^$user:"); then
if getent passwd $user > /dev/null; then
log "WARNING: User \"$user\" already exists. Skipping."
return 0
fi
@ -63,7 +63,7 @@ function createUser() {
fi
if [ -n "$gid" ]; then
if ! $(cat /etc/group | cut -d: -f3 | grep -q "$gid"); then
if ! getent group $gid > /dev/null; then
groupadd --gid $gid "group_$gid"
fi