X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mjo-overlay.git;a=blobdiff_plain;f=eclass%2Fsys-user.eclass;h=b90b59027a53c8e8f27f2588bda5f79c6cb1c484;hp=35d20ed050a5ce48a4390c1e3c5663e570c62cda;hb=4b1c465944c3722edb6c24016663ad7b7b15e553;hpb=929a9a71d2022b6397cc4db036a14ea4543b188f diff --git a/eclass/sys-user.eclass b/eclass/sys-user.eclass index 35d20ed..b90b590 100644 --- a/eclass/sys-user.eclass +++ b/eclass/sys-user.eclass @@ -9,6 +9,7 @@ # This eclass does most of the work for the sys-user/ packages that # supply system user accounts. +# 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 @@ -76,6 +77,8 @@ sys-user_src_compile() { :; } sys-user_src_test() { :; } sys-user_getuid() { + [[ $# -eq 1 ]] || die "usage: sys-user_getuid " + # Output the real UID of the given user, or the empty string if the # user does not exist on the system. echo $(id --real --user "${1}") @@ -102,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. # @@ -173,11 +192,13 @@ sys-user_src_install() { # be possible. # # Beware, this only works if SYS_USER_UID is guaranteed to have a - # real UID and not, for example, -1. That is taken care of in - # src_configure() for now. - touch "${T}/${SYS_USER_UID}" || die - insinto "/var/lib/sys-user" - doins "${T}/${SYS_USER_UID}" + # real UID and not, for example, -1. + # + # TODO: this is a problem now! + # + #touch "${T}/${SYS_USER_UID}" || die + #insinto "/var/lib/sys-user" + #doins "${T}/${SYS_USER_UID}" } sys-user_pkg_preinst() { @@ -221,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 }