From dbfc899d79cfa5e086dc91485c126c5d9a9a53d2 Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 25 Apr 2025 18:12:35 +0000 Subject: [PATCH] pw-hash tweaks (#159): * do not take lock on shares-db / sessions-db when running with `--ah-gen` or `--ah-cli` (allows a 2nd instance for that purpose) * add options to print effective salt for ah/fk/dk; useful for nixos and other usecases where config is derived or otherwise opaque --- copyparty/__main__.py | 3 +++ copyparty/svchub.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 6bf2b0c6..0dbab9f2 100644 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -1308,6 +1308,9 @@ def add_salt(ap, fk_salt, dk_salt, ah_salt): ap2.add_argument("--fk-salt", metavar="SALT", type=u, default=fk_salt, help="per-file accesskey salt; used to generate unpredictable URLs for hidden files") ap2.add_argument("--dk-salt", metavar="SALT", type=u, default=dk_salt, help="per-directory accesskey salt; used to generate unpredictable URLs to share folders with users who only have the 'get' permission") ap2.add_argument("--warksalt", metavar="SALT", type=u, default="hunter2", help="up2k file-hash salt; serves no purpose, no reason to change this (but delete all databases if you do)") + ap2.add_argument("--show-ah-salt", action="store_true", help="on startup, print the effective value of \033[33m--ah-salt\033[0m (the autogenerated value in $XDG_CONFIG_HOME unless otherwise specified)") + ap2.add_argument("--show-fk-salt", action="store_true", help="on startup, print the effective value of \033[33m--fk-salt\033[0m (the autogenerated value in $XDG_CONFIG_HOME unless otherwise specified)") + ap2.add_argument("--show-dk-salt", action="store_true", help="on startup, print the effective value of \033[33m--dk-salt\033[0m (the autogenerated value in $XDG_CONFIG_HOME unless otherwise specified)") def add_shutdown(ap): diff --git a/copyparty/svchub.py b/copyparty/svchub.py index 6dcc9fd3..e4f1110a 100644 --- a/copyparty/svchub.py +++ b/copyparty/svchub.py @@ -253,6 +253,14 @@ class SvcHub(object): setattr(args, "ipu_iu", iu) setattr(args, "ipu_nm", nm) + for zs in "ah_salt fk_salt dk_salt".split(): + if getattr(args, "show_%s" % (zs,)): + self.log("root", "effective %s is %s" % (zs, getattr(args, zs))) + + if args.ah_cli or args.ah_gen: + args.no_ses = True + args.shr = "" + if not self.args.no_ses: self.setup_session_db()