From 69f78b86afb8e66d054ae9c427ff391083c43723 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 25 Oct 2022 01:23:41 +0200 Subject: [PATCH] cleanup --- README.md | 4 ++-- copyparty/__main__.py | 4 ++-- copyparty/smbd.py | 10 +++------- setup.py | 1 - 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 1e52ba4f..9321b772 100644 --- a/README.md +++ b/README.md @@ -1136,7 +1136,7 @@ regarding the frequent server log message during uploads; * on this http connection, `2.77 GiB` transferred, `102.9 MiB/s` average, `948` chunks handled * client says `4` uploads OK, `0` failed, `3` busy, `1` queued, `10042 MiB` total size, `7198 MiB` and `00:01:09` left -design detail: [why chunk-hashes](#./docs/devnotes/#why-chunk-hashes) +design detail: [why chunk-hashes](#./docs/devnotes.md#why-chunk-hashes) # performance @@ -1369,7 +1369,7 @@ these are standalone programs and will never be imported / evaluated by copypart the self-contained "binary" [copyparty-sfx.py](https://github.com/9001/copyparty/releases/latest/download/copyparty-sfx.py) will unpack itself and run copyparty, assuming you have python installed of course -you can reduce the sfx size by repacking it; see [./docs/devnotes/#sfx-repack](#./docs/devnotes/#sfx-repack) +you can reduce the sfx size by repacking it; see [./docs/devnotes.md#sfx-repack](#./docs/devnotes.md#sfx-repack) ## copyparty.exe diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 001032cd..d09fe91a 100755 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -634,12 +634,12 @@ def run_argparse(argv: list[str], formatter: Any, retry: bool) -> argparse.Names ap2.add_argument("--ftp-pr", metavar="P-P", type=u, help="the range of TCP ports to use for passive connections, for example \033[32m12000-13000") ap2 = ap.add_argument_group('WebDAV options') - ap2.add_argument("--daw", action="store_true", help="enable full write support. \033[1;31mNB!\033[0m This has side-effects -- PUT-operations will now \033[1;31mOVERWRITE\033[0m existing files, rather than inventing new filenames to avoid loss of data. You might want to instead set this as a volflag where needed. By not setting this flag, uploaded files can get written to a filename which the client does not expect (which might be okay, depending on client)") + ap2.add_argument("--daw", action="store_true", help="enable full write support. \033[1;31mWARNING:\033[0m This has side-effects -- PUT-operations will now \033[1;31mOVERWRITE\033[0m existing files, rather than inventing new filenames to avoid loss of data. You might want to instead set this as a volflag where needed. By not setting this flag, uploaded files can get written to a filename which the client does not expect (which might be okay, depending on client)") ap2.add_argument("--dav-nr", action="store_true", help="reject depth:infinite requests (recursive file listing); breaks spec compliance and some clients, which might be a good thing since depth:infinite is extremely server-heavy") ap2.add_argument("--dav-mac", action="store_true", help="disable apple-garbage filter -- allow macos to create junk files (._* and .DS_Store, .Spotlight-*, .fseventsd, .Trashes, .AppleDouble, __MACOS)") ap2 = ap.add_argument_group('SMB/CIFS options') - ap2.add_argument("--smb", action="store_true", help="enable smb (read-only) -- this requires running copyparty as root on linux and macos unless --smb-port") + ap2.add_argument("--smb", action="store_true", help="enable smb (read-only) -- this requires running copyparty as root on linux and macos unless --smb-port is set above 1024 and your OS does port-forwarding from 445 to that.\n\033[1;31mWARNING:\033[0m this protocol is dangerous! Never expose to the internet. Account permissions are coalesced; if one account has write-access to a volume, then all accounts do.") ap2.add_argument("--smbw", action="store_true", help="enable write support (please dont)") ap2.add_argument("--smb1", action="store_true", help="disable SMBv2, only enable SMBv1 (CIFS)") 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") diff --git a/copyparty/smbd.py b/copyparty/smbd.py index 99ce777b..3a9dd970 100644 --- a/copyparty/smbd.py +++ b/copyparty/smbd.py @@ -1,5 +1,4 @@ # coding: utf-8 -from __future__ import print_function, unicode_literals import inspect import logging @@ -24,10 +23,6 @@ from .svchub import SvcHub -class Standin(object): - pass - - class HLog(logging.Handler): def __init__(self, log_func: Any) -> None: logging.Handler.__init__(self) @@ -173,6 +168,7 @@ def _open( self.files = {k: v for k, v in self.files.items() if v[0] > cutoff} logging.info("was tracking %d files, now %d", nf, len(self.files)) + vpath = vpath.replace("\\", "/").lstrip("/") self.files[ret] = (now, vpath) return ret @@ -234,12 +230,12 @@ def _unlink(self, vpath: str) -> None: yeet("blocked delete (no --smbw): " + vpath) # return bos.unlink(self._v2a("stat", vpath, *a)[1]) - vp = vpath.lstrip("/") vfs, ap = self._v2a("delete", vpath) if not vfs.axs.udel: yeet("blocked delete (no-del-acc): " + vpath) - self.hub.up2k.handle_rm(LEELOO_DALLAS, "1.7.6.2", [vp], []) + vpath = vpath.replace("\\", "/").lstrip("/") + self.hub.up2k.handle_rm(LEELOO_DALLAS, "1.7.6.2", [vpath], []) def _utime(self, vpath: str, times: tuple[float, float]) -> None: if not self.args.smbw: diff --git a/setup.py b/setup.py index 5455f7aa..f26aa5f8 100755 --- a/setup.py +++ b/setup.py @@ -128,7 +128,6 @@ def run(self): "audiotags": ["mutagen"], "ftpd": ["pyftpdlib"], "ftps": ["pyftpdlib", "pyopenssl"], - "smbd": ["impacket"], }, "entry_points": {"console_scripts": ["copyparty = copyparty.__main__:main"]}, "scripts": ["bin/copyparty-fuse.py", "bin/up2k.py"],