Compare commits

..

No commits in common. "7754f17cc90663c1f809d0cadca0909cf2e9af30" and "b40f61b0b5ff3c12bd2ac04a805524cddb62f8fb" have entirely different histories.

4 changed files with 6 additions and 36 deletions

View File

@ -4,7 +4,7 @@ SSHWOT_EXPORT_KNOWN_HOSTS_MAIN:=src/main-export-known-hosts.py
SSHWOT_EXPORT_KNOWN_HOSTS_DEPS:=src/entry.py src/hashing.py src/process_known_hosts.py src/write_file.py
SSHWOT_FILTER_MAIN:=src/main-filter.py
SSHWOT_FILTER_DEPS:=src/entry.py src/hashing.py src/open_default_files.py src/read_file.py src/write_file.py
SSHWOT_FILTER_DEPS:=src/entry.py src/hashing.py src/read_file.py src/write_file.py
all: $(BINS)

View File

@ -48,14 +48,14 @@ def main():
try:
homedir = os.environ['HOME']
except KeyError as err:
raise KeyError('$HOME is not set') from err
except KeyError:
raise KeyError('$HOME is not set')
# The input file
# Default to ~/.ssh/known_hosts
parser.add_argument('infile',
nargs = '?',
default = os.path.join(homedir, '.ssh/known_hosts'),
default = homedir + '/.ssh/known_hosts',
help = 'a file in .ssh/known_hosts format'
)

View File

@ -3,11 +3,11 @@ import sys
import entry
import hashing
import open_default_files
import read_file
import write_file
def main():
# TODO: Default location to search
parser = argparse.ArgumentParser(
description = """Search sshwot file(s) for given host and/or
fingerprint.""",
@ -94,14 +94,8 @@ def main():
else:
fingerprint = None
# Use the default files if no input files were specified
if len(args.infiles) == 0:
infiles = open_default_files.open_all()
else:
infiles = args.infiles
matches = []
for infile in infiles:
for infile in args.infiles:
entries, file_comment = read_file.read(infile)
# Filter by host if it's present

View File

@ -1,24 +0,0 @@
import os
def open_all():
"""open_all() → [file(rb)]
Open the default sshwot files"""
try:
homedir = os.environ['HOME']
except KeyError as err:
raise KeyError('$HOME is not set') from err
# If the directory doesn't exist, just return empty
try:
sshwot_dir = os.listdir(os.path.join(homedir, '.sshwot'))
except FileNotFoundError:
return []
# Read all the .sshwot files from /.sshwot by default
files = []
for dir_entry in sshwot_dir:
if dir_entry.split('.')[-1] == 'sshwot':
files.append(open(dir_entry, 'rb'))
return files