X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mjo-overlay.git;a=blobdiff_plain;f=eclass%2Fsys-user.eclass;h=8a4c426e3e0dcc36801d63079d427e8891d34241;hp=e14cdfb733ec1a5947f8f681f1ef341b449c917d;hb=8da30d4d982f17cb7605a3bb0804b5561acb6e31;hpb=ad88c75318cc9173a5959ca329ccf16f2ac73553 diff --git a/eclass/sys-user.eclass b/eclass/sys-user.eclass index e14cdfb..8a4c426 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. @@ -180,7 +178,8 @@ sys-user_src_configure() { fi local current_name=$(sys-user_getname "${SYS_USER_UID}") - if [[ "${current_name}" != "${SYS_USER_NAME}" ]]; then + if [[ -n "${current_name}" ]] && \ + [[ "${current_name}" != "${SYS_USER_NAME}" ]]; then # This UID is already taken by another user, but this # specific UID was not important (we checked in # pkg_pretend), so fall back to an arbitrary one.