From 95566e83887af52e5879b9329f8efb0dfd907aac Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 3 Nov 2023 16:52:43 +0000 Subject: [PATCH] cosmetics: * fix toast/tooltip colors on splashpage * properly warn if --ah-cli or --ah-gen is used without --ah-alg * support ^D during --ah-cli * improve flavor texts --- copyparty/__main__.py | 4 ++-- copyparty/authsrv.py | 3 +++ copyparty/pwhash.py | 8 ++++++-- copyparty/web/ui.css | 28 +++++++++++++++++++--------- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 3f2ef2b0..ead96543 100755 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -1094,7 +1094,7 @@ def add_logging(ap): ap2.add_argument("--ansi", action="store_true", help="force colors; overrides environment-variable NO_COLOR") ap2.add_argument("--no-voldump", action="store_true", help="do not list volumes and permissions on startup") ap2.add_argument("--log-tdec", metavar="N", type=int, default=3, help="timestamp resolution / number of timestamp decimals") - ap2.add_argument("--log-badpwd", metavar="N", type=int, default=1, help="log passphrase of failed login attempts: 0=terse, 1=plaintext, 2=hashed") + ap2.add_argument("--log-badpwd", metavar="N", type=int, default=1, help="log failed login attempt passwords: 0=terse, 1=plaintext, 2=hashed") ap2.add_argument("--log-conn", action="store_true", help="debug: print tcp-server msgs") ap2.add_argument("--log-htp", action="store_true", help="debug: print http-server threadpool scaling") ap2.add_argument("--ihead", metavar="HEADER", type=u, action='append', help="dump incoming header") @@ -1314,7 +1314,7 @@ def run_argparse( for k, h, t in sects: k2 = "help_" + k.replace("-", "_") if vars(ret)[k2]: - lprint("# {} help page".format(k)) + lprint("# %s help page (%s)" % (k, h)) lprint(t + "\033[0m") sys.exit(0) diff --git a/copyparty/authsrv.py b/copyparty/authsrv.py index ffe2a7a3..29e8fca7 100644 --- a/copyparty/authsrv.py +++ b/copyparty/authsrv.py @@ -1723,6 +1723,9 @@ class AuthSrv(object): def setup_pwhash(self, acct: dict[str, str]) -> None: self.ah = PWHash(self.args) if not self.ah.on: + if self.args.ah_cli or self.args.ah_gen: + t = "\n BAD CONFIG:\n cannot --ah-cli or --ah-gen without --ah-alg" + raise Exception(t) return if self.args.ah_cli: diff --git a/copyparty/pwhash.py b/copyparty/pwhash.py index 36b4c127..f8e5c9fa 100644 --- a/copyparty/pwhash.py +++ b/copyparty/pwhash.py @@ -136,8 +136,12 @@ class PWHash(object): import getpass while True: - p1 = getpass.getpass("password> ") - p2 = getpass.getpass("again or just hit ENTER> ") + try: + p1 = getpass.getpass("password> ") + p2 = getpass.getpass("again or just hit ENTER> ") + except EOFError: + return + if p2 and p1 != p2: print("\033[31minputs don't match; try again\033[0m", file=sys.stderr) continue diff --git a/copyparty/web/ui.css b/copyparty/web/ui.css index 03e0415c..2beae327 100644 --- a/copyparty/web/ui.css +++ b/copyparty/web/ui.css @@ -1,3 +1,18 @@ +:root { + --fg: #ccc; + --fg-max: #fff; + --bg-u2: #2b2b2b; + --bg-u5: #444; +} +html.y { + --fg: #222; + --fg-max: #000; + --bg-u2: #f7f7f7; + --bg-u5: #ccc; +} +html.bz { + --bg-u2: #202231; +} @font-face { font-family: 'scp'; font-display: swap; @@ -14,6 +29,7 @@ html { max-width: min(34em, 90%); max-width: min(34em, calc(100% - 7em)); color: #ddd; + color: var(--fg); background: #333; background: var(--bg-u2); border: 0 solid #777; @@ -171,24 +187,15 @@ html { color: #f6a; } html.y #tt { - color: #333; - background: #fff; border-color: #888 #000 #777 #000; } html.bz #tt { - background: #202231; border-color: #3b3f58; } html.y #tt, html.y #toast { box-shadow: 0 .3em 1em rgba(0,0,0,0.4); } -html.y #tt code { - color: #fff; - color: var(--fg-max); - background: #060; - background: var(--bg-u5); -} #modalc code { color: #060; background: transparent; @@ -326,6 +333,9 @@ html.y .btn:focus { box-shadow: 0 .1em .2em #037 inset; outline: #037 solid .1em; } +input[type="submit"] { + cursor: pointer; +} input[type="text"]:focus, input:not([type]):focus, textarea:focus {