annotate test/test_svrauth.py @ 1921:284c3837891c

Allow user space file locations (rootless support) Why: Running dropbear as a user (rootless) is aided if files and programs can be saved/removed without needing sudo. What: Use the same convention as DROPBEAR_DEFAULT_CLI_AUTHKEY; if not starting with '/', then is relative to hedge's /home/hedge: *_PRIV_FILENAME DROPBEAR_PIDFILE SFTPSERVER_PATH default_options.h commentary added. Changes kept to a minimum, so log entry in svr_kex.c#163 is refactored. From: Generated hostkey is <path> ... <finger-print> to: Generated hostkey path is <path> Generated hostkey fingerprint is <fp> Otherwise the unexpanded path was reported. Patch modified by Matt Johnston Signed-off-by: Begley Brothers Inc <[email protected]>
author Begley Brothers Inc <begleybrothers@gmail.com>
date Thu, 09 Jul 2020 17:47:58 +1000
parents 30fd047f6ebf
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1885
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 from test_dropbear import *
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 import signal
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3 import queue
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4 import socket
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 import os
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6 from pathlib import Path
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 # Tests for server side authentication
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 # Requires keyfile and authorized_keys set up in github action build.yml
1887
30fd047f6ebf Fix pytest incorrect skip "reason" string
Matt Johnston <matt@ucc.asn.au>
parents: 1885
diff changeset
11 @pytest.mark.skipif('DBTEST_IN_ACTION' not in os.environ, reason="DBTEST_IN_ACTION not set")
1885
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 def test_pubkeyinfo(request, dropbear):
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 kf = str(Path.home() / ".ssh/id_dropbear_key2")
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14 r = dbclient(request, "-i", kf, "echo -n $SSH_PUBKEYINFO", capture_output=True)
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 # stop at first space
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16 assert r.stdout.decode() == "key2"
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17
1887
30fd047f6ebf Fix pytest incorrect skip "reason" string
Matt Johnston <matt@ucc.asn.au>
parents: 1885
diff changeset
18 @pytest.mark.skipif('DBTEST_IN_ACTION' not in os.environ, reason="DBTEST_IN_ACTION not set")
1885
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19 def test_pubkeyinfo_special(request, dropbear):
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20 kf = str(Path.home() / ".ssh/id_dropbear_key3")
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21 r = dbclient(request, "-i", kf, "echo -n $SSH_PUBKEYINFO", capture_output=True)
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22 # comment contains special characters so the SSH_PUBKEYINFO should not be set
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23 assert r.stdout.decode() == ""
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
24
1887
30fd047f6ebf Fix pytest incorrect skip "reason" string
Matt Johnston <matt@ucc.asn.au>
parents: 1885
diff changeset
25 @pytest.mark.skipif('DBTEST_IN_ACTION' not in os.environ, reason="DBTEST_IN_ACTION not set")
1885
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
26 def test_pubkeyinfo_okchar(request, dropbear):
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
27 kf = str(Path.home() / ".ssh/id_dropbear_key4")
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
28 r = dbclient(request, "-i", kf, "echo -n $SSH_PUBKEYINFO", capture_output=True)
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
29 # comment contains special characters so the SSH_PUBKEYINFO should not be set
5d8dbb6fdab7 Fix SSH_PUBKEYINFO, limit characters, add tests
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
30 assert r.stdout.decode() == "key4,char"