Re: procd, possible hotplug issue?

2024-02-23 Thread Daniel Golle
On Wed, Feb 21, 2024 at 10:01:30PM +0100, e9hack wrote:
> Am 21.02.2024 um 01:21 schrieb Daniel Golle:
> > 
> > Yep, I didn't think about empty variables when I built this...
> > 
> > Can you test this please:
> > https://github.com/openwrt/procd/pull/3
> > 
> 
> This does fix the issue.
> 
> If I test a modified executable, I replaced it by a link to a link on a 
> automatically mounted usb stick. The link on the usb stick points to the 
> modified executable. e.g.:
> 
> /sbin/dnsmasq is renamed to /sbin/dnsmasq.old
> /sbin/dnsmasq -> /mnt/test/dnsmasq/dnsmasq
> /mnt/test/dnsmasq/dnsmasq -> /mnt/test/dnsmasq/dnsmasq-test-something
> 
> If the modification bricks the router, I replace the last link on the usb 
> stick by
> 
> /mnt/test/dnsmasq/dnsmasq -> /sbin/dnsmasq.old
> 
> or
> 
> /mnt/test/dnsmasq/dnsmasq -> /rom/sbin/dnsmasq
> 
> and the router is operational again.
> 
> This doesn't work for procd since procd is needed before the usb stick is 
> mounted.
> 
> How can I do similar things for procd?

There isn't any as convenient option, for the reason you named.
When hacking on procd the qemu targets (malta, armvirt, x86) are very
handy for testing and debugging. Once things work well there I move on
to a "friendly" board (ie. with dualboot/recovery feature, serial
console, pstore which is also good for PID 1 crashes, ...).

> 
> Regards,
> Hartmut
> 
> 
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: procd, possible hotplug issue?

2024-02-21 Thread e9hack

Am 21.02.2024 um 01:21 schrieb Daniel Golle:


Yep, I didn't think about empty variables when I built this...

Can you test this please:
https://github.com/openwrt/procd/pull/3



This does fix the issue.

If I test a modified executable, I replaced it by a link to a link on a 
automatically mounted usb stick. The link on the usb stick points to the 
modified executable. e.g.:

/sbin/dnsmasq is renamed to /sbin/dnsmasq.old
/sbin/dnsmasq -> /mnt/test/dnsmasq/dnsmasq
/mnt/test/dnsmasq/dnsmasq -> /mnt/test/dnsmasq/dnsmasq-test-something

If the modification bricks the router, I replace the last link on the usb stick 
by

/mnt/test/dnsmasq/dnsmasq -> /sbin/dnsmasq.old

or

/mnt/test/dnsmasq/dnsmasq -> /rom/sbin/dnsmasq

and the router is operational again.

This doesn't work for procd since procd is needed before the usb stick is 
mounted.

How can I do similar things for procd?

Regards,
Hartmut


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: procd, possible hotplug issue?

