lancachenet / monolithic

A monolithic lancache service capable of caching all CDNs in a single instance
https://hub.docker.com/r/lancachenet/monolithic
Other
737 stars 73 forks source link

Can't clear /cache/data directory: Permission denied #24

Closed borzaka closed 4 years ago

borzaka commented 5 years ago

Describe the issue you are having

I wanted to test the caching service, and as described in the readme, I tried to clear the /data/cache folder after a couple of days of running, but I couldn't over FTP.

CWD cache
550 Can't change directory to cache: Permission denied
RMD cache
550 Can't remove directory: Permission denied
DELE cache
550 Could not delete cache: Invalid argument
PWD
257 "/home/steamcache/cache/data" is your current location

How are you running the container(s)?

I have created a steamcache user, and added to the docker group.

HOST_IP=`hostname -I | cut -d' ' -f1`
docker run --restart unless-stopped --name steamcache-dns --detach -p 53:53/udp -e USE_GENERIC_CACHE=true -e LANCACHE_IP=$HOST_IP steamcache/steamcache-dns:latest
docker run --restart unless-stopped --name lancache --detach -v /home/steamcache/cache/data:/data/cache -v /home/steamcache/cache/logs:/data/logs -p 80:80 -e CACHE_MEM_SIZE=1000m -e CACHE_DISK_SIZE=500000m -e CACHE_MAX_AGE=365d -e LOGFILE_RETENTION=60 -e UPSTREAM_DNS="1.1.1.1 1.0.0.1" steamcache/monolithic:latest
docker run --restart unless-stopped --name sniproxy --detach -p 443:443 steamcache/sniproxy:latest
echo Please configure your dhcp server to serve dns as $HOST_IP

192.168.30.250 is my HOST_IP

steamcache@honved:~$ docker ps
CONTAINER ID        IMAGE                              COMMAND                  CREATED             STATUS              PORTS                         NAMES
89ffeaac571d        steamcache/sniproxy:latest         "sniproxy -f -c /etc…"   4 minutes ago       Up 4 minutes        0.0.0.0:443->443/tcp          sniproxy
6c331ecdfd23        steamcache/monolithic:latest       "/bin/bash -e /init/…"   4 minutes ago       Up 4 minutes        0.0.0.0:80->80/tcp, 443/tcp   lancache
1930f4ec5cc1        steamcache/steamcache-dns:latest   "bash /scripts/boots…"   4 minutes ago       Up 4 minutes        0.0.0.0:53->53/udp            steamcache-dns

Side question: what are the toughs of my custom environment variable settings? I don't understand some of the default values. 3650 days cache max age? 3650 days logfile retention? These are too much, aren't these?

DNS Configuration

image

Output of container(s)

The error.log is empty, and the access.log is huge as probably should be, this is an extract:

[wsus] 192.168.30.102 / - - - [13/Mar/2019:17:05:23 +0000] "GET /filestreamingservice/files/081ca1d9-1880-45d1-87f2-ec73c262409c?P1=1552497409&P2=402&P3=2&P4=QqBfyPl5aAsMeObyk4GU5%2bWayHjYpEl4i6IKme9BUSosV%2fQA6nFUDAkMnOl2B9jKMIqASBqqTKPPv88ZeHVL0w%3d%3d HTTP/1.1" 206 1014099 "-" "Microsoft-Delivery-Optimization/10.0" "HIT" "9.tlu.dl.delivery.mp.microsoft.com" "bytes=4194304-5208402"
[wsus] 192.168.30.109 / - - - [13/Mar/2019:17:05:28 +0000] "GET /filestreamingservice/files/b5c09e1f-7909-421a-8626-c8f759432571/pieceshash HTTP/1.1" 200 9460 "-" "Microsoft-Delivery-Optimization/10.0" "HIT" "dl.delivery.mp.microsoft.com" "-"
[wsus] 192.168.30.109 / - - - [13/Mar/2019:17:05:28 +0000] "GET /filestreamingservice/files/78ccaf0d-aa87-4d4a-bf7f-26080d4a223a/pieceshash HTTP/1.1" 200 9460 "-" "Microsoft-Delivery-Optimization/10.0" "HIT" "dl.delivery.mp.microsoft.com" "-"
[emdl.ws.microsoft.com] 192.168.30.109 / - - - [13/Mar/2019:17:05:29 +0000] "GET /emdl/c/doc/ph/prod6/msdownload/update/software/secu/2019/03/64/windows10.0-kb4489868-x64_ad95efe86b8219fef45fe886d3469dd07948a844.psf.json HTTP/1.1" 200 3907989 "-" "Microsoft-Delivery-Optimization/10.0" "HIT" "emdl.ws.microsoft.com" "-"
[wsus] 192.168.30.109 / - - - [13/Mar/2019:17:13:27 +0000] "GET /d/msdownload/update/software/defu/2019/03/am_delta_patch_1.289.1059.0_3cc1d82489f7648b65166b0824605db09484d842.exe HTTP/1.1" 206 2 "-" "Microsoft-Delivery-Optimization/10.0" "MISS" "au.download.windowsupdate.com" "bytes=0-1"
[wsus] 192.168.30.109 / - - - [13/Mar/2019:17:13:27 +0000] "GET /d/msdownload/update/software/defu/2019/03/am_delta_patch_1.289.1059.0_3cc1d82489f7648b65166b0824605db09484d842.exe HTTP/1.1" 206 334208 "-" "Microsoft-Delivery-Optimization/10.0" "HIT" "au.download.windowsupdate.com" "bytes=0-334207"

