Enhance Ubus Integration Documentation & Refine ACL Permissions (#30121)

* Enhance Ubus Integration Documentation & Refine ACL Permissions

The current documentation does not contain enough information to start using the ubus integration, and the current ACL config file gives more permission than is actually needed.

This change explains how to add a system user `hass` and documents the configuration of `/etc/config/rpcd` configuration file. Those steps are missing from the current configuration.

Credits for those valuable steps go to: https://github.com/kvj/hass_openwrt.

Further more, the current ACLs config file gives more permission than is actually needed to make the integration work.

* Tiny style tweaks

* Update source/_integrations/ubus.markdown

* Update source/_integrations/ubus.markdown

---------

Co-authored-by: c0ffeeca7 <38767475+c0ffeeca7@users.noreply.github.com>
This commit is contained in:
Simon 2023-12-04 09:00:17 +01:00 committed by GitHub
parent b2f0736665
commit aa7e0c6c9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,17 +20,33 @@ opkg update
opkg install rpcd-mod-file uhttpd-mod-ubus opkg install rpcd-mod-file uhttpd-mod-ubus
``` ```
And create on your OpenWrt device a read-only user to be used by setting up the ACL file `/usr/share/rpcd/acl.d/user.json`. Add a new system user `hass` (or do it in any other way that you prefer):
- Add line to /etc/passwd: hass:x:10001:10001:hass:/var:/bin/false
- Add line to /etc/shadow: hass:x:0:0:99999:7:::
Edit the `/etc/config/rpcd` and add the following lines:
```yaml
config login
option username 'hass'
option password '$p$hass'
list read hass
list read unauthenticated
list write hass
```
Then, create an ACL file at `/usr/share/rpcd/acl.d/hass.json` for the user `hass`:
```json ```json
{ {
"user": { "hass": {
"description": "Read only user access role", "description": "Access role for OpenWrt ubus integration",
"read": { "read": {
"ubus": { "ubus": {
"*": [ "*" ] "hostapd.*": ["get_clients"],
"uci": ["get"]
}, },
"uci": [ "*" ]
}, },
"write": {} "write": {}
} }