diff options
| author | David Bremner <david@tethera.net> | 2021-04-24 09:28:15 -0300 |
|---|---|---|
| committer | David Bremner <david@tethera.net> | 2021-04-24 12:11:22 -0300 |
| commit | 27a2c2c80d7854f75f8910802880f9a8e6764a45 (patch) | |
| tree | 2e39eeba380eccdfd6325a233f4f91a1c296cb01 /test/test-lib.sh | |
| parent | c008176ade7c95f73adaf706a82e99140cad6033 (diff) | |
test: replace notmuch_passwd_sanitize with python version
Apparently the -f option to hostname is not portable, and in fact it
does not seem to always behave reasonably in e.g. a chroot.
Python code originally due to Tomi [1], modified by yours truly.
[1]: id:m2lf9fbkug.fsf@guru.guru-group.fi
Diffstat (limited to 'test/test-lib.sh')
| -rw-r--r-- | test/test-lib.sh | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/test/test-lib.sh b/test/test-lib.sh index 3f8d5827..4c9f2a21 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -700,12 +700,20 @@ notmuch_built_with_sanitize () sed 's/^built_with[.]\(.*\)=.*$/built_with.\1=something/' } -notmuch_passwd_sanitize () +notmuch_passwd_sanitize() { - local user=$(id -un) - local fqdn=$(hostname -f) - local full_name=$(getent passwd $user | cut -d: -f 5 | cut -d, -f1) - sed -e "s/$user/USERNAME/" -e "s/$fqdn/FQDN/" -e "s/$full_name/USER_FULL_NAME/" + ${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.getfqdn() + +for l in sys.stdin: + l = l.replace(user, "USERNAME").replace(fqdn, "FQDN").replace(".(none)","").replace(name, "USER_FULL_NAME") + sys.stdout.write(l) +' } notmuch_config_sanitize () |
