From a0c12392463365abeac8971d4cd0cb18b565569f Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 26 Jun 2023 00:05:12 +0000 Subject: [PATCH] v1.8.0 --- README.md | 2 +- copyparty/__main__.py | 1 + copyparty/__version__.py | 6 +++--- copyparty/authsrv.py | 17 +++++++---------- copyparty/ico.py | 4 +++- copyparty/pwhash.py | 5 ++++- scripts/sfx.ls | 1 + tests/util.py | 4 ++-- 8 files changed, 22 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index ed628d9e..9de285f8 100644 --- a/README.md +++ b/README.md @@ -1577,7 +1577,7 @@ you can hash passwords before putting them into config files / providing them a optionally also specify `--ah-cli` to enter an interactive mode where it will hash passwords without ever writing the plaintext ones to disk -the default configs take about 0.4 sec to process a new password on a decent laptop +the default configs take about 0.4 sec and 256 MiB RAM to process a new password on a decent laptop ## https diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 3bc0edfc..2ae8d86d 100755 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -659,6 +659,7 @@ def get_sects(): use sha2-512 with 424242 iterations recommended: \033[32m--ah-alg argon2\033[0m + (takes about 0.4 sec and 256M RAM to process a new password) argon2 needs python-package argon2-cffi, scrypt needs openssl, diff --git a/copyparty/__version__.py b/copyparty/__version__.py index d3087999..51ef4240 100644 --- a/copyparty/__version__.py +++ b/copyparty/__version__.py @@ -1,8 +1,8 @@ # coding: utf-8 -VERSION = (1, 7, 6) -CODENAME = "unlinked" -BUILD_DT = (2023, 6, 11) +VERSION = (1, 8, 0) +CODENAME = "argon" +BUILD_DT = (2023, 6, 26) S_VERSION = ".".join(map(str, VERSION)) S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT) diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index dbd533aa..991acf26 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -1136,7 +1136,7 @@ class AuthSrv(object): self.log("\n{0}\n{1}{0}".format(t, "\n".join(slns))) raise - self.setup_pwhash() + self.setup_pwhash(acct) # case-insensitive; normalize if WINDOWS: @@ -1658,9 +1658,9 @@ class AuthSrv(object): self.re_pwd = re.compile(zs) - def setup_pwhash(self) -> None: + def setup_pwhash(self, acct: dict[str, str]) -> None: self.ah = PWHash(self.args) - if self.ah.alg == "none": + if not self.ah.on: return if self.args.ah_cli: @@ -1673,19 +1673,17 @@ class AuthSrv(object): print(self.ah.hash(self.args.ah_gen)) sys.exit() - if not self.args.a: + if not acct: return changed = False - for acct in self.args.a[:]: - uname, pw = acct.split(":", 1) + for uname, pw in list(acct.items())[:]: if pw.startswith("+") and len(pw) == 33: continue changed = True hpw = self.ah.hash(pw) - self.args.a.remove(acct) - self.args.a.append("{}:{}".format(uname, hpw)) + acct[uname] = hpw t = "hashed password for account {}: {}" self.log(t.format(uname, hpw), 3) @@ -1693,8 +1691,7 @@ class AuthSrv(object): return lns = [] - for acct in self.args.a: - uname, pw = acct.split(":", 1) + for uname, pw in acct.items(): lns.append(" {}: {}".format(uname, pw)) t = "please use the following hashed passwords in your config:\n{}" diff --git a/copyparty/ico.py b/copyparty/ico.py index 89973e88..1495e5eb 100644 --- a/copyparty/ico.py +++ b/copyparty/ico.py @@ -17,7 +17,9 @@ class Ico(object): def get(self, ext: str, as_thumb: bool, chrome: bool) -> tuple[str, bytes]: """placeholder to make thumbnails not break""" - zb = hashlib.sha1(ext.encode("utf-8")).digest()[2:4] + bext = ext.encode("ascii", "replace") + ext = bext.decode("utf-8") + zb = hashlib.sha1(bext).digest()[2:4] if PY2: zb = [ord(x) for x in zb] diff --git a/copyparty/pwhash.py b/copyparty/pwhash.py index 3226f5b2..36b4c127 100644 --- a/copyparty/pwhash.py +++ b/copyparty/pwhash.py @@ -20,9 +20,12 @@ class PWHash(object): alg = args.ah_alg ac = {} + if alg == "none": + alg = "" + self.alg = alg self.ac = ac - if alg == "none": + if not alg: self.on = False self.hash = unicode return diff --git a/scripts/sfx.ls b/scripts/sfx.ls index b3a96964..a2cfe485 100644 --- a/scripts/sfx.ls +++ b/scripts/sfx.ls @@ -23,6 +23,7 @@ copyparty/ico.py, copyparty/mdns.py, copyparty/mtag.py, copyparty/multicast.py, +copyparty/pwhash.py, copyparty/res, copyparty/res/__init__.py, copyparty/res/COPYING.txt, diff --git a/tests/util.py b/tests/util.py index bcbf34a6..7542257f 100644 --- a/tests/util.py +++ b/tests/util.py @@ -98,7 +98,7 @@ class Cfg(Namespace): def __init__(self, a=None, v=None, c=None): ka = {} - ex = "daw dav_auth dav_inf dav_mac dav_rt dotsrch e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vu e2vp ed emp force_js getmod grid hardlink ih ihead magic never_symlink nid nih no_acode no_athumb no_dav no_dedup no_del no_dupe no_logues no_mv no_readme no_robots no_sb_md no_sb_lg no_scandir no_thumb no_vthumb no_zip nrand nw rand vc xdev xlink xvol" + ex = "daw dav_auth dav_inf dav_mac dav_rt dotsrch e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vu e2vp ed emp force_js getmod grid hardlink ih ihead magic never_symlink nid nih no_acode no_athumb no_dav no_dedup no_del no_dupe no_logues no_mv no_readme no_robots no_sb_md no_sb_lg no_scandir no_thumb no_vthumb no_zip nrand nw rand smb vc xdev xlink xvol" ka.update(**{k: False for k in ex.split()}) ex = "dotpart no_rescan no_sendfile no_voldump plain_ip" @@ -113,7 +113,7 @@ class Cfg(Namespace): ex = "df loris re_maxage rproxy rsp_jtr rsp_slp s_wr_slp theme themes turbo" ka.update(**{k: 0 for k in ex.split()}) - ex = "doctitle favico html_head lg_sbf log_fk md_sbf mth textfiles unlist R RS SR" + ex = "ah_alg doctitle favico html_head lg_sbf log_fk md_sbf mth textfiles unlist R RS SR" ka.update(**{k: "" for k in ex.split()}) ex = "xad xar xau xbd xbr xbu xiu xm"