Linux distro

Debian 9 stretch 64-bit PC (amd64)

nightah commented 5 years ago

The whole cache directory is owned by www-data within the container which is: UID: 33 GID: 33

The folders are set to permissions 700 and files as 600

You're trying to remove as a user that does not have ownership to touch any of those folders and files. chmod -R 760 /home/steamcache/cache/data and make sure that your steamcache user is added to GID 33 which is likely www-data or http depending on your distro.

New files will be created with permissions 600 so any time you plan to do a mass removal you'll need to run the chmod command above again.

borzaka commented 5 years ago

Added my steamcache user to www-data group. I'am using Debian 9 stretch 64-bit PC (amd64).

$ groups
steamcache www-data docker

But when I try to change the permissions, this happens:

$ chmod -R 760 /home/steamcache/cache/data
chmod: changing permissions of '/home/steamcache/cache/data': Operation not permitted
chmod: changing permissions of '/home/steamcache/cache/data/cache': Operation not permitted
chmod: cannot read directory '/home/steamcache/cache/data/cache': Permission denied

Or I should execute this command as root?

ls -la info up to home directory: I can't enter to the cache folder in here.

/cache/data$ ls -la
total 12
drwxr-xr-x   3 www-data www-data 4096 Mar  9 16:18 .
drwxr-xr-x   4 root     root     4096 Mar  9 16:18 ..
drwx------ 258 www-data root     4096 Mar 15 12:27 cache
/cache$ ls -la
total 16
drwxr-xr-x 4 root       root       4096 Mar  9 16:18 .
drwxr-xr-x 3 steamcache steamcache 4096 Mar  9 16:35 ..
drwxr-xr-x 3 www-data   www-data   4096 Mar  9 16:18 data
drwxr-xr-x 2 www-data   www-data   4096 Mar  9 16:18 logs
$ ls -la
total 28
drwxr-xr-x 3 steamcache steamcache 4096 Mar  9 16:35 .
drwxr-xr-x 6 root       root       4096 Mar  9 15:45 ..
-rw------- 1 steamcache steamcache 2463 Mar 20 16:19 .bash_history
-rw-r--r-- 1 steamcache steamcache  220 Mar  9 15:45 .bash_logout
-rw-r--r-- 1 steamcache steamcache 3526 Mar  9 15:45 .bashrc
drwxr-xr-x 4 root       root       4096 Mar  9 16:18 cache
-rw-r--r-- 1 steamcache steamcache  675 Mar  9 15:45 .profile
VibroAxe commented 5 years ago

Yeah, you'll probably want to do this operation as root (or a container subshell docker exec -it lancache /bin/bash)

nightah commented 5 years ago

@borzaka per @VibroAxe's suggestions, you want to either run it as root or you can run the command within the container itself: docker exec it lancache chmod -R 760 /data/cache.

unspec commented 4 years ago

Closing as no response for > 6 months