users: Flush nscd cache after user operations

nscd monitors files in /etc and invalidates the cache automatically when
they change.  However, for other mechanisms it recommends issuing a
manual flush in its manual page.  Flush nscd passwd and group database
caches after all user operations (not just rename operation, just to be
sure).
This commit is contained in:
Sunil Mohan Adapa 2016-08-23 21:39:57 +05:30 committed by James Valleroy
parent 0e4a722147
commit d9197111d8
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 19 additions and 0 deletions

View File

@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
- help: Minor updates and fixes to status log.
- Updated translations to fix weblate errors.
- Fixed spelling errors in datetime and letsencrypt modules.
- users: Flush nscd cache after user operations.
### Changed
- dynamicdns, transmission, upgrades: Allowed Plinth to run as non-root.

View File

@ -34,6 +34,8 @@ create_user()
ldapadduser $username users > /dev/null
set_user_password $username $password
flush_cache
}
@ -48,6 +50,8 @@ delete_user()
while read -r group; do
ldapdeleteuserfromgroup $username $group > /dev/null || true
done <<< "$groups"
flush_cache
}
@ -64,6 +68,8 @@ rename_user()
ldapdeleteuserfromgroup $old_username $group > /dev/null || true
ldapaddusertogroup $new_username $group > /dev/null || true
done <<< "$groups"
flush_cache
}
@ -95,6 +101,8 @@ add_user_to_group()
ldapaddgroup $groupname > /dev/null 2>&1 || true
ldapaddusertogroup $username $groupname > /dev/null
flush_cache
}
@ -104,6 +112,16 @@ remove_user_from_group()
groupname="$2"
ldapdeleteuserfromgroup $username $groupname > /dev/null
flush_cache
}
flush_cache()
{
# Flush nscd cache
nscd --invalidate=passwd
nscd --invalidate=group
}