mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
-mkpasswd: fetch password via getpass instead of requiring command line entry
This gives better security, since running programs and their command lines are visible in 'ps'.
This commit is contained in:
parent
62c4b79e04
commit
0d99bc62d2
@ -4,14 +4,23 @@ Password hashing utility for PyLink IRC Services.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from pylinkirc.coremods.login import pwd_context
|
from pylinkirc.coremods.login import pwd_context
|
||||||
|
import getpass
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Hashes a password for use with PyLink IRC Services.')
|
parser = argparse.ArgumentParser(description='Hashes a password for use with PyLink IRC Services.')
|
||||||
parser.add_argument('password', help='specifies the password to hash')
|
parser.add_argument('password', help='specifies the password to hash', nargs='?', default='')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
assert pwd_context, 'Cannot hash passwords because passlib is missing! Install it via "pip3 install passlib".'
|
assert pwd_context, 'Cannot hash passwords because passlib is missing! Install it via "pip3 install passlib".'
|
||||||
assert args.password, "Password cannot be empty!"
|
|
||||||
print(pwd_context.encrypt(args.password))
|
password = args.password
|
||||||
|
|
||||||
|
# If no password was given, enter one on the command line
|
||||||
|
if not password:
|
||||||
|
password = getpass.getpass()
|
||||||
|
|
||||||
|
password = password.strip()
|
||||||
|
assert password, "Password cannot be empty!"
|
||||||
|
print(pwd_context.encrypt(password))
|
||||||
|
Loading…
Reference in New Issue
Block a user