-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from olcf/ngin_remove_setupsh_cleanup_setuppy
Create a cleaner setup environment
- Loading branch information
Showing
6 changed files
with
128 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
cryptography>=2.3 | ||
exrex>=0.10.5 | ||
future>=0.17.1 | ||
mock>=2.0.0 | ||
nginsecretsharing>=0.3.0 | ||
pyperclip>=1.6.0 | ||
PyYAML>=4.2b1 | ||
setuptools>=41.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[metadata] | ||
name = pkpass | ||
author = Noah Ginsburg | ||
author_email = [email protected] | ||
url = https://github.com/olcf/pkpass | ||
description = Public Key based Password Management | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
license = GPLV3 | ||
classifiers = | ||
Environment :: Console | ||
Intended Audience :: Developers | ||
Intended Audience :: Information Technology | ||
Intended Audience :: System Administrators | ||
LICENSE :: OSI Approved :: GNU GENERAL PUBLIC LICENSE V3 (GPLV3) | ||
Operating System :: OS Independent | ||
Programming Language :: Python :: 2.7 | ||
Programming Language :: Python :: 3.5 | ||
Programming Language :: Python :: 3.6 | ||
Programming Language :: Python :: 3.7 | ||
Topic :: Security :: Cryptography | ||
|
||
[options] | ||
include_package_data = True | ||
packages = find: | ||
scripts = | ||
bin/pkpass | ||
|
||
[options.packages.find] | ||
exclude = | ||
tests | ||
|
||
[options.extras_require] | ||
testing: mock; tox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,36 +10,18 @@ | |
import getpass | ||
from shutil import rmtree | ||
|
||
from setuptools import find_packages, setup, Command | ||
|
||
# Package meta-data | ||
NAME = 'pkpass' | ||
DESCRIPTION = 'Public Key based password manager' | ||
URL = 'https://github.com/olcf/pkpass' | ||
EMAIL = '[email protected]' | ||
AUTHOR = 'Noah Ginsburg' | ||
VERSION = None | ||
from setuptools import setup, Command | ||
|
||
with io.open('requirements.txt') as requirements_file: | ||
REQUIRED = requirements_file.read().splitlines() | ||
|
||
HOME = os.path.expanduser("~") | ||
HERE = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
# Import the README and use it as the long-description. | ||
# Note: this will only work if 'README.md' is present in your MANIFEST.in file! | ||
try: | ||
with io.open(os.path.join(HERE, 'README.md'), encoding='utf-8') as f: | ||
LONG_DESCRIPTION = '\n' + f.read() | ||
except IOError: | ||
LONG_DESCRIPTION = DESCRIPTION | ||
|
||
# Load the package's __version__.py module as a dictionary. | ||
ABOUT = {} | ||
if not VERSION: | ||
with open(os.path.join(HERE, 'VERSION')) as version_file: | ||
ABOUT['__version__'] = version_file.read().strip() | ||
else: | ||
ABOUT['__version__'] = VERSION | ||
with open(os.path.join(HERE, 'VERSION')) as version_file: | ||
ABOUT['__version__'] = version_file.read().strip() | ||
|
||
class UploadCommand(Command): | ||
"""Support setup.py upload.""" | ||
|
@@ -82,11 +64,10 @@ class RCFile(Command): | |
user_options = [] | ||
|
||
def initialize_options(self): | ||
self.home = os.path.expanduser("~") | ||
pass | ||
|
||
def finalize_options(self): | ||
# this command object complains with you do stuff in init | ||
self.home = os.path.expanduser("~") #pylint: attribute-defined-outside-init | ||
pass | ||
|
||
def user_input(self, prompt, default): | ||
u_input = input(prompt).strip() | ||
|
@@ -110,52 +91,62 @@ def file_creation(self, user_prompt, default): | |
|
||
def finish_run(self): | ||
testing = """testing versions of openssl and pkcs15-tool if version numbers return you're probably good | ||
for sanity sake Noah's return values were: | ||
openssl version: LibreSSL 2.2.7 | ||
pkcs15-tool --version: OpenSC-0.18.0, rev: eb60481f, commit-time: 2018-05-16 13:48:37 +0200 | ||
------YOUR VALUES BELOW THIS LINE -----------""" | ||
for sanity sake Noah's return values were: | ||
openssl version: LibreSSL 2.2.7 | ||
pkcs15-tool --version: OpenSC-0.18.0, rev: eb60481f, commit-time: 2018-05-16 13:48:37 +0200 | ||
------YOUR VALUES BELOW THIS LINE -----------""" | ||
|
||
print(testing) | ||
print(Popen("openssl version".split(), stdout=PIPE, stdin=PIPE, stderr=STDOUT).communicate()[0]) | ||
print(Popen("pkcs15-tool --version".split(), stdout=PIPE, stdin=PIPE, stderr=STDOUT).communicate()[0]) | ||
print(Popen("openssl version".split(), stdout=PIPE, stdin=PIPE, stderr=STDOUT).communicate()[0].decode("ASCII")) | ||
print(Popen("pkcs15-tool --version".split(), stdout=PIPE, stdin=PIPE, stderr=STDOUT).communicate()[0].decode("ASCII")) | ||
|
||
def run(self): | ||
args = { | ||
'cabundle': '', | ||
'card_slot': '', | ||
'certpath': '', | ||
'connect': '', | ||
'dstpwstore': '', | ||
'escrow_users': '', | ||
'groups': '', | ||
'identity': '', | ||
'keypath': '', | ||
'min_escrow': '', | ||
'pwstore': '', | ||
'time': '', | ||
'rules': '', | ||
'rules_map': '', | ||
'users': '' | ||
} | ||
print("If not using defaults for the following paths please use full filepath or relative to home using ~") | ||
passdb_home = os.path.join(self.home, "passdb") | ||
certs = self.directory_creation("Directory for certpath (defaults to ~/passdb/certs): ", | ||
os.path.join(passdb_home, "certs")) | ||
keys = self.directory_creation("Directory for keypath (defaults to ~/passdb/keys): ", | ||
os.path.join(passdb_home, "keys")) | ||
cabundle = self.file_creation("Path to cabundle (defaults to ~/passdb/cabundles/ca.bundle): ", | ||
os.path.join(passdb_home, "cabundles", "ca.bundle")) | ||
passwords = self.directory_creation("Directory for passwords (defaults to ~/passdb/passwords): ", | ||
os.path.join(passdb_home, "passwords")) | ||
|
||
print(Popen("pkcs11-tool -L".split(), stdout=PIPE, stdin=PIPE, stderr=STDOUT).communicate()[0]) | ||
card_slot = self.user_input("Available slots listed above, which would you like to use? (defaults to 0): ", "0") | ||
identity = self.user_input("What user name would you like to use? (defaults to system user): ", getpass.getuser()) | ||
passdb_home = os.path.join(HOME, "passdb") | ||
args['certpath'] = self.directory_creation("Directory for certpath (defaults to ~/passdb/certs): ", | ||
os.path.join(passdb_home, "certs")) | ||
args['keypath'] = self.directory_creation("Directory for keypath (defaults to ~/passdb/keys): ", | ||
os.path.join(passdb_home, "keys")) | ||
args['cabundle'] = self.file_creation("Path to cabundle (defaults to ~/passdb/cabundles/ca.bundle): ", | ||
os.path.join(passdb_home, "cabundles", "ca.bundle")) | ||
args['pwstore'] = self.directory_creation("Directory for passwords (defaults to ~/passdb/passwords): ", | ||
os.path.join(passdb_home, "passwords")) | ||
|
||
print(Popen("pkcs11-tool -L".split(), stdout=PIPE, stdin=PIPE, stderr=STDOUT).communicate()[0].decode("ASCII")) | ||
args['card_slot'] = self.user_input("Available slots listed above, which would you like to use? (defaults to 0): ", "0") | ||
args['identity'] = self.user_input("What user name would you like to use? (defaults to system user): ", getpass.getuser()) | ||
print("Escrow users is a feature of Pkpass. Escrow allows a password to be recovered by the majority of the escrow users in the event of an emergency.") | ||
check_escrow = self.user_input("Would you like to setup escrow? ", "n") | ||
if check_escrow.lower()[0] != 'y': | ||
escrow_users = "" | ||
min_escrow = "" | ||
else: | ||
if check_escrow.lower()[0] == 'y': | ||
escrow_users = self.user_input("Please enter a comma seperated list of usernames: ", "").split(',') | ||
escrow_users = ",".join([user.strip() for user in escrow_users]) | ||
min_escrow = self.user_input("What should be the minimum number of escrow users required to unlock? ", | ||
len(escrow_users.split(',')) - 1) | ||
|
||
contents = """certpath: %s | ||
keypath: %s | ||
cabundle: %s | ||
pwstore: %s | ||
card_slot: %s | ||
identity: %s | ||
escrow_users: %s | ||
min_escrow: %s""" % (certs, keys, cabundle, passwords, card_slot, identity, escrow_users, min_escrow) | ||
|
||
with open(os.path.join(self.home, '.pkpassrc'), 'w') as fname: | ||
fname.write(contents) | ||
args['escrow_users'] = ",".join([user.strip() for user in escrow_users]) | ||
args['min_escrow'] = self.user_input("What should be the minimum number of escrow users required to unlock? ", | ||
len(args['escrow_users'].split(',')) - 1) | ||
|
||
with open(os.path.join(HOME, '.pkpassrc'), 'w') as fname: | ||
# fname.write(contents) | ||
for key, value in args.items(): | ||
if value: | ||
fname.write("%s: %s\n" % (key, value)) | ||
else: | ||
fname.write("#%s:\n" % key) | ||
|
||
self.finish_run() | ||
|
||
|
@@ -167,7 +158,7 @@ class Verify(Command): | |
user_options = [("rcfile=", "r", 'Specify the rc file path')] | ||
|
||
def initialize_options(self): | ||
self.rcfile = "" | ||
self.rcfile = "~/.pkpassrc" | ||
|
||
def finalize_options(self): | ||
pass | ||
|
@@ -219,12 +210,13 @@ def run(self): | |
'nosign', 'noverify', 'overwrite', | ||
'pwfile', 'pwname', 'recovery', 'stdin'] | ||
args_dict = {} | ||
with open(self.rcfile, 'r') as rcyaml: | ||
try: | ||
args_dict = yaml.safe_load(rcyaml) | ||
except yaml.YAMLError as err: | ||
valid = False | ||
print(err) | ||
if self.rcfile: | ||
with open(os.path.expanduser(self.rcfile), 'r') as rcyaml: | ||
try: | ||
args_dict = yaml.safe_load(rcyaml) | ||
except yaml.YAMLError as err: | ||
valid = False | ||
print(err) | ||
for arg in store_args: | ||
if arg in args_dict.keys(): | ||
valid = False | ||
|
@@ -244,32 +236,11 @@ def run(self): | |
print("Config Valid") | ||
|
||
setup( | ||
name=NAME, | ||
version=ABOUT['__version__'], | ||
description=DESCRIPTION, | ||
long_description=LONG_DESCRIPTION, | ||
long_description_content_type='text/markdown', | ||
author=AUTHOR, | ||
author_email=EMAIL, | ||
url=URL, | ||
packages=find_packages(exclude=('tests',)), | ||
install_requires=REQUIRED, | ||
include_package_data=True, | ||
license='GPLV3', | ||
classifiers=[ | ||
'License :: OSI Approved :: GNU GENERAL PUBLIC LICENSE V3 (GPLV3)', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python :: 2.7', | ||
'Programming Language :: Python :: 3.5', | ||
'Programming Language :: Python :: 3.6', | ||
'Programming Language :: Python :: 3.7', | ||
], | ||
cmdclass={ | ||
'upload': UploadCommand, | ||
'rcfile': RCFile, | ||
'verify': Verify, | ||
}, | ||
scripts=[ | ||
'bin/pkpass' | ||
] | ||
) |
Oops, something went wrong.