From 4b1c465944c3722edb6c24016663ad7b7b15e553 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 7 Aug 2017 17:22:38 -0400 Subject: [PATCH] sys-user.eclass: add a sys-user_modify() function. --- eclass/sys-user.eclass | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/eclass/sys-user.eclass b/eclass/sys-user.eclass index 92c7829..b90b590 100644 --- a/eclass/sys-user.eclass +++ b/eclass/sys-user.eclass @@ -9,7 +9,7 @@ # This eclass does most of the work for the sys-user/ packages that # supply system user accounts. -# Needed for egetshell and egethome +# Needed for egetshell and egethome. inherit user EXPORT_FUNCTIONS pkg_pretend src_unpack src_configure src_compile src_install src_test pkg_preinst pkg_postinst pkg_prerm @@ -105,6 +105,22 @@ sys-user_create() { } +sys-user_modify() { + # Modify the existing user named $SYS_USER_NAME to match the values + # contained in the following variables: + # + # * SYS_USER_UID + # * SYS_USER_SHELL + # * SYS_USER_HOME + # * SYS_USER_GROUPS + # + usermod ${SYS_USER_UID:+--uid }"${SYS_USER_UID}" \ + ${SYS_USER_GROUPS:+--append --groups }"${SYS_USER_GROUPS}" \ + --shell "${SYS_USER_SHELL}" \ + --home-dir "${SYS_USER_HOME}" \ + "${SYS_USER_NAME}" +} + sys-user_pkg_pretend() { # Sanity checks that would otherwise run code in global scope. # @@ -226,8 +242,9 @@ sys-user_pkg_preinst() { fi # The user already exists, so all we have left to do is to try - # to append SYS_USER_GROUPS to the existing groups. - usermod --append --groups "${SYS_USER_GROUPS}" \ + # to append SYS_USER_GROUPS to the existing groups. The home + # dir, shell, and uid should all match already. + sys-user_modify \ || die "failed to append groups to existing user ${SYS_USER_NAME}" fi } -- 2.44.2