2024-02-20 Thread Daniel Golle
On Tue, Feb 20, 2024 at 11:47:49PM +0100, e9hack wrote:
> Am 20.02.2024 um 14:14 schrieb Paul D:
> > 
> > Could you show an example of this?
> > 
> 
> I modified /usr/lib/dnsmasq/dhcp-script.sh to see additional variables in the 
> syslog:
> 
> --- dhcp-script.sh.orig 2024-02-14 16:22:53.0 +0100
> +++ dhcp-script.sh  2024-02-20 22:55:33.0 +0100
> @@ -50,4 +50,7 @@ esac
> 
>  json_close_array env
> 
> -[ -n "$hotplugobj" ] && ubus call hotplug.${hotplugobj} call "$(json_dump)"
> +[ -n "$hotplugobj" ] && {
> +   logger -t dhcp-script "ubus call hotplug.${hotplugobj} call 
> \"$(json_dump)\""
> +   ubus call hotplug.${hotplugobj} call "$(json_dump)"
> +}
> 
> 
> 'logread -e 192.168.104.82' with HOSTNAME empty shows:
> Tue Feb 20 23:14:33 2024 user.notice dhcp-script: ubus call hotplug.dhcp call 
> "{ "env": [ "MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", 
> "ACTION=update", "HOSTNAME=" ] }"
> Tue Feb 20 23:14:33 2024 user.notice dhcp-script: ubus call hotplug.dhcp call 
> "{ "env": [ "MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", 
> "ACTION=update", "HOSTNAME=" ] }"
> Tue Feb 20 23:14:34 2024 user.notice nft-qos-monitor: ACTION=update, 
> MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, HOSTNAME=WLAN-DSL9
> Tue Feb 20 23:14:34 2024 user.notice dhcp-script: ubus call hotplug.neigh 
> call "{ "env": [ "MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", 
> "ACTION=add" ] }"
> Tue Feb 20 23:14:34 2024 user.notice nft-qos-dynamic: ACTION=update, 
> MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, HOSTNAME=WLAN-DSL9
> Tue Feb 20 23:14:35 2024 user.notice dhcp-script: ubus call hotplug.neigh 
> call "{ "env": [ "MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", 
> "ACTION=add" ] }"
> Tue Feb 20 23:14:35 2024 user.notice nft-qos-monitor: ACTION=update, 
> MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, HOSTNAME=WLAN-DSL9
> Tue Feb 20 23:14:36 2024 user.notice nft-qos-dynamic: ACTION=update, 
> MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, HOSTNAME=WLAN-DSL9
> 
> 'logread -e 192.168.104.84' with HOSTNAME set shows:
> Tue Feb 20 23:14:34 2024 user.notice dhcp-script: ubus call hotplug.dhcp call 
> "{ "env": [ "MACADDR=bb:bb:bb:bb:bb:bb", "IPADDR=192.168.104.84", 
> "ACTION=update", "HOSTNAME=raspberrypi2" ] }"
> Tue Feb 20 23:14:34 2024 user.notice dhcp-script: ubus call hotplug.neigh 
> call "{ "env": [ "MACADDR=bb:bb:bb:bb:bb:bb", "IPADDR=192.168.104.84", 
> "ACTION=add" ] }"
> Tue Feb 20 23:14:35 2024 user.notice dhcp-script: ubus call hotplug.neigh 
> call "{ "env": [ "MACADDR=bb:bb:bb:bb:bb:bb", "IPADDR=192.168.104.84", 
> "ACTION=add" ] }"
> Tue Feb 20 23:14:36 2024 user.notice nft-qos-monitor: ACTION=update, 
> MACADDR=bb:bb:bb:bb:bb:bb, IPADDR=192.168.104.84, HOSTNAME=raspberrypi2
> Tue Feb 20 23:14:36 2024 user.notice nft-qos-dynamic: ACTION=update, 
> MACADDR=bb:bb:bb:bb:bb:bb, IPADDR=192.168.104.84, HOSTNAME=raspberrypi2
> 
> WLAN-DSL9 is the router name:
> root@WLAN-DSL9:~# echo $HOSTNAME
> WLAN-DSL9
> 
> If I replace HOSTNAME by DHCP_HOSTNAME in /usr/lib/dnsmasq/dhcp-script.sh, 
> /etc/hotplug.d/dhcp/00-nft-qos-monitor and 
> /etc/hotplug.d/dhcp/01-nft-qos-dynamic, I get the following output:
> 
> Tue Feb 20 23:44:43 2024 user.notice dhcp-script: ubus call hotplug.dhcp call 
> "{ "env": [ "MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", 
> "ACTION=update", "DHCP_HOSTNAME=" ] }"
> Tue Feb 20 23:44:43 2024 user.notice dhcp-script: ubus call hotplug.dhcp call 
> "{ "env": [ "MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", 
> "ACTION=update", "DHCP_HOSTNAME=" ] }"
> Tue Feb 20 23:44:44 2024 user.notice nft-qos-monitor: ACTION=update, 
> MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, DHCP_HOSTNAME=
> Tue Feb 20 23:44:44 2024 user.notice dhcp-script: ubus call hotplug.neigh 
> call "{ "env": [ "MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", 
> "ACTION=add" ] }"
> Tue Feb 20 23:44:44 2024 user.notice nft-qos-dynamic: ACTION=update, 
> MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, DHCP_HOSTNAME=
> Tue Feb 20 23:44:45 2024 user.notice dhcp-script: ubus call hotplug.neigh 
> call "{ "env": [ "MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", 
> "ACTION=add" ] }"
> Tue Feb 20 23:44:45 2024 user.notice nft-qos-monitor: ACTION=update, 
> MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, DHCP_HOSTNAME=
> Tue Feb 20 23:44:46 2024 user.notice nft-qos-dynamic: ACTION=update, 
> MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, DHCP_HOSTNAME=
> 
> If procd generates the hotplug call, it filters out empty variables. From 
> procd hotplug-dispatch.c line 239:
> 
>   *tmp = '\0';
>   if (validate_envvarname(enve))
>   continue;
>   *tmp = '=';
> 
>   if (!strlen(++tmp))
>   continue;

