crazy-max / docker-qbittorrent

qBittorrent Docker image
MIT License
73 stars 15 forks source link

entrypoint.sh mangles Downloads\ScanDirsV2 config parameter #25

Closed adamrothman closed 3 years ago

adamrothman commented 3 years ago

Behaviour

Steps to reproduce this issue

  1. Launch a fresh crazy-max/docker-qbittorrent container
  2. Navigate to web UI and open Options
  3. On the Downloads tab, observe no entries under Automatically add torrents from:
  4. Observe malformed value for Downloads\ScanDirsV2 in /data/config/qBittorrent.conf, e.g.:

    Downloads\ScanDirsV2=@Variant(Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)x1cDownloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)x1Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)x16Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)/Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)x64Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)x61Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)tDownloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)x61Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)/Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)wDownloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)x61Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)tDownloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)x63Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)hDownloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)x2Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\x1\0\0\0\x16\0/\0\x64\0\x61\0t\0\x61\0/\0w\0\x61\0t\0\x63\0h\0\0\0\x2\0\0\0\x1)x1)

Expected behaviour

entrypoint.sh should properly configure /data/watch as a monitored folder: https://github.com/crazy-max/docker-qbittorrent/blob/bd10285902071ed167f9d936a9a5be45177460ac/entrypoint.sh#L22-L23

Actual behaviour

No monitored folders are configured. Torrent files added to the directory mapped to /data/watch are not automatically started.

Manually adding /data/watch as a monitored folder and saving my Options overwrites the garbage value and gets the watch dir working as expected. Unfortunately, the invocations of sed in entrypoint.sh revert this change every time the container (re)starts: https://github.com/crazy-max/docker-qbittorrent/blob/bd10285902071ed167f9d936a9a5be45177460ac/entrypoint.sh#L87

Configuration

Here's my compose file:

docker-compose.yml ```yaml version: '3' services: flexget: build: flexget depends_on: - nginx environment: TZ: America/Los_Angeles networks: - tarsnet restart: always volumes: - /volume1/docker/flexget:/home/flexget/.flexget - /volume1/docker/transmission/watch:/home/flexget/torrents nginx: build: nginx networks: - tarsnet ports: - 'XXX:443' # redacted restart: always volumes: - /usr/syno/etc/certificate/_archive/1B4XLl:/etc/nginx/ssl:ro qbittorrent: depends_on: - nginx environment: ALT_WEBUI: 'false' PUID: '1044' PGID: '65538' TZ: America/Los_Angeles image: crazymax/qbittorrent networks: - tarsnet ports: - 'XXX:6881/tcp' # redacted - 'XXX:6881/udp' # redacted restart: always ulimits: nproc: 65535 nofile: soft: 32000 hard: 40000 volumes: - /volume1/docker/qbittorrent:/data - /volume1/Media/Downloads:/data/downloads transmission: build: transmission depends_on: - nginx environment: CURL_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt TZ: America/Los_Angeles networks: - tarsnet ports: - 'XXX:XXX' # redacted restart: always volumes: - /volume1/docker/transmission/config:/home/transmission/.config - /volume1/docker/transmission/incomplete:/home/transmission/incomplete - /volume1/docker/transmission/watch:/home/transmission/watch - /volume1/Media/Downloads:/home/transmission/downloads ```

Docker info

# docker info
Containers: 4
 Running: 4
 Paused: 0
 Stopped: 0
Images: 34
Server Version: 18.09.8
Storage Driver: btrfs
Logging Driver: db
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs db fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 0cf16177dbb234350dc27dd2bbd1d7cebd098108
runc version: 6cc9d3f2cd512eeb3d548e2f6b75bcdebc779d4d
init version: e01de58 (expected: fec3683)
Security Options:
 apparmor
Kernel Version: 3.10.105
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 5.814GiB
Name: TARS
ID: VC5Y:VJHJ:EHD3:JVFU:RQPU:MTKU:ULVH:PZPM:NL2Z:HWP5:4UUO:XZ5D
Docker Root Dir: /volume1/@docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No kernel memory limit support
WARNING: No cpu cfs quota support
WARNING: No cpu cfs period support

Logs

WAN IP address is X.X.X.X
Switching to PGID 65538...
Switching to PUID 1044...
Creating folders...
Overriding required parameters...
Fixing perms...
Trying to construct an instance of an invalid type, type id: 74413837

******** Information ********
To control qBittorrent, access the Web UI at http://localhost:8080

Discussion

Some light Googling suggests that the "trying to construct an instance of invalid type" error message that gets printed on container startup could be related to decoding a QVariant value, which just so happens to be the type of the Downloads\ScanDirsV2 config parameter.

My theory is that the double quotes around WATCH_DIR on this line https://github.com/crazy-max/docker-qbittorrent/blob/bd10285902071ed167f9d936a9a5be45177460ac/entrypoint.sh#L22-L23 might be causing bits of that string to be interpreted as escape sequences and/or causing it to interact badly with sed.

crazy-max commented 3 years ago

@adamrothman I've changed the behavior in 614eb1d. Let me know what you think about it. See also https://github.com/crazy-max/docker-qbittorrent#watch-torrents

adamrothman commented 3 years ago

Works great, thanks @crazy-max!