2016-02-11 20:27:41 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import sys, re
|
2016-02-11 20:39:56 +01:00
|
|
|
from epasswd import EPasswd
|
2016-02-11 20:27:41 +01:00
|
|
|
|
|
|
|
if len(sys.argv)<4:
|
|
|
|
sys.exit(-2)
|
|
|
|
|
2018-09-27 16:57:39 +02:00
|
|
|
filename=sys.argv[1]
|
2016-02-11 20:27:41 +01:00
|
|
|
myfaction=sys.argv[2]
|
|
|
|
mypasswd=sys.argv[3]
|
2018-12-01 15:29:47 +01:00
|
|
|
quiet=len(sys.argv)<=4
|
|
|
|
|
|
|
|
def log(str):
|
|
|
|
if not quiet:
|
|
|
|
print(str)
|
2016-02-11 20:27:41 +01:00
|
|
|
|
2018-09-27 16:57:39 +02:00
|
|
|
if mypasswd[0] == '"':
|
|
|
|
mypasswd = mypasswd.strip('"')
|
|
|
|
|
|
|
|
pw_data = EPasswd()
|
|
|
|
try:
|
|
|
|
pw_data.load_database(filename)
|
2018-12-01 15:29:47 +01:00
|
|
|
log("loaded from db " + filename)
|
2018-09-27 16:57:39 +02:00
|
|
|
except:
|
|
|
|
pw_data.load_file(filename)
|
2018-12-01 15:29:47 +01:00
|
|
|
log("loaded from file " + filename)
|
2016-02-11 20:27:41 +01:00
|
|
|
|
2016-02-11 20:39:56 +01:00
|
|
|
if pw_data.fac_exists(myfaction):
|
|
|
|
if pw_data.check(myfaction, mypasswd):
|
2018-12-01 15:29:47 +01:00
|
|
|
log("password match: " + myfaction)
|
2016-02-11 20:39:56 +01:00
|
|
|
sys.exit(0)
|
2018-12-01 15:29:47 +01:00
|
|
|
log("password mismatch: " + myfaction)
|
|
|
|
else:
|
|
|
|
log("faction missing: " + myfaction)
|
|
|
|
|
2016-02-11 20:27:41 +01:00
|
|
|
sys.exit(-1)
|