docksal / boilerplate-drupal7

Drupal 7 boilerplate project with basic configuration powered by Docksal
https://docksal.io
13 stars 18 forks source link

Folder Permissions Issue when Uploading Media #8

Closed loopy3025 closed 6 years ago

loopy3025 commented 6 years ago

We have an issue when running docksal on Windows. When trying to upload a file, we get a permissions error. This does not make a lot of sense because the folders all have the correct permissions. Please see the screenshots for all the details.

captureahl capturefatureimage captureerror capturefolderpermissions

achekulaev commented 6 years ago
  1. Make sure the dir is writeable fin exec touch docroot/sites/default/files/12345
  2. Make sure that public:// is configured properly in Drupal
  3. Make sure tmp is configured properly in Drupal
# File system settings.
$conf['file_temporary_path'] = '/tmp';
# Workaround for permission issues with NFS shares
$conf['file_chmod_directory'] = 0777;
$conf['file_chmod_file'] = 0666;
loopy3025 commented 6 years ago

I have gone through all that, but I will quadruple check and provide screenshots. Tomorrow.

As a side note, I set it up on my mac today and I'm having the same problem.

achekulaev commented 6 years ago

THe fact that you experience the issue on Mac as well speaks in favor of error in site configuration, rather that some DevOps issue.

loopy3025 commented 6 years ago

Thanks again for always responding to us @achekulaev . We really appreciate it.

I ran through the list and here's the results...

1) Tested the permissions by deleting a file from the virtual environment on the command line... 1-check

2) Checked the settings.local.php 2-settings

3) Checked to make sure they're reflected in the system... 3-gui

4) Tested the upload... 4-error-in-gui

5) Looked at the watchdog error... 5-watchdog

Is there any more information I can help provide?

achekulaev commented 6 years ago

Show fin config please

loopy3025 commented 6 years ago

Sure thing. Thanks again for your help, Oleksii.

COMPOSE_PROJECT_NAME_SAFE: opwdd
COMPOSE_FILE:
C:/Users/afasoldt/.babun/cygwin/home/afasoldt/.docksal/stacks/volumes-bind.yml
C:/Users/afasoldt/.babun/cygwin/home/afasoldt/.docksal/stacks/stack-default.yml
ENV_FILE:
C:/Users/afasoldt/.babun/cygwin/home/afasoldt/projects/opwdd/.docksal/docksal.env
C:/Users/afasoldt/.babun/cygwin/home/afasoldt/projects/opwdd/.docksal/docksal-local.env

PROJECT_ROOT: /c/Users/afasoldt/.babun/cygwin/home/afasoldt/projects/opwdd
DOCROOT: docroot
VIRTUAL_HOST: opwdd.docksal
VIRTUAL_HOST_ALIASES: *.opwdd.docksal
IP: 192.168.64.100
MYSQL: 192.168.64.100:32774

Docker Compose configuration
---------------------
services:
  cli:
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      DOCROOT: docroot
      HOST_GID: null
      HOST_UID: null
      XDEBUG_CONFIG: remote_connect_back=0 remote_host=192.168.64.1
      XDEBUG_ENABLED: '0'
    hostname: cli
    image: docksal/cli:1.3-php5
    volumes:
    - docksal_ssh_agent:/.ssh-agent:ro
    - /home/docker
    - project_root:/var/www:rw,nocopy
  db:
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      MYSQL_DATABASE: default
      MYSQL_PASSWORD: user
      MYSQL_ROOT_PASSWORD: root
      MYSQL_USER: user
    hostname: db
    image: docksal/db:1.1-mysql-5.6
    ports:
    - 0:3306/tcp
    volumes:
    - project_root:/var/www:ro,nocopy
  web:
    depends_on:
      cli:
        condition: service_started
    dns:
    - 192.168.64.100
    - 8.8.8.8
    environment:
      APACHE_BASIC_AUTH_PASS: null
      APACHE_BASIC_AUTH_USER: null
      APACHE_DOCUMENTROOT: /var/www/docroot
    hostname: web
    image: docksal/web:2.1-apache2.4
    labels:
      io.docksal.project-root: /c/Users/afasoldt/.babun/cygwin/home/afasoldt/projects/opwdd
      io.docksal.virtual-host: opwdd.docksal,*.opwdd.docksal
    volumes:
    - project_root:/var/www:ro,nocopy
version: '2.1'
volumes:
  docksal_ssh_agent:
    external: true
    name: docksal_ssh_agent
  project_root:
    driver: local
    driver_opts:
      device: /c/Users/afasoldt/.babun/cygwin/home/afasoldt/projects/opwdd
      o: bind
      type: none

---------------------
loopy3025 commented 6 years ago

Here's an interesting thing. I spun up another site to make sure I was doing everything right and it has a smaller list of files at the moment, so it's easier to see what's going on.

When I try to change permissions on the folder from the command line, I get "Permission denied" When I try to do it from the machine using fin exec, it changes the permissions. However, it doesn't seem to persist. When I execute the command again, it goes through the process again as if the permissions have reverted back.

WEIRD!

different

loopy3025 commented 6 years ago

I took my mac off the network and I was able to set 777 permissions and it works fine now. It seems my windows machine is not allowed to actually set 777 due to Active Directory rules. Thank you for looking into this for me.

loopy3025 commented 6 years ago

Hey, @achekulaev I have a quick question. I noticed that when I run commands outside virtualization, it uses my windows credentials "AFasoldt". When I run it using fin exec, it uses "root". Is there any way I can get docker to use my windows credentials instead? I think that'll solve my problem.

achekulaev commented 6 years ago

@loopy3025 docker can not use your UID from Windows. Windows user id is incompatible with UNIX user id, because it uses much bigger integer than UNIX. But you don't need them to match on WIndows because on Windows Docker maps your files via SMB that ignores UNIX permissions. The problem you experienced happens on your host level not inside Docker.

loopy3025 commented 6 years ago

Sorry if I sound dense, @achekulaev but I'm not sure what that means. Is that a setting I can change in Docker?

achekulaev commented 6 years ago

:)

Is there any way I can get docker to use my windows credentials instead?

No

loopy3025 commented 6 years ago

It is now working for me for some reason. I think it's possible that using "run as administrator" on babun before a fin restart actually allows you to upload files in the site.

achekulaev commented 6 years ago

If you need to run babun as an administrator then it means windows permissions on your files are incorrect somewhere.