home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.18k stars 31.15k forks source link

allowlist_external_dirs directive ignored #124509

Closed leonbrag closed 3 months ago

leonbrag commented 3 months ago

The problem

HASS is running in docker container and docker container properly maps external directory on the host to HASS's container directory as /media-frigate:

image

I can verify inside of the HASS docker container that directory exists and is valid:

This is inside of the HASS container:

leonbrag@hpdebian:~$ sudo docker exec -it homeassistant bash
hpdebian:/config# cd /media-frigate/clips/
hpdebian:/media-frigate/clips# pwd
/media-frigate/clips
hpdebian:/media-frigate/clips# df -h
Filesystem                Size      Used Available Use% Mounted on
overlay                 226.7G      6.8G    208.4G   3% /
tmpfs                    64.0M         0     64.0M   0% /dev
shm                      64.0M         0     64.0M   0% /dev/shm
/dev/sda1               457.4G     21.9G    412.2G   5% /config
/dev/sdb1               457.4G    251.6G    182.4G  58% /media-frigate
/dev/nvme0n1p2          226.7G      6.8G    208.4G   3% /etc/localtime
/dev/nvme0n1p2          226.7G      6.8G    208.4G   3% /etc/resolv.conf
/dev/nvme0n1p2          226.7G      6.8G    208.4G   3% /etc/hostname
/dev/nvme0n1p2          226.7G      6.8G    208.4G   3% /etc/hosts

In the HASS configuration YAML add /media-frigate to allow list:

leonbrag@hpdebian:/media/data/hass$ cat configuration.yaml


# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
#notify: !include notify.yaml

homeassistant:
  name: Home
  allowlist_external_dirs:
    - /media-frigate/clips

However when my automation uses following path:

 data:
      images: '-/media-frigate/clips/test-1724440646.270697-1kpiu2.jpg'

HASS reports error: Error: remote_path_not_allowed

this leads me to believe that allowlist_external_dirs is ignored.

What version of Home Assistant Core has the issue?

core-2024.8.2

What was the last working version of Home Assistant Core?

na

What type of installation are you running?

Home Assistant Container

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

2024-08-23 12:17:45.626 ERROR (MainThread) [homeassistant.components.automation.email] email: Error executing script. Error for call_service at pos 1: remote_path_not_allowed
2024-08-23 12:17:45.627 ERROR (MainThread) [homeassistant.components.automation.email] Error while executing automation automation.email: remote_path_not_allowed

Example YAML snippet

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
#notify: !include notify.yaml

homeassistant:
  name: Home
  allowlist_external_dirs:
    - /media-frigate/clips

Anything in the logs that might be useful for us?

No response

Additional information

No response

jgverweij commented 3 months ago

Do you really need the hyphen ('-') at the beginning of the path reference?

So really:

data:
      images: '-/media-frigate/clips/test-1724440646.270697-1kpiu2.jpg'

Instead of:

data:
      images: '/media-frigate/clips/test-1724440646.270697-1kpiu2.jpg'
leonbrag commented 3 months ago

I think lack of space was the problem!

leonbrag commented 3 months ago

removed space.