copyparty 1.15.3__py3-none-any.whl → 1.15.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
copyparty/__init__.py CHANGED
@@ -48,9 +48,64 @@ try:
48
48
  except:
49
49
  CORES = (os.cpu_count() if hasattr(os, "cpu_count") else 0) or 2
50
50
 
51
+ # all embedded resources to be retrievable over http
52
+ zs = """
53
+ web/a/partyfuse.py
54
+ web/a/u2c.py
55
+ web/a/webdav-cfg.bat
56
+ web/baguettebox.js
57
+ web/browser.css
58
+ web/browser.html
59
+ web/browser.js
60
+ web/browser2.html
61
+ web/cf.html
62
+ web/copyparty.gif
63
+ web/dd/2.png
64
+ web/dd/3.png
65
+ web/dd/4.png
66
+ web/dd/5.png
67
+ web/deps/busy.mp3
68
+ web/deps/easymde.css
69
+ web/deps/easymde.js
70
+ web/deps/marked.js
71
+ web/deps/fuse.py
72
+ web/deps/mini-fa.css
73
+ web/deps/mini-fa.woff
74
+ web/deps/prism.css
75
+ web/deps/prism.js
76
+ web/deps/prismd.css
77
+ web/deps/scp.woff2
78
+ web/deps/sha512.ac.js
79
+ web/deps/sha512.hw.js
80
+ web/md.css
81
+ web/md.html
82
+ web/md.js
83
+ web/md2.css
84
+ web/md2.js
85
+ web/mde.css
86
+ web/mde.html
87
+ web/mde.js
88
+ web/msg.css
89
+ web/msg.html
90
+ web/shares.css
91
+ web/shares.html
92
+ web/shares.js
93
+ web/splash.css
94
+ web/splash.html
95
+ web/splash.js
96
+ web/svcs.html
97
+ web/svcs.js
98
+ web/ui.css
99
+ web/up2k.js
100
+ web/util.js
101
+ web/w.hash.js
102
+ """
103
+ RES = set(zs.strip().split("\n"))
104
+
51
105
 
52
106
  class EnvParams(object):
53
107
  def __init__(self) :
108
+ self.pkg = None
54
109
  self.t0 = time.time()
55
110
  self.mod = ""
56
111
  self.cfg = ""