Yep, I didn't think about empty variables when I built this...

Can you test this please:
https://github.com/openwrt/procd/pull/3


> 
> Regards,
> Hartmut
> 
> 
> 
> 
> 

Re: procd, possible hotplug issue?

2024-02-20 Thread e9hack

Am 20.02.2024 um 14:14 schrieb Paul D:


Could you show an example of this?



I modified /usr/lib/dnsmasq/dhcp-script.sh to see additional variables in the 
syslog:

--- dhcp-script.sh.orig 2024-02-14 16:22:53.0 +0100
+++ dhcp-script.sh  2024-02-20 22:55:33.0 +0100
@@ -50,4 +50,7 @@ esac

 json_close_array env

-[ -n "$hotplugobj" ] && ubus call hotplug.${hotplugobj} call "$(json_dump)"
+[ -n "$hotplugobj" ] && {
+   logger -t dhcp-script "ubus call hotplug.${hotplugobj} call 
\"$(json_dump)\""
+   ubus call hotplug.${hotplugobj} call "$(json_dump)"
+}


'logread -e 192.168.104.82' with HOSTNAME empty shows:
Tue Feb 20 23:14:33 2024 user.notice dhcp-script: ubus call hotplug.dhcp call "{ "env": [ 
"MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", "ACTION=update", "HOSTNAME=" ] }"
Tue Feb 20 23:14:33 2024 user.notice dhcp-script: ubus call hotplug.dhcp call "{ "env": [ 
"MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", "ACTION=update", "HOSTNAME=" ] }"
Tue Feb 20 23:14:34 2024 user.notice nft-qos-monitor: ACTION=update, 
MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, HOSTNAME=WLAN-DSL9
Tue Feb 20 23:14:34 2024 user.notice dhcp-script: ubus call hotplug.neigh call "{ "env": [ 
"MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", "ACTION=add" ] }"
Tue Feb 20 23:14:34 2024 user.notice nft-qos-dynamic: ACTION=update, 
MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, HOSTNAME=WLAN-DSL9
Tue Feb 20 23:14:35 2024 user.notice dhcp-script: ubus call hotplug.neigh call "{ "env": [ 
"MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", "ACTION=add" ] }"
Tue Feb 20 23:14:35 2024 user.notice nft-qos-monitor: ACTION=update, 
MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, HOSTNAME=WLAN-DSL9
Tue Feb 20 23:14:36 2024 user.notice nft-qos-dynamic: ACTION=update, 
MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, HOSTNAME=WLAN-DSL9

'logread -e 192.168.104.84' with HOSTNAME set shows:
Tue Feb 20 23:14:34 2024 user.notice dhcp-script: ubus call hotplug.dhcp call "{ "env": [ 
"MACADDR=bb:bb:bb:bb:bb:bb", "IPADDR=192.168.104.84", "ACTION=update", "HOSTNAME=raspberrypi2" ] 
}"
Tue Feb 20 23:14:34 2024 user.notice dhcp-script: ubus call hotplug.neigh call "{ "env": [ 
"MACADDR=bb:bb:bb:bb:bb:bb", "IPADDR=192.168.104.84", "ACTION=add" ] }"
Tue Feb 20 23:14:35 2024 user.notice dhcp-script: ubus call hotplug.neigh call "{ "env": [ 
"MACADDR=bb:bb:bb:bb:bb:bb", "IPADDR=192.168.104.84", "ACTION=add" ] }"
Tue Feb 20 23:14:36 2024 user.notice nft-qos-monitor: ACTION=update, 
MACADDR=bb:bb:bb:bb:bb:bb, IPADDR=192.168.104.84, HOSTNAME=raspberrypi2
Tue Feb 20 23:14:36 2024 user.notice nft-qos-dynamic: ACTION=update, 
MACADDR=bb:bb:bb:bb:bb:bb, IPADDR=192.168.104.84, HOSTNAME=raspberrypi2

WLAN-DSL9 is the router name:
root@WLAN-DSL9:~# echo $HOSTNAME
WLAN-DSL9

If I replace HOSTNAME by DHCP_HOSTNAME in /usr/lib/dnsmasq/dhcp-script.sh, 
/etc/hotplug.d/dhcp/00-nft-qos-monitor and 
/etc/hotplug.d/dhcp/01-nft-qos-dynamic, I get the following output:

Tue Feb 20 23:44:43 2024 user.notice dhcp-script: ubus call hotplug.dhcp call "{ "env": [ 
"MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", "ACTION=update", "DHCP_HOSTNAME=" ] }"
Tue Feb 20 23:44:43 2024 user.notice dhcp-script: ubus call hotplug.dhcp call "{ "env": [ 
"MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", "ACTION=update", "DHCP_HOSTNAME=" ] }"
Tue Feb 20 23:44:44 2024 user.notice nft-qos-monitor: ACTION=update, 
MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, DHCP_HOSTNAME=
Tue Feb 20 23:44:44 2024 user.notice dhcp-script: ubus call hotplug.neigh call "{ "env": [ 
"MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", "ACTION=add" ] }"
Tue Feb 20 23:44:44 2024 user.notice nft-qos-dynamic: ACTION=update, 
MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, DHCP_HOSTNAME=
Tue Feb 20 23:44:45 2024 user.notice dhcp-script: ubus call hotplug.neigh call "{ "env": [ 
"MACADDR=aa:aa:aa:aa:aa:aa", "IPADDR=192.168.104.82", "ACTION=add" ] }"
Tue Feb 20 23:44:45 2024 user.notice nft-qos-monitor: ACTION=update, 
MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, DHCP_HOSTNAME=
Tue Feb 20 23:44:46 2024 user.notice nft-qos-dynamic: ACTION=update, 
MACADDR=aa:aa:aa:aa:aa:aa, IPADDR=192.168.104.82, DHCP_HOSTNAME=

If procd generates the hotplug call, it filters out empty variables. From procd 
hotplug-dispatch.c line 239:

*tmp = '\0';
if (validate_envvarname(enve))
continue;
*tmp = '=';

if (!strlen(++tmp))
continue;

Regards,
Hartmut


 



___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: procd, possible hotplug issue?

2024-02-20 Thread Paul D

On 2024-02-17 22:55, e9hack wrote:

Hi,

I face a problem with hotplug calls. To execute hotplug calls, procd
checks given environment variables. If a variable is empty, it is
simply not set by procd. If such a variable is already set by the
shell, the called hotplug script gets a wrong value. This occurs with
dhcp hotplug scripts. On some dhcp changes, dnsmasq executes its dhcp
script. This sets the variable HOSTNAME. Sometimes this value is
empty. This results in calling the hotplug script with HOSTNAME set to
the router name, because the variable is already set. I think, procd
must clear or delete such environment variables.

Regards,
Hartmut



Could you show an example of this?



___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel