From 47297475bf86f6152e717e5f3af79256357d4949 Mon Sep 17 00:00:00 2001 From: shermanhlc <100432197+shermanhlc@users.noreply.github.com> Date: Sat, 15 Aug 2026 08:51:09 -0500 Subject: [PATCH] u2c: password in U2C_PW (#1604) --- bin/u2c.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/u2c.py b/bin/u2c.py index 61a27340..efb3a4c0 100755 --- a/bin/u2c.py +++ b/bin/u2c.py @@ -1576,7 +1576,7 @@ NOTE: if server has --usernames enabled, then password is "username:password" ap.add_argument("url", type=unicode, help="server url, including destination folder") ap.add_argument("files", type=files_decoder, nargs="+", help="files and/or folders to process") ap.add_argument("-v", action="store_true", help="verbose") - ap.add_argument("-a", metavar="PASSWD", default="", help="password (or $filepath) for copyparty (is sent in header 'PW')") + ap.add_argument("-a", metavar="PASSWD", default="", help="password (or $filepath) for copyparty (is sent in header 'PW'), default is env.var U2C_PW") ap.add_argument("--ba", metavar="PASSWD", default="", help="password (or $filepath) for basic-auth (usually not necessary)") ap.add_argument("-s", action="store_true", help="file-search (disables upload)") ap.add_argument("-x", type=unicode, metavar="REGEX", action="append", help="skip file if filesystem-abspath matches REGEX (option can be repeated), example: '.*/\\.hist/.*'") @@ -1729,6 +1729,9 @@ NOTE: if server has --usernames enabled, then password is "username:password" with open(zs[1:], "rb") as f: setattr(ar, k, f.read().decode("utf-8").strip()) + if not ar.a: + ar.a = os.environ.get("U2C_PW", "") + if ar.ba: ar.ba = "Basic " + base64.b64encode(ar.ba.encode("utf-8")).decode("utf-8")