copyparty/__main__.py CHANGED
@@ -57,6 +57,8 @@ from .util import (
57
57
  ansi_re,
58
58
  b64enc,
59
59
  dedent,
60
+ has_resource,
61
+ load_resource,
60
62
  min_ex,
61
63
  pybin,
62
64
  termsize,
@@ -210,6 +212,7 @@ def init_E(EE ) :
210
212
 
211
213
  raise Exception("could not find a writable path for config")
212
214
 
215
+ E.pkg = sys.modules[__package__]
213
216
  E.mod = os.path.dirname(os.path.realpath(__file__))
214
217
  if E.mod.endswith("__init__"):
215
218
  E.mod = os.path.dirname(E.mod)
@@ -319,8 +322,7 @@ def ensure_locale() :
319
322
 
320
323
 
321
324
  def ensure_webdeps() :
322
- ap = os.path.join(E.mod, "web/deps/mini-fa.woff")
323
- if os.path.exists(ap):
325
+ if has_resource(E, "web/deps/mini-fa.woff"):
324
326
  return
325
327
 
326
328
  warn(
@@ -511,14 +513,18 @@ def sfx_tpoke(top ):
511
513
 
512
514
 
513
515
  def showlic() :
514
- p = os.path.join(E.mod, "res", "COPYING.txt")
515
- if not os.path.exists(p):
516
+ try:
517
+ with load_resource(E, "res/COPYING.txt") as f:
518
+ buf = f.read()
519
+ except:
520
+ buf = b""
521
+
522
+ if buf:
523
+ print(buf.decode("utf-8", "replace"))
524
+ else:
516
525
  print("no relevant license info to display")
517
526
  return
518
527
 
519
- with open(p, "rb") as f:
520
- print(f.read().decode("utf-8", "replace"))
521
-
522
528
 
523
529
  def get_sects():
524
530
  return [
@@ -1166,7 +1172,7 @@ def add_smb(ap):
1166
1172
  ap2.add_argument("--smbw", action="store_true", help="enable write support (please dont)")
1167
1173
  ap2.add_argument("--smb1", action="store_true", help="disable SMBv2, only enable SMBv1 (CIFS)")
1168
1174
  ap2.add_argument("--smb-port", metavar="PORT", type=int, default=445, help="port to listen on -- if you change this value, you must NAT from TCP:445 to this port using iptables or similar")
1169
- ap2.add_argument("--smb-nwa-1", action="store_true", help="disable impacket#1433 workaround (truncate directory listings to 64kB)")
1175
+ ap2.add_argument("--smb-nwa-1", action="store_true", help="truncate directory listings to 64kB (~400 files); avoids impacket-0.11 bug, fixes impacket-0.12 performance")
1170
1176
  ap2.add_argument("--smb-nwa-2", action="store_true", help="disable impacket workaround for filecopy globs")
1171
1177
  ap2.add_argument("--smba", action="store_true", help="small performance boost: disable per-account permissions, enables account coalescing instead (if one user has write/delete-access, then everyone does)")
1172
1178
  ap2.add_argument("--smbv", action="store_true", help="verbose")
@@ -1558,16 +1564,13 @@ def run_argparse(
1558
1564
  return ret
1559
1565
 
1560
1566
 
1561
- def main(argv = None, rsrc = None) :
1567
+ def main(argv = None) :
1562
1568
  time.strptime("19970815", "%Y%m%d") # python#7980
1563
1569
  if WINDOWS:
1564
1570
  os.system("rem") # enables colors
1565
1571
 
1566
1572
  init_E(E)
1567
1573
 
1568
- if rsrc: # pyz
1569
- E.mod = rsrc
1570
-
1571
1574
  if argv is None:
1572
1575
  argv = sys.argv
1573
1576
 
copyparty/__version__.py CHANGED
@@ -1,8 +1,8 @@
1
1
  # coding: utf-8
2
2
 
3
- VERSION = (1, 15, 3)
3
+ VERSION = (1, 15, 4)
4
4
  CODENAME = "fill the drives"
5
- BUILD_DT = (2024, 9, 16)
5
+ BUILD_DT = (2024, 10, 4)
6
6
 
7
7
  S_VERSION = ".".join(map(str, VERSION))
8
8
  S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT)
copyparty/cert.py CHANGED
@@ -7,7 +7,7 @@ import shutil
7
7
  import time
8
8
 
9
9
  from .__init__ import ANYWIN
10
- from .util import Netdev, runcmd, wrename, wunlink
10
+ from .util import Netdev, load_resource, runcmd, wrename, wunlink
11
11
 
12
12
  HAVE_CFSSL = not os.environ.get("PRTY_NO_CFSSL")
13
13
 
@@ -25,13 +25,15 @@ def ensure_cert(log , args) :
25
25
 
26
26
  i feel awful about this and so should they
27
27
  """
28
- cert_insec = os.path.join(args.E.mod, "res/insecure.pem")
28
+ with load_resource(args.E, "res/insecure.pem") as f:
29
+ cert_insec = f.read()
29
30
  cert_appdata = os.path.join(args.E.cfg, "cert.pem")
30
31
  if not os.path.isfile(args.cert):
31
32
  if cert_appdata != args.cert:
32
33
  raise Exception("certificate file does not exist: " + args.cert)
33
34
 
34
- shutil.copy(cert_insec, args.cert)
35
+ with open(args.cert, "wb") as f:
36
+ f.write(cert_insec)
35
37
 
36
38
  with open(args.cert, "rb") as f:
37
39
  buf = f.read()
@@ -46,7 +48,9 @@ def ensure_cert(log , args) :
46
48
  raise Exception(m + "private key must appear before server certificate")
47
49
 
48
50
  try:
49
- if filecmp.cmp(args.cert, cert_insec):
51
+ with open(args.cert, "rb") as f:
52
+ active_cert = f.read()
53
+ if active_cert == cert_insec:
50
54
  t = "using default TLS certificate; https will be insecure:\033[36m {}"
51
55
  log("cert", t.format(args.cert), 3)
52
56
  except:
@@ -147,14 +151,22 @@ def _gen_srv(log , args, netdevs ):
147
151
  raise Exception("no useable cert found")
148
152
 
149
153
  expired = time.time() + args.crt_sdays * 60 * 60 * 24 * 0.5 > expiry
150
- cert_insec = os.path.join(args.E.mod, "res/insecure.pem")
154
+ if expired:
155
+ raise Exception("old server-cert has expired")
156
+
151
157
  for n in names:
152
158
  if n not in inf["sans"]:
153
159
  raise Exception("does not have {}".format(n))
154
- if expired:
155
- raise Exception("old server-cert has expired")
156
- if not filecmp.cmp(args.cert, cert_insec):
160
+
161
+ with load_resource(args.E, "res/insecure.pem") as f:
162
+ cert_insec = f.read()
163
+
164
+ with open(args.cert, "rb") as f:
165
+ active_cert = f.read()
166
+
167
+ if active_cert and active_cert != cert_insec:
157
168
  return
169
+
158
170
  except Exception as ex:
159
171
  log("cert", "will create new server-cert; {}".format(ex))
160
172
 
copyparty/cfg.py CHANGED
@@ -2,7 +2,7 @@
2
2
  from __future__ import print_function, unicode_literals
3
3
 
4
4
  # awk -F\" '/add_argument\("-[^-]/{print(substr($2,2))}' copyparty/__main__.py | sort | tr '\n' ' '
5
- zs = "a c e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vp e2vu ed emp i j lo mcr mte mth mtm mtp nb nc nid nih nw p q s ss sss v z zv"
5
+ zs = "a c e2d e2ds e2dsa e2t e2ts e2tsr e2v e2vp e2vu ed emp i j lo mcr mte mth mtm mtp nb nc nid nih nth nw p q s ss sss v z zv"
6
6
  onedash = set(zs.split())
7
7
 
8
8
 
copyparty/ftpd.py CHANGED
@@ -159,7 +159,7 @@ class FtpFs(AbstractedFS):
159
159
  t = "Unsupported characters in [{}]"
160
160
  raise FSE(t.format(vpath), 1)
161
161
 
162
- fn = sanitize_fn(fn or "", "", [".prologue.html", ".epilogue.html"])
162
+ fn = sanitize_fn(fn or "", "")
163
163
  vpath = vjoin(rd, fn)
164
164
  vfs, rem = self.hub.asrv.vfs.get(vpath, self.uname, r, w, m, d)
165
165
  if not vfs.realpath: