X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mjo-overlay.git;a=blobdiff_plain;f=eclass%2Fsys-user.eclass;h=37c4d8719ac82cce8bec5a42b3f830c9ed5ba682;hp=d76e6190327aef906179ed0e0362d073aeeed540;hb=42b11c0d223b3cbdd2a3878375b54bedd66fc46b;hpb=79143a78e86fe8a181c2a749cab7ff08e08a7d11 diff --git a/eclass/sys-user.eclass b/eclass/sys-user.eclass index d76e619..37c4d87 100644 --- a/eclass/sys-user.eclass +++ b/eclass/sys-user.eclass @@ -83,7 +83,7 @@ sys-user_getuid() { # Output the real UID of the given user, or the empty string if the # user does not exist on the system. [[ $# -eq 1 ]] || die "usage: sys-user_getuid " - echo $(id --real --user "${1}") + echo $(id --real --user "${1}" 2>/dev/null) } sys-user_getname() { @@ -132,22 +132,20 @@ sys-user_modify() { sys-user_pkg_pretend() { # Sanity checks that would otherwise run code in global scope. - - # Next ensure that no other username owns an important UID. if [[ "${SYS_USER_UID_IMPORTANT}" == "true" ]]; then - # Ok, the UID is important. Make sure nobody else has it. Or + + # The UID is important, so make sure nobody else has it. Or # rather, nobody else *with a different username* has it. local oldname=$(sys-user_getname "${SYS_USER_UID}") - if [[ "${SYS_USER_NAME}" != "${oldname}" ]]; then + if [[ -n "${oldname}" ]] && \ + [[ "${SYS_USER_NAME}" != "${oldname}" ]]; then die "important UID ${SYS_USER_UID} already belongs to ${oldname}" fi - fi - # Finally, ensure that this username doesn't already exist with - # another UID if its UID is supposedly important. - local olduid=$(sys-user_getuid "${SYS_USER_NAME}") - if [[ -n "${olduid}" ]]; then - if [[ "${SYS_USER_UID_IMPORTANT}" == "true" ]] && \ + # Ensure that this username doesn't already exist with another + # UID if its UID is supposedly important. + local olduid=$(sys-user_getuid "${SYS_USER_NAME}") + if [[ -n "${olduid}" ]] && \ [[ "${SYS_USER_UID}" != "${olduid}" ]]; then # The UID is important and specified, but there is already a # system user with this name and a different UID. Halp. @@ -271,11 +269,16 @@ sys-user_pkg_prerm() { # We have successfully done nothing. ewarn "Tried to remove nonexistent user ${SYS_USER_NAME}." elif [[ -z "${REPLACING_VERSIONS}" ]]; then - # The user to remove exists, and this is not an upgrade, so - # we really do remove him. - userdel "${SYS_USER_NAME}" || \ - die "failed to remove user ${SYS_USER_NAME}" - einfo "Removed user ${SYS_USER_NAME} from the system." + # The user to remove exists, and this is not an upgrade. For + # Phase 1, we maintain the status quo and simply refuse to + # remove him (unless you know what you are doing). + if [[ "${I_KNOW_WHAT_I_AM_DOING}" == "yes" ]]; then + userdel "${SYS_USER_NAME}" || \ + die "failed to remove user ${SYS_USER_NAME}" + einfo "Removed user ${SYS_USER_NAME} from the system." + else + die "refusing to remove package for system user ${SYS_USER_NAME}" + fi # The missing case: if the user exists and this is an upgrade, # we leave the user alone to be modified in