On Mon, May 17 2021, Felipe Contreras wrote:

> On Mon, May 17, 2021 at 2:33 PM Tomi Ollila <tomi.oll...@iki.fi> wrote:
>>
>> notmuch_passwd_sanitize() in test-lib.sh is too generic, it cannot
>> work in many cases...
>>
>> The more specific version _libconfig_sanitize() replaces it in
>> T590-libconfig.sh and the code that uses it is modified to output
>> the keys (ascending numbers printed in hex) so the sanitizer knows
>> what to sanitize in which lines...
>>
>> In addition to ".(none)" now also ".localdomain" if filtered from
>> USERNAME@FQDN.
>> ---
>>
>> Rebase of id:20210502181535.31292-1-tomi.oll...@iki.fi
>>
>> * 'fn () {' style change
>> * added @ to fqdn replace, as it could be subset of user
>>
>>  test/T590-libconfig.sh | 97 +++++++++++++++++++++++++-----------------
>>  test/test-lib.sh       | 20 ---------
>>  2 files changed, 59 insertions(+), 58 deletions(-)
>>
>> diff --git a/test/T590-libconfig.sh b/test/T590-libconfig.sh
>> index 745e1bb4..8e70b7b2 100755
>> --- a/test/T590-libconfig.sh
>> +++ b/test/T590-libconfig.sh
>> @@ -5,6 +5,26 @@ test_description="library config API"
>>
>>  add_email_corpus
>>
>> +_libconfig_sanitize() {
>> +    ${NOTMUCH_PYTHON} -c '
>> +import os, sys, pwd, socket
>> +
>> +pw = pwd.getpwuid(os.getuid())
>> +user = pw.pw_name
>> +name = pw.pw_gecos.partition(",")[0]
>> +fqdn = socket.getaddrinfo(socket.gethostname(), 0, 0,
>> +                          socket.SOCK_STREAM, 0, socket.AI_CANONNAME)[0][3]
>> +for l in sys.stdin:
>> +    if l[:3] == "8: ":
>> +        # fqdn could be subset of user; therefore @
>> +        l = l.replace(user, "USERNAME").replace("@" + fqdn, "@FQDN")
>> +        l = l.replace(".(none)", "").replace(".localdomain", "")
>> +    elif l[:3] == "a: ":
>> +        l = l.replace(name, "USER_FULL_NAME")
>
> This generates garbage when name is null. See ff5f141b (test: fix
> passwd_sanitize(), 2021-05-01).

You're right -- that was the reason I added ''s around,
just forgot that part :/

Anyway, there are other problems, will fix that along...

Thanks,

Tomi

>
> At the very least we need to check for that, even better if we
> generate the proper output:
>
>         if name:
>             l = l.replace(name, "USER_FULL_NAME")
>         else:
>             l = "a: \'USER_FULL_NAME\'\\n"

>
> This makes the test pass with no geckos name, but we need to use bash
> strings: $'string'. Otherwise we would need to do something much more
> weird.
>
> Cheers.
>
> -- 
> Felipe Contreras
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org

Reply via email to