freifunk / openwrt-packages

Freifunk specific global OpenWrt Packages
Apache License 2.0
26 stars 33 forks source link

mod-freifunk: use libuci-lua in place of luci.model.uci #28

Closed SvenRoederer closed 4 years ago

SvenRoederer commented 4 years ago

The LuCI-page currently fails with:

/usr/lib/lua/luci/model/cbi/freifunk/profile.lua:12: attempt to concatenate local 'community' (a boolean value) stack traceback: /usr/lib/lua/luci/model/cbi/freifunk/profile.lua:16: in function 'func' /usr/lib/lua/luci/cbi.lua:66: in function 'load' /usr/lib/lua/luci/dispatcher.lua:1348: in function '_cbi' /usr/lib/lua/luci/dispatcher.lua:1019: in function 'dispatch' /usr/lib/lua/luci/dispatcher.lua:980: in function 'dispatch' /usr/lib/lua/luci/dispatcher.lua:479: in function </usr/lib/lua/luci/dispatcher.lua:478>

This is caused by returning "false" when getting the "freifunk.community.name" via luci.model.uci. Upstream changed the luci-base package to route uci-requests through the RPCd. This change in turn requires setting up correct permissions for accessing the RPCd. Avoid this additional layer by using the libuci-lua which returns the correct result.

SvenRoederer commented 4 years ago

Have it as draft for now, to discuss and test

PolynomialDivision commented 4 years ago

I think it is better style to add detailed permissions in /usr/share/rpcd/acl.d/luci-mod-freifunk.json. Here is an example that should fix the read error (untested):

{
        "luci-mod-freifunk": {
                "description": "Provdies access to freifunk",
                "read": {
                        "uci": [ "freifunk" ],
                },
                "write": {
                }
        }
}
XDjackieXD commented 4 years ago

using PolynomialDivision's pointer I've extended the file as follows

{
        "luci-mod-freifunk": {
                "description": "Provdies access to freifunk",
                "read": {
                        "uci": [ "freifunk", "profile_*" ],
                },
                "write": {
                        "uci": [ "freifunk", "profile_*" ],
                }
        }
}

This fixes all errors that were also fixed by using libuci directly so I'd prefer this option.

SvenRoederer commented 4 years ago

@XDjackieXD can you add a PR for this?

As mentioned in https://github.com/freifunk-berlin/firmware/issues/816#issuecomment-649042765 and https://github.com/freifunk-berlin/firmware-packages/pull/206#issuecomment-648466155 the libuci-lua will work for reading the configs, but might to fail when writing. And using 2 libs, which offer the same function", in the same project surely will become really confusing,

XDjackieXD commented 4 years ago

@SvenRoederer I opened #32 with this fix. I tested this at home but I haven't tested this exact commit as I'm currently on my laptop so please test before merging.

SvenRoederer commented 4 years ago

withdrawn in favour of #32