commit:     a8fa1aff3bcbb91cbdee0344a251f44110376747
Author:     Viorel Munteanu <ceamac <AT> gentoo <DOT> org>
AuthorDate: Sat Apr  6 17:47:56 2024 +0000
Commit:     Viorel Munteanu <ceamac <AT> gentoo <DOT> org>
CommitDate: Sat Apr  6 17:50:55 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a8fa1aff

net-misc/dropbear: fix client-server tests

Use sys-libs/nss_wrapper to fake home dir for dropbear server.

Signed-off-by: Viorel Munteanu <ceamac <AT> gentoo.org>

 net-misc/dropbear/dropbear-2024.84.ebuild          |  4 ++-
 .../dropbear-2024.84-fix-channels-tests.patch      | 36 ++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/net-misc/dropbear/dropbear-2024.84.ebuild 
b/net-misc/dropbear/dropbear-2024.84.ebuild
index 68f1c4674d72..83d23fbcf782 100644
--- a/net-misc/dropbear/dropbear-2024.84.ebuild
+++ b/net-misc/dropbear/dropbear-2024.84.ebuild
@@ -43,6 +43,7 @@ DEPEND="
 RDEPEND+=" pam? ( >=sys-auth/pambase-20080219.1 )"
 BDEPEND="
        test? (
+               sys-libs/nss_wrapper
                $(python_gen_any_dep '
                        dev-python/attrs[${PYTHON_USEDEP}]
                        dev-python/iniconfig[${PYTHON_USEDEP}]
@@ -63,6 +64,7 @@ PATCHES=(
        "${FILESDIR}"/${PN}-2024.84-dbscp.patch
        "${FILESDIR}"/${PN}-2022.82-tests.patch
        "${FILESDIR}"/${PN}-2024.84-non-interactive-tests.patch
+       "${FILESDIR}"/${PN}-2024.84-fix-channels-tests.patch
 )
 
 set_options() {
@@ -106,7 +108,7 @@ src_prepare() {
        restore_config localoptions.h
 
        # remove tests that fail
-       rm test/test_aslr.py test/test_channels.py || die
+       rm test/test_aslr.py || die
 
        # dropbearconver is not build with USE minimal
        if use minimal; then

diff --git a/net-misc/dropbear/files/dropbear-2024.84-fix-channels-tests.patch 
b/net-misc/dropbear/files/dropbear-2024.84-fix-channels-tests.patch
new file mode 100644
index 000000000000..0db292da8332
--- /dev/null
+++ b/net-misc/dropbear/files/dropbear-2024.84-fix-channels-tests.patch
@@ -0,0 +1,36 @@
+dbclient obeys $HOME, but dropbear (the server) resolves HOME using getpwnam.
+Use sys-libs/nss_wrapper to fake it during tests.
+
+--- a/test/Makefile.in
++++ b/test/Makefile.in
+@@ -4,7 +4,15 @@ SHELL=bash
+ 
+ all: test
+ 
++uid:=$(shell id -u)
++gid:=$(shell id -g)
+ test: fakekey
++      mkdir -p ~/.ssh
++      ../dropbearkey -t ecdsa -f ~/.ssh/id_dropbear
++      ../dropbearkey -y -f ~/.ssh/id_dropbear | grep ^ecdsa > 
~/.ssh/authorized_keys
++      echo "$(LOGNAME)::$(uid):$(gid):$(USER):$(HOME):/bin/bash" >> ~/passwd
++      echo "$(LOGNAME)::$(gid):" >> ~/group
++      chmod 0700 ~ ~/.ssh ~/.ssh/authorized_keys ~/passwd ~/group
+       pytest --hostkey=fakekey --dbclient=../dbclient --dropbear=../dropbear 
$(srcdir)
+ 
+ one: fakekey
+--- a/test/test_dropbear.py
++++ b/test/test_dropbear.py
+@@ -27,7 +27,11 @@ def dropbear(request):
+               ]
+       print("subprocess args: ", args)
+ 
+-      p = subprocess.Popen(args, stderr=subprocess.PIPE, text=True)
++      env = os.environ
++      env['LD_PRELOAD'] = 'libnss_wrapper.so'
++      env['NSS_WRAPPER_PASSWD'] = env['HOME'] + '/passwd'
++      env['NSS_WRAPPER_GROUP'] = env['HOME'] + '/group'
++      p = subprocess.Popen(args, stderr=subprocess.PIPE, text=True, env=env)
+       # Wait until it has started listening
+       for l in p.stderr:
+               if "Not backgrounding" in l:

Reply via email to