Compare commits

...

1 commit

Author SHA1 Message Date
fenris cf842f53e8 [int] 2026-10-10 16:21:12 +02:00
3 changed files with 88 additions and 11 deletions

View file

@ -38,6 +38,7 @@ def action_db_create(
options = (
{
"key_file": None,
"dry_run": False,
}
|
(options or {})
@ -60,7 +61,10 @@ def action_db_create(
)
)
}
)
),
{
"dry_run": options["dry_run"],
}
)
@ -69,6 +73,14 @@ def action_mkdir(
group_name,
options = None
):
options = (
{
"key_file": None,
"dry_run": False,
}
|
(options or {})
)
__helpers_misc.shell_exec(
__helpers_misc.string_coin(
"keepassxc-cli mkdir{{macro_auth}} {{db_path}} {{group_name}}",
@ -77,7 +89,10 @@ def action_mkdir(
"group_name": group_name,
"macro_auth": macro_auth(options["key_file"]),
}
)
),
{
"dry_run": options["dry_run"],
}
)
@ -87,6 +102,14 @@ def action_add(
member_name,
options = None
):
options = (
{
"key_file": None,
"dry_run": False,
}
|
(options or {})
)
__helpers_misc.shell_exec(
__helpers_misc.string_coin(
"keepassxc-cli add{{macro_auth}} {{db_path}} {{entry}}",
@ -95,7 +118,10 @@ def action_add(
"entry": compose_entry(group_name, member_name),
"macro_auth": macro_auth(options["key_file"]),
}
)
),
{
"dry_run": options["dry_run"],
}
)
@ -105,6 +131,14 @@ def action_rm(
member_name,
options = None
):
options = (
{
"key_file": None,
"dry_run": False,
}
|
(options or {})
)
__helpers_misc.shell_exec(
__helpers_misc.string_coin(
"keepassxc-cli rm{{macro_auth}} {{db_path}} {{entry}}",
@ -113,7 +147,10 @@ def action_rm(
"entry": compose_entry(group_name, member_name),
"macro_auth": macro_auth(options["key_file"]),
}
)
),
{
"dry_run": options["dry_run"],
}
)
@ -125,6 +162,14 @@ def action_attachment_import(
attachment_path,
options = None
):
options = (
{
"key_file": None,
"dry_run": False,
}
|
(options or {})
)
__helpers_misc.shell_exec(
__helpers_misc.string_coin(
"keepassxc-cli attachment-import{{macro_auth}} {{db_path}} {{entry}} '{{attachment_label}}' {{attachment_path}}",
@ -135,5 +180,8 @@ def action_attachment_import(
"attachment_path": attachment_path,
"macro_auth": macro_auth(options["key_file"]),
}
)
),
{
"dry_run": options["dry_run"],
}
)

View file

@ -43,8 +43,19 @@ def directory_create(path):
def shell_exec(
command
command,
options = None
):
options = (
{
"dry_run": False,
}
|
(options or {})
)
_sys.stderr.write("\n>> %s\n" % command)
if (options["dry_run"]):
pass
else:
_os.system(command)

View file

@ -11,7 +11,8 @@ import helpers.keepass as __helpers_keepass
def action_init(
source_directory
source_directory,
database_file_name
):
keepass_db_path = _os.path.join(source_directory, "private_keys.kdbx")
keepass_authfile_path = _os.path.join(source_directory, "private_keys.keyx")
@ -37,11 +38,13 @@ def action_key_add(
group,
name,
key_path,
keepass_db_path,
options = None
):
options = (
{
"remove_private_key": False,
"dry_run": False,
}
|
(options or {})
@ -52,13 +55,15 @@ def action_key_add(
__helpers_misc.directory_create(directory_key)
## transfer private key to keepass database
if True:
keepass_db_path = _os.path.join(source_directory, "private_keys.kdbx")
keepass_authfile_path = _os.path.join(source_directory, "private_keys.keyx")
# keepass_db_path = _os.path.join(source_directory, "private_keys.kdbx")
# keepass_authfile_path = _os.path.join(source_directory, "private_keys.keyx")
keepass_authfile_path = None # (keepass_db_path + ".auth")
__helpers_keepass.action_mkdir(
keepass_db_path,
group,
{
"key_file": keepass_authfile_path,
"dry_run": options["dry_run"],
}
)
__helpers_keepass.action_add(
@ -67,6 +72,7 @@ def action_key_add(
name,
{
"key_file": keepass_authfile_path,
"dry_run": options["dry_run"],
}
)
__helpers_keepass.action_attachment_import(
@ -77,6 +83,7 @@ def action_key_add(
path_key_private,
{
"key_file": keepass_authfile_path,
"dry_run": options["dry_run"],
}
)
## remove private key file
@ -87,7 +94,10 @@ def action_key_add(
{
"path": path_key_private,
}
)
),
{
"dry_run": options["dry_run"],
}
)
@ -273,6 +283,12 @@ def main():
metavar = "<action>",
help = "options: init | key-add | key-generate | key-remove | put",
)
argument_parser.add_argument(
"-q",
"--dry-run",
action = "store_true",
default = False,
)
argument_parser.add_argument(
"-s",
"--source-directory",
@ -333,8 +349,10 @@ def main():
args.group,
args.name,
args.key_path,
args.target_file,
{
"remove_private_key": args.remove_private_key,
"dry_run": args.dry_run,
}
)
elif (args.action == "key-generate"):