Objavljen vir
Prenos vir ZIP
CH-J SM Mobile
Brskajte po imenikih in datotekah za določeno izdajo programa.
CH-J / SM Mobile
134 datoteke
sm-mobile-20261016T050549Z-3678f2a05fa9
Dodano: · Zgrajena:
1
#!/usr/bin/env python32
"""Real, unprivileged loopback-only OpenSSH fixture on macOS/Linux. No Docker required."""3
import argparse,base64,getpass,json,os,pathlib,shutil,socket,subprocess,tempfile,time4
root=pathlib.Path(__file__).resolve().parents[1]5
p=argparse.ArgumentParser()6
p.add_argument('--device',help='Flutter device id; omitted runs host network tests')7
p.add_argument('--android',action='store_true',help='Use emulator host address 10.0.2.2')8
args=p.parse_args()9
sshd=shutil.which('sshd') or '/usr/sbin/sshd'10
# StrictModes requires a non-world-writable parent, unlike /tmp on macOS.11
cache=pathlib.Path.home()/'.cache/sm-mobile-tests';cache.mkdir(parents=True,exist_ok=True);cache.chmod(0o700)12
with tempfile.TemporaryDirectory(prefix='openssh-',dir=cache) as temporary:13
fixture=pathlib.Path(temporary)14
for name,phrase in [('host_key',''),('client_key','isolated-test-passphrase')]:15
subprocess.run(['ssh-keygen','-q','-t','ed25519','-N',phrase,'-f',str(fixture/name)],check=True)16
shutil.copy(fixture/'client_key.pub',fixture/'authorized_keys')17
(fixture/'authorized_keys').chmod(0o600)18
(fixture/'remote').mkdir()19
(fixture/'sshd_config').write_text(f'''Port 2222920
ListenAddress 127.0.0.121
HostKey {fixture}/host_key22
PidFile {fixture}/pid23
AuthorizedKeysFile {fixture}/authorized_keys24
StrictModes yes25
PubkeyAuthentication yes26
PasswordAuthentication no27
KbdInteractiveAuthentication no28
UsePAM no29
AllowUsers {getpass.getuser()}30
Subsystem sftp internal-sftp31
LogLevel ERROR32
''')33
with (fixture/'server.log').open('w') as log:34
server=subprocess.Popen([sshd,'-D','-e','-f',str(fixture/'sshd_config')],stdout=log,stderr=log)35
try:36
time.sleep(.5)37
if server.poll() is not None: raise SystemExit((fixture/'server.log').read_text())38
with socket.create_connection(('127.0.0.1',22229),timeout=3): pass39
env={**os.environ,'SM_OPENSSH_TEST':'1','SM_TEST_KEY':str(fixture/'client_key'),'SM_TEST_REMOTE_DIR':str(fixture/'remote')}40
if args.device:41
fingerprint=subprocess.check_output(['ssh-keygen','-lf',str(fixture/'host_key.pub'),'-E','sha256'],text=True).split()[1]42
defines={'SM_TEST_KEY_B64':base64.b64encode((fixture/'client_key').read_bytes()).decode(),43
'SM_TEST_FINGERPRINT':fingerprint,'SM_TEST_USER':getpass.getuser(),'SM_TEST_HOST':'10.0.2.2' if args.android else '127.0.0.1'}44
(fixture/'defines.json').write_text(json.dumps(defines));(fixture/'defines.json').chmod(0o600)45
command=['flutter','test','integration_test/device_test.dart','-d',args.device,'--dart-define-from-file='+str(fixture/'defines.json')]46
else: command=['flutter','test','test/network/openssh_test.dart','--reporter','expanded']47
subprocess.run(command,cwd=root,env=env,check=True)48
finally:49
server.terminate()50
try: server.wait(timeout=5)51
except subprocess.TimeoutExpired: server.kill();server.wait()SHA-256
7b46c93edc8a7d5706a3195d938578161fcde4567c2ecb6f5b63955139b90ce7CH-J Proprietary Software License 1.14 · Vir je na voljo pod CH-J Proprietary Software License 1.14. Njena razpoložljivost ne spreminja pogojev licence ali dodeljuje dodatnih pravic.
Arhiv SHA-256
c486a807e4828998b9c57ab0f2e760f7980b31965fe118e89d3e1a5a2b65be65