Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FILE_DIR error? #79

Open
Death-Pact opened this issue Apr 5, 2022 · 9 comments
Open

FILE_DIR error? #79

Death-Pact opened this issue Apr 5, 2022 · 9 comments
Labels
question Further information is requested support

Comments

@Death-Pact
Copy link

I am able to get Send to work, but I noticed that my instance isn't using the volume I specified in the docker_compose.yml file.

My docker_compose.yml is as follows:

version: "3"

services:
send:
image: registry.gitlab.com/timvisee/send:latest
restart: always
ports:
- '1234:1234'
volumes:
- uploads:/uploads
environment:
- VIRTUAL_HOST=send.***.com
- VIRTUAL_PORT=1234
- DHPARAM_GENERATION=false
- NODE_ENV=production
- BASE_URL=https://send.***.com
- PORT=1234
- REDIS_HOST=redis

  # For local uploads storage
  # - FILE_DIR=/uploads

  # For S3 object storage (disable volume and FILE_DIR variable)
  # - AWS_ACCESS_KEY_ID=********
  # - AWS_SECRET_ACCESS_KEY=********
  # - S3_BUCKET=send
  # - S3_ENDPOINT=s3.us-west-2.amazonaws.com
  # - S3_USE_PATH_STYLE_ENDPOINT=true

  # To customize upload limits
  # - EXPIRE_TIMES_SECONDS=3600,86400,604800,2592000,31536000
  # - DEFAULT_EXPIRE_SECONDS=3600
  # - MAX_EXPIRE_SECONDS=31536000
  # - DOWNLOAD_COUNTS=1,2,5,10,15,25,50,100,1000
  # - MAX_DOWNLOADS=1000
  - MAX_FILE_SIZE=10737418240

redis:
image: 'redis:alpine'
restart: always
volumes:
- send-redis:/data

volumes:
send-redis:
uploads:

If I uncomment the FILE_DIR variable, Send gives me an error in the logs during file upload as follows:

{"Timestamp":1649169981773000000,"Logger":"FirefoxSend","Type":"uncaughtException","Severity":0,"Pid":1,"EnvVersion":"2.0","Fields":{"error":"Error: ENOENT: no such file or directory, unlink '/uploads/1-10889695b316358b'","stack":"\n at Object.unlinkSync (node:fs:1718:3)\n at WriteStream. (/app/server/storage/fs.js:33:12)\n at WriteStream.emit (node:events:402:35)\n at WriteStream.emit (node:domain:475:12)\n at emitErrorNT (node:internal/streams/destroy:157:8)\n at emitErrorCloseNT (node:internal/streams/destroy:122:3)\n at processTicksAndRejections (node:internal/process/task_queues:83:21)"}}

Basically, I just want to know where my files are going in this current setup because I cannot find the uploaded files anywhere in my bin/sh. This is more of a security question for me. I could very much be setting up Send incorrectly. Either way, I just want to know where my files get stored currently.

@gechandesu
Copy link

I am able to get Send to work, but I noticed that my instance isn't using the volume I specified in the docker_compose.yml file.

Make sure that the owner of the uploads directory on the host is the user with UID 1000. Inside the container, the Send is launched on behalf of the user "app" with this UID. The user in the container must have write access to the /uploads.

Basically, I just want to know where my files are going in this current setup because I cannot find the uploaded files anywhere in my bin/sh.

I ran into a similar problem and also didn’t understand where the files that didn’t end up in /uploads go.
Judging by the fact that the links to them stopped working before the download and time limits expired, I can assume that they were lost.

@Death-Pact
Copy link
Author

I ran into a similar problem and also didn’t understand where the files that didn’t end up in /uploads go. Judging by the fact that the links to them stopped working before the download and time limits expired, I can assume that they were lost.

I just recently found tmp files in the /var/lib/docker/overlay2 folder of the files I have been uploading. I am still wondering why this compose file isn't using the file directory I specify... any ideas?

@timvisee
Copy link
Owner

timvisee commented Apr 20, 2022

Send does currently not support using a local directory for uploads when running in production mode (NODE_ENV=production). You may switch to NODE_ENV=development instead to use FILE_DIR as configured. This limitation was introduced by Mozilla years back.

