• [gentoo-dev] [PATCH] user-info.eclass: egetent: fix lookup by id when R

    From Mike Gilbert@21:1/5 to All on Sun Jul 9 03:20:01 2023
    Previous to this change, egetent would match any id that starts with the
    id given as input. For example:

    egetent group 1

    bin::1:root,bin,daemon
    wheel::10:root
    floppy::11:root
    news::13:news
    uucp::14:uucp
    console::17:
    audio::18:
    cdrom::19:
    users::100:

    Adding a colon to the grep expression yeilds the desired result:

    egetent group 1

    bin::1:root,bin,daemon

    Signed-off-by: Mike Gilbert <floppym@gentoo.org>
    ---
    eclass/user-info.eclass | 4 ++--
    1 file changed, 2 insertions(+), 2 deletions(-)

    diff --git a/eclass/user-info.eclass b/eclass/user-info.eclass
    index b18f280c1022..1cc7b8250309 100644
    --- a/eclass/user-info.eclass
    +++ b/eclass/user-info.eclass
    @@ -1,4 +1,4 @@
    -# Copyright 1999-2022 Gentoo Authors
    +# Copyright 1999-2023 Gentoo Authors
    # Distributed under the terms of the GNU General Public License v2

    # @ECLASS: user-info.eclass
    @@ -64,7 +64,7 @@ egetent() {
    getent "${db}" "${key}"
    else
    if [[ ${key} =~ ^[[:digit:]]+$ ]]; then
    - grep -E "^([^:]*:){2}${key}" "${ROOT}/etc/${db}"
    + grep -E "^([^:]*:){2}${key}:" "${ROOT}/etc/${db}"
    else
    grep "^${key}:" "${ROOT}/etc/${db}"
    fi
    --
    2.41.0

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ulrich Mueller@21:1/5 to All on Sun Jul 9 09:40:01 2023
    LGTM except for a typo in the commit message:

    Adding a colon to the grep expression yeilds the desired result:

    -----BEGIN PGP SIGNATURE-----

    iQFDBAEBCAAtFiEEtDnZ1O9xIP68rzDbUYgzUIhBXi4FAmSqYqkPHHVsbUBnZW50 b28ub3JnAAoJEFGIM1CIQV4u5XUIAMpTxc572u8KmRRTL2NXJuWr5rFOwSQX6Ktv 5x1+2oC7oxP2Nz5o9X6fcdpOK8cchDNKBCI4DIj3qYIUOj5WvZOy/ShCOYWzhcHO 2stk8yNQ83LuFPgI1mLsBqy5XDIHw94jvcYKC1G5icyj5OmmZiK0JNCI4O/iMGcl hZEAhzzum8xnJftpgmTRBhYIbV2EIwNZ1ZzCohYqXEsew9PyvF+B9YkVPqp9bIBh ZAIuIVEwwQgcx7X2RVeMI8sccjyWqsvgD91GtUBipc37QsqF7AnzPRgj2BVPFSE4 9Oxqmqd2+iQFCho30Y5hDAYyHGfAbog/vez8DaES53lXsMvwxDo=
    =vWW4
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)