1
0
mirror of https://github.com/calebstewart/pwncat.git synced 2024-11-23 17:15:38 +01:00

Fixed config argument processing

This commit is contained in:
Caleb Stewart 2021-02-15 14:20:06 -05:00
parent 64a5cdd06c
commit 56e73a6c37
2 changed files with 11 additions and 6 deletions

View File

@ -32,7 +32,7 @@ def main():
"--config",
"-c",
type=argparse.FileType("r"),
default="./pwncatrc",
default=None,
help="Custom configuration file (default: ./pwncatrc)",
)
parser.add_argument(

View File

@ -268,14 +268,19 @@ class Manager:
# Load local configuration script
if isinstance(config, str):
try:
with open(config) as filp:
self.parser.eval(filp.read(), config)
except (FileNotFoundError, PermissionError):
pass
with open(config) as filp:
self.parser.eval(filp.read(), config)
elif config is not None:
self.parser.eval(config.read(), config.name)
config.close()
else:
try:
# If no config is specified, attempt to load `./pwncatrc`
# but don't fail if it doesn't exist.
with open("./pwncatrc") as filp:
self.parser.eval(filp.read(), "./pwncatrc")
except (FileNotFoundError, PermissionError):
pass
def open_database(self):
"""Create the internal engine and session builder