If you're experiencing permission errors, make sure to set proper directory permissions on your host for the mounted directory.

@timvisee timvisee added question Further information is requested support labels Apr 20, 2022
@bytebone
Copy link

I'm currently setting up Send and am encountering the same issue as OP. When the env FILE_DIR is defined, uploading files causes the same error as in the OP. Leaving it undefined allowed up- and downloading, but now I have no idea where the uploaded files go.
I've used a customized version of the docker-compose script to set up send and redis:

services:
  send:
    image: registry.gitlab.com/timvisee/send:latest
    restart: unless-stopped
    container_name: send
    env_file: send.env
    volumes:
      - files:/uploads
    networks:
      - default
      - nginx_default

  redis:
    image: 'redis:alpine'
    container_name: send-redis
    restart: unless-stopped
    volumes:
      - redis:/data
    networks:
      - default

volumes:
  files:
  redis:

networks:
  nginx_default:
    external: true
  default:

as well as the environment variables in a separate send.env file:

#Backend Config
VIRTUAL_HOST=send.web.site
VIRTUAL_PORT=1234
DHPARAM_GENERATION=false
NODE_ENV=production
BASE_URL=https://send.web.site
PORT=1234
#FILE_DIR=/uploads

since im new to docker and self hosting, i dont know how to check the write permissions for the data folder inside the volume. but as other containers are perfectly capable to r/w into them, i'd assume this isnt a permission issue.

i would love if send would use the assigned volume, but dont know how to get it to work. do i have to switch to the dev mode as mentioned in your previous comment to get this to work? or are there other workarounds that would allow the use of the specified volume?

@bytebone
Copy link

Update

I have been able to fix, or rather circumvent, this issue. After lots of investigation I found that inside the container, the /uploads folder (from the volume) is mounted with rwxr-xr-x permissions, with owner/group ID 0. Since the Send service launches and runs under user ID 1000, obviously it cannot write data into /uploads.
I couldn't find any way to manipulate the permissions of the mounted folder to allow user ID 1000 to write into it. So instead I forced Send to launch with ID 0 by changing my compose.yml like this:

services:
  send:
    user: "0"
    volumes: 
    - files:/uploads

(content reduced to relevant data)

Now, send runs as user ID 0 and is perfectly able to r/w in the /uploads folder, and encrypted files appear in the volumes' folder on the host as expected, even when using the production environment.

But, I am unsure if there are security or functionality implications with this approach. After a very short and dirty test, all seems to be working fine, but I will investigate more. I'd much appreciate some input from @timvisee if this is a stupid idea or not. For now, I'll leave it running as is.

@fcki1984
Copy link

it's work for me.

  • find uid=1000's user
nano /etc/passwd
  • The user of UID = 1000 is admin on my server
chown -R admin:admin path-you-local-map-folder (./uploads)
  • docker-compose.yaml
    volumes:
      - ./uploads:/uploads

      ......

      # For local uploads storage
      - FILE_DIR=/uploads

@arkprocession
Copy link

it's work for me.

* find `uid=1000`'s user
nano /etc/passwd
* The user  of  `UID = 1000` is `admin`  on my server
chown -R admin:admin path-you-local-map-folder (./uploads)
* docker-compose.yaml
    volumes:
      - ./uploads:/uploads

      ......

      # For local uploads storage
      - FILE_DIR=/uploads

Hi, do you know how would it be for windows?

@gdmn
Copy link

gdmn commented Jan 23, 2023

I think that the default upload directory is not /upload:

https://github.com/timvisee/send/blob/master/server/config.js#L188

@gdmn
Copy link

gdmn commented Jan 23, 2023

Send does currently not support using a local directory for uploads when running in production mode (NODE_ENV=production).

I run Send like this: podman run -v ./uploads:/uploads --detach --rm -it --name ffsend-instance -p 1443:1443 -e 'BASE_URL' -e 'FILE_DIR' -e 'MAX_FILE_SIZE' -e 'MAX_EXPIRE_SECONDS' registry.gitlab.com/timvisee/send:latest and I see uploaded files in ./uploads directory. What is the default mode?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested support
Projects
None yet
Development

No branches or pull requests

7 participants