]> gitweb.michael.orlitzky.com - mjo-overlay.git/commitdiff
sys-user.eclass: replace a few egetent calls with sys-user_getuid().
authorMichael Orlitzky <michael@orlitzky.com>
Mon, 7 Aug 2017 20:36:32 +0000 (16:36 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Mon, 7 Aug 2017 20:36:32 +0000 (16:36 -0400)
eclass/sys-user.eclass

index 95417c79a8516ec4f53031cfe6c442d43e3eb77f..8417212dc67bdace6dbc82d5aea41f2796dcfcd3 100644 (file)
@@ -115,8 +115,8 @@ sys-user_pkg_pretend() {
 
        # Finally, ensure that this username doesn't already exist with
        # another UID if its UID is supposedly important.
-       if [[ -n $(egetent passwd "${SYS_USER_NAME}") ]]; then
-               local olduid=$(sys-user_getuid "${SYS_USER_NAME}")
+       local olduid=$(sys-user_getuid "${SYS_USER_NAME}")
+       if [[ -n "${olduid}" ]]; then
                if [[ "${SYS_USER_UID_IMPORTANT}" == "true" ]] && \
                           [[ "${SYS_USER_UID}" != "${olduid}" ]]; then
                        # The UID is important and specified, but there is already a
@@ -127,7 +127,8 @@ sys-user_pkg_pretend() {
 }
 
 sys-user_src_configure() {
-       if [[ -n $(egetent passwd "${SYS_USER_NAME}") ]]; then
+       local current_uid=$(sys-user_getuid "${SYS_USER_NAME}")
+       if [[ -n "${current_uid}" ]]; then
                # UPGRADE PATH: This user already exists, so if the eclass
                # consumer doesn't care about some settings, we can reuse the
                # pre-existing ones.
@@ -136,7 +137,7 @@ sys-user_src_configure() {
                # prevents us from incrementing the UID on a reinstall, and doing
                # so would break most packages that need a system user to exist.
                if [[ "${SYS_USER_UID_IMPORTANT}" != "true" ]]; then
-                       SYS_USER_UID=$(sys-user_getuid "${SYS_USER_NAME}")
+                       SYS_USER_UID="${current_uid}"
                fi
 
                if (( "${SYS_USER_HOME}" == -1 )); then
@@ -177,7 +178,7 @@ sys-user_src_install() {
 }
 
 sys-user_pkg_preinst() {
-       if [[ -z $(egetent passwd "${SYS_USER_NAME}") ]]; then
+       if [[ -z $(sys-user_getuid "${SYS_USER_NAME}") ]]; then
                # The user does not already exist. This is the nice and easy
                # case because no matter how we got here, we want to go ahead
                # and create the (new) user.
@@ -238,7 +239,7 @@ sys-user_pkg_postinst() {
           # that this new version is going to add. At this point, in our
           # pkg_postinst(), the old version's pkg_prerm() phase should have
           # already happened.
-          if [[ -n $(egetent passwd "${SYS_USER_NAME}") ]]; then
+          if [[ -n $(sys-user_getuid "${SYS_USER_NAME}") ]]; then
                   die "User ${SYS_USER_NAME} already exists during an upgrade."
           else
                   enewuser "${SYS_USER_NAME}" \
@@ -252,7 +253,7 @@ sys-user_pkg_postinst() {
 }
 
 sys-user_pkg_prerm() {
-       if [[ -z $(egetent passwd "${SYS_USER_NAME}") ]]; then
+       if [[ -z $(sys-user_getuid "${SYS_USER_NAME}") ]]; then
                # We have successfully done nothing.
                ewarn "Tried to remove nonexistent user ${SYS_USER_NAME}."
        else