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

Not list files after set "ENFORCE_BASEPATH": true #171

Open
iStitch07 opened this issue Nov 10, 2019 · 15 comments
Open

Not list files after set "ENFORCE_BASEPATH": true #171

iStitch07 opened this issue Nov 10, 2019 · 15 comments

Comments

@iStitch07
Copy link

iStitch07 commented Nov 10, 2019

Hello, what I do wrong?
I setup configurator via pip3 install

/etc/hass/settings.conf

{
"LISTENIP": "0.0.0.0",
"PORT": 3218,
"GIT": false,
"BASEPATH": "/home/hass/.homeassistant/",
"ENFORCE_BASEPATH": true,
"SSL_CERTIFICATE": null,
"SSL_KEY": null,
"IGNORE_SSL": false,
"HASS_API": "http://127.0.0.1:8123/api/",
"HASS_WS_API": null,
"HASS_API_PASSWORD": "Long time live access token"
"USERNAME": null,
"PASSWORD": null,
"ALLOWED_NETWORKS": [],
"ALLOWED_DOMAINS": [],
"BANNED_IPS": [],
"BANLIMIT": 0,
"IGNORE_PATTERN": [],
"DIRSFIRST": true,
"HIDEHIDDEN": true,
"SESAME": null,
"SESAME_TOTP_SECRET": null,
"VERIFY_HOSTNAME": null,
"ENV_PREFIX": "HC_",
"NOTIFY_SERVICE": "persistent_notification.create"
}

/etc/systemd/system/[email protected]
[Unit]
Description=HASS-Configurator
After=network-online.target

[Service]
Type=simple
User=%i
WorkingDirectory=/home/hass/.homeassistant/
ExecStart=/usr/local/bin/hass-configurator /etc/hass/settings.conf
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target

======================================================

/var/log/syslog
Nov 10 19:41:13 axius hass-configurator[1123]: INFO:2019-11-10 19:41:13,977:hass_configurator.configurator:192.168.1.123 - "GET / HTTP/1.1" 200 -
Nov 10 19:41:14 axius hass-configurator[1123]: INFO:2019-11-10 19:41:14,854:hass_configurator.configurator:192.168.1.123 - "GET /api/listdir?path=. HTTP/1.1" 200 -
Nov 10 19:41:14 axius hass-configurator[1123]: WARNING:2019-11-10 19:41:14,855:hass_configurator.configurator:Access denied.

======================================================
2019-11-10 в 19 46 59

======================================================

If I change "ENFORCE_BASEPATH": to false all start working good, but possible to change directory and list file system, what I want to avoid.

@danielperna84
Copy link
Owner

Please try to start the configurator without the enforced basepath, then open a file within the basepath. That way the configurator will re-open the same file and path at the next startup. Then stop the configurator, enable enforce basepath, then start again. It should then start with the file you had open last and display the content of the directory.

I assume you get the error because prior to shutting down the configurator you had a file open that was outside of the basepath. The configurator remembers this and tries to access the same file when you restart the configurator, even though with the enforced basepath access to that file is now denied.

Does this solution work?

@iStitch07
Copy link
Author

iStitch07 commented Nov 25, 2019

Nope. i migrated to docker and there configurator work perfect. But I special try to reproduce situation in dev environment and receive same result
Now configurator endorsed to
"BASEPATH": "/home/projects/",
"ENFORCE_BASEPATH": true,

And any way
Снимок экрана 2019-11-25 в 22 33 34

Log:
INFO:2019-11-25 22:33:06,405:hass_configurator.configurator:Starting server
INFO:2019-11-25 22:33:06,406:hass_configurator.configurator:Listening on: http://0.0.0.0:3218
INFO:2019-11-25 22:33:09,547:hass_configurator.configurator:192.168.1.123 - "GET / HTTP/1.1" 200 -
WARNING:2019-11-25 22:33:09,574:hass_configurator.configurator:Exception getting bootstrap
WARNING:2019-11-25 22:33:09,575:hass_configurator.configurator:<urlopen error [Errno 111] Connection refused>
INFO:2019-11-25 22:33:12,053:hass_configurator.configurator:192.168.1.123 - "GET /api/file?filename=/home/projects/smarthome/docker-compose.yml HTTP/1.1" 200 -
INFO:2019-11-25 22:33:12,959:hass_configurator.configurator:192.168.1.123 - "GET /api/listdir?path=. HTTP/1.1" 200 -
WARNING:2019-11-25 22:33:12,961:hass_configurator.configurator:Access denied.

Because its not affecting me now, you can close this issue without resolution, just for your information.

@victor-falcon
Copy link

I have the same problem right now. I can't navigate... 😞

@victor-falcon
Copy link

There´re any ways to fully restart or reset the plugging? I uninstall and install but the problem persist.

@danielperna84
Copy link
Owner

danielperna84 commented Dec 9, 2019

I don't know why this is happening. As a workaround you should be able to open a specific folder manually. To do this, open the JavaScript console of your browser and execute the function listdir('/your/path').

It would also be interesting if this problem persists when you use another browser, and if learing the browser cache can solve the problem as well.

@victor-falcon
Copy link

image

listdir command doesn't work.

I try to open configurator with another browser and the problem persist

@victor-falcon
Copy link

I also saw this, maybe it helps
image

@danielperna84
Copy link
Owner

There are two options:

  1. There seems to be a problem with the ingress-functionality of hassio. It somehow messes with the external dependencies the configurator relies on. If this is really the case, please open an issue at the hassio-addons repository.
  2. You have something like PiHole or some other content blocking mechanism active that prevents the configurator to load these external resources.

@victor-falcon
Copy link

There're another problem. Now I can load base path with listdir('/') but when I try to open config folder I get no response.

image
image

@danielperna84
Copy link
Owner

I don't use hassio and the ingress-functionality, so I don't know what the problem could be. Please head over to the forum at https://community.home-assistant.io to see if someone there knows why this is happening.

@victor-falcon
Copy link

The problem it's not with ingress. When I access from local network with local IP it still happening.

@danielperna84
Copy link
Owner

Could you make another screenshot like above when accessing locally? And instead of the preview-tab please open the response-tab.

@ravikwow
Copy link

ravikwow commented Sep 17, 2021

I start configurator.py with settings.conf file. If I set ENFORCE_BASEPATH to false then work fine and I can view all file system. But if i set ENFORCE_BASEPATH to true then I view situation on screenshot: I can not view basepath directory, but configurator.py open file from previous session from basepath directory.
Error on console "Permission denied."show only if I set ENFORCE_BASEPATH to true.
{
"LISTENIP": "0.0.0.0",
"PORT": 3218,
"GIT": false,
"BASEPATH": "/etc/homeassistant/",
"ENFORCE_BASEPATH": true,
"SSL_CERTIFICATE": null,
"SSL_KEY": null,
"IGNORE_SSL": false,
"HASS_API": null,
"HASS_WS_API": null,
"HASS_API_PASSWORD": null,
"USERNAME": null,
"PASSWORD": null,
"ALLOWED_NETWORKS": [],
"ALLOWED_DOMAINS": [],
"BANNED_IPS": [],
"BANLIMIT": 0,
"IGNORE_PATTERN": [],
"DIRSFIRST": true,
"SESAME": null,
"SESAME_TOTP_SECRET": null,
"VERIFY_HOSTNAME": null,
"ENV_PREFIX": "HC_",
"NOTIFY_SERVICE": "persistent_notification.create"
}
Снимок экрана в 2021-09-17 13-42-51
.

@danielperna84
Copy link
Owner

@ravikwow

Have you tried this? Also please remove the trailing / in your BASEPATH configuration.

@ravikwow
Copy link

ravikwow commented Sep 17, 2021

@ravikwow

Have you tried this? Also please remove the trailing / in your BASEPATH configuration.

Thanks, I remove /, it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants