diff mbox series

[1/2] uhttpd: Reload config after uhttpd-mod-ubus was added

Message ID 20210320123228.3697143-1-hauke@hauke-m.de
State Superseded
Delegated to: Hauke Mehrtens
Headers show
Series [1/2] uhttpd: Reload config after uhttpd-mod-ubus was added | expand

Commit Message

Hauke Mehrtens March 20, 2021, 12:32 p.m. UTC
Without this change the config is only committed, but the uhttpd daemon
is not reloaded. This reload is needed to apply the config. Without the
reload of uhttpd, the ubus server is not available over http and returns
a Error 404.

This caused problems when installing luci on the snapshots and
accessing it without reloading uhttpd.

There is another bug in uhttpd that it does not discard the request data
when it returned a http error 404 for a post request and interpret it as
part of the next request on the same TCP connection.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 package/network/services/uhttpd/files/ubus.default | 2 ++
 1 file changed, 2 insertions(+)

Comments

Hauke Mehrtens March 20, 2021, 12:35 p.m. UTC | #1
On 3/20/21 1:32 PM, Hauke Mehrtens wrote:
> Without this change the config is only committed, but the uhttpd daemon
> is not reloaded. This reload is needed to apply the config. Without the
> reload of uhttpd, the ubus server is not available over http and returns
> a Error 404.
> 
> This caused problems when installing luci on the snapshots and
> accessing it without reloading uhttpd.
> 
> There is another bug in uhttpd that it does not discard the request data
> when it returned a http error 404 for a post request and interpret it as
> part of the next request on the same TCP connection.
> 
> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
> ---
>   package/network/services/uhttpd/files/ubus.default | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/package/network/services/uhttpd/files/ubus.default b/package/network/services/uhttpd/files/ubus.default
> index ca9e72a3150a..35724ba57e03 100644
> --- a/package/network/services/uhttpd/files/ubus.default
> +++ b/package/network/services/uhttpd/files/ubus.default
> @@ -3,11 +3,13 @@
>   if [ -z "$(uci -q get uhttpd.main.ubus_prefix)" ]; then
>   	uci set uhttpd.main.ubus_prefix=/ubus
>   	uci commit uhttpd
> +	reload_config
>   fi
>   
>   [ "$(uci -q get uhttpd.main.ubus_socket)" = "/var/run/ubus.sock" ] && {
>   	uci set uhttpd.main.ubus_socket='/var/run/ubus/ubus.sock'
>   	uci commit uhttpd
> +	reload_config
>   }
>   
>   exit 0
> 

I will also increase the PKG_RELEASE.

Hauke
Jo-Philipp Wich March 20, 2021, 1:05 p.m. UTC | #2
Hi Hauke,

thanks for looking into it!

I have a couple of remarks...

> [...]
>  [ "$(uci -q get uhttpd.main.ubus_socket)" = "/var/run/ubus.sock" ] && {
>  	uci set uhttpd.main.ubus_socket='/var/run/ubus/ubus.sock'
>  	uci commit uhttpd
> +	reload_config

That might reload other, unrelated changes. It likely isn't that much of
a problem in practise for most users but could interfere with other
provisioning setups or custom logic.

I think it is better if we simply perform a selective /etc/init.d/uhttpd
reload call here.

>  }
>  
>  exit 0
>
Hauke Mehrtens March 20, 2021, 7:58 p.m. UTC | #3
On 3/20/21 2:05 PM, Jo-Philipp Wich wrote:
> Hi Hauke,
> 
> thanks for looking into it!
> 
> I have a couple of remarks...
> 
>> [...]
>>   [ "$(uci -q get uhttpd.main.ubus_socket)" = "/var/run/ubus.sock" ] && {
>>   	uci set uhttpd.main.ubus_socket='/var/run/ubus/ubus.sock'
>>   	uci commit uhttpd
>> +	reload_config
> 
> That might reload other, unrelated changes. It likely isn't that much of
> a problem in practise for most users but could interfere with other
> provisioning setups or custom logic.
> 
> I think it is better if we simply perform a selective /etc/init.d/uhttpd
> reload call here.

thanks for the hint, I updated the code.

Hauke
diff mbox series

Patch

diff --git a/package/network/services/uhttpd/files/ubus.default b/package/network/services/uhttpd/files/ubus.default
index ca9e72a3150a..35724ba57e03 100644
--- a/package/network/services/uhttpd/files/ubus.default
+++ b/package/network/services/uhttpd/files/ubus.default
@@ -3,11 +3,13 @@ 
 if [ -z "$(uci -q get uhttpd.main.ubus_prefix)" ]; then
 	uci set uhttpd.main.ubus_prefix=/ubus
 	uci commit uhttpd
+	reload_config
 fi
 
 [ "$(uci -q get uhttpd.main.ubus_socket)" = "/var/run/ubus.sock" ] && {
 	uci set uhttpd.main.ubus_socket='/var/run/ubus/ubus.sock'
 	uci commit uhttpd
+	reload_config
 }
 
 exit 0