<div dir="ltr">Great, thanks :-)<div><br></div><div>Oldrich.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">so 28. 3. 2020 v 20:23 odesílatel Simon Kelley <<a href="mailto:simon@thekelleys.org.uk">simon@thekelleys.org.uk</a>> napsal:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Patch applied, thanks.<br>
<br>
<br>
Simon.<br>
<br>
<br>
On 20/03/2020 21:18, Oldřich Jedlička wrote:<br>
> Same as for the dbus, allow specifying ubus service name (namespace) on<br>
> the command line as an optional argument to --enable-ubus option.<br>
> <br>
> Signed-off-by: Oldřich Jedlička <<a href="mailto:oldium.pro@gmail.com" target="_blank">oldium.pro@gmail.com</a>><br>
> ---<br>
> man/dnsmasq.8 | 7 +++++--<br>
> src/config.h | 1 +<br>
> src/dnsmasq.h | 1 +<br>
> src/option.c | 14 +++++++++++---<br>
> src/ubus.c | 3 ++-<br>
> 5 files changed, 20 insertions(+), 6 deletions(-)<br>
> <br>
> diff --git a/man/dnsmasq.8 b/man/dnsmasq.8<br>
> index 2032a37..034e3cf 100644<br>
> --- a/man/dnsmasq.8<br>
> +++ b/man/dnsmasq.8<br>
> @@ -366,10 +366,13 @@ been built with DBus support. If the service name is given, dnsmasq<br>
> provides service at that name, rather than the default which is <br>
> .B uk.org.thekelleys.dnsmasq<br>
> .TP <br>
> -.B --enable-ubus<br>
> +.B --enable-ubus[=<service-name>]<br>
> Enable dnsmasq UBus interface. It sends notifications via UBus on<br>
> DHCPACK and DHCPRELEASE events. Furthermore it offers metrics.<br>
> -Requires that dnsmasq has been built with UBus support.<br>
> +Requires that dnsmasq has been built with UBus support. If the service<br>
> +name is given, dnsmasq provides service at that namespace, rather than<br>
> +the default which is<br>
> +.B dnsmasq<br>
> .TP<br>
> .B \-o, --strict-order<br>
> By default, dnsmasq will send queries to any of the upstream servers<br>
> diff --git a/src/config.h b/src/config.h<br>
> index b002560..7d08f7d 100644<br>
> --- a/src/config.h<br>
> +++ b/src/config.h<br>
> @@ -50,6 +50,7 @@<br>
> #define RANDFILE "/dev/urandom"<br>
> #define DNSMASQ_SERVICE "uk.org.thekelleys.dnsmasq" /* Default - may be overridden by config */<br>
> #define DNSMASQ_PATH "/uk/org/thekelleys/dnsmasq"<br>
> +#define DNSMASQ_UBUS_NAME "dnsmasq" /* Default - may be overridden by config */<br>
> #define AUTH_TTL 600 /* default TTL for auth DNS */<br>
> #define SOA_REFRESH 1200 /* SOA refresh default */<br>
> #define SOA_RETRY 180 /* SOA retry default */<br>
> diff --git a/src/dnsmasq.h b/src/dnsmasq.h<br>
> index f747868..b47ef74 100644<br>
> --- a/src/dnsmasq.h<br>
> +++ b/src/dnsmasq.h<br>
> @@ -1063,6 +1063,7 @@ extern struct daemon {<br>
> unsigned int duid_enterprise, duid_config_len;<br>
> unsigned char *duid_config;<br>
> char *dbus_name;<br>
> + char *ubus_name;<br>
> char *dump_file;<br>
> int dump_mask;<br>
> unsigned long soa_sn, soa_refresh, soa_retry, soa_expiry;<br>
> diff --git a/src/option.c b/src/option.c<br>
> index 9ffd7fc..1f698da 100644<br>
> --- a/src/option.c<br>
> +++ b/src/option.c<br>
> @@ -238,7 +238,7 @@ static const struct myoption opts[] =<br>
> { "caa-record", 1, 0 , LOPT_CAA },<br>
> { "dns-rr", 1, 0, LOPT_RR },<br>
> { "enable-dbus", 2, 0, '1' },<br>
> - { "enable-ubus", 0, 0, LOPT_UBUS },<br>
> + { "enable-ubus", 2, 0, LOPT_UBUS },<br>
> { "bootp-dynamic", 2, 0, '3' },<br>
> { "dhcp-mac", 1, 0, '4' },<br>
> { "no-ping", 0, 0, '5' },<br>
> @@ -428,7 +428,7 @@ static struct {<br>
> { 'z', OPT_NOWILD, NULL, gettext_noop("Bind only to interfaces in use."), NULL },<br>
> { 'Z', OPT_ETHERS, NULL, gettext_noop("Read DHCP static host information from %s."), ETHERSFILE },<br>
> { '1', ARG_ONE, "[=<busname>]", gettext_noop("Enable the DBus interface for setting upstream servers, etc."), NULL },<br>
> - { LOPT_UBUS, OPT_UBUS, NULL, gettext_noop("Enable the UBus interface."), NULL },<br>
> + { LOPT_UBUS, ARG_ONE, "[=<busname>]", gettext_noop("Enable the UBus interface."), NULL },<br>
> { '2', ARG_DUP, "<interface>", gettext_noop("Do not provide DHCP on this interface, only provide DNS."), NULL },<br>
> { '3', ARG_DUP, "[=tag:<tag>]...", gettext_noop("Enable dynamic address allocation for bootp."), NULL },<br>
> { '4', ARG_DUP, "set:<tag>,<mac address>", gettext_noop("Map MAC address (with wildcards) to option set."), NULL },<br>
> @@ -1881,7 +1881,15 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma<br>
> else<br>
> daemon->dbus_name = DNSMASQ_SERVICE;<br>
> break;<br>
> - <br>
> +<br>
> + case LOPT_UBUS: /* --enable-ubus */<br>
> + set_option_bool(OPT_UBUS);<br>
> + if (arg)<br>
> + daemon->ubus_name = opt_string_alloc(arg);<br>
> + else<br>
> + daemon->ubus_name = DNSMASQ_UBUS_NAME;<br>
> + break;<br>
> +<br>
> case '8': /* --log-facility */<br>
> /* may be a filename */<br>
> if (strchr(arg, '/') || strcmp (arg, "-") == 0)<br>
> diff --git a/src/ubus.c b/src/ubus.c<br>
> index c7f6b19..5f81287 100644<br>
> --- a/src/ubus.c<br>
> +++ b/src/ubus.c<br>
> @@ -38,7 +38,7 @@ static struct ubus_object_type ubus_object_type =<br>
> UBUS_OBJECT_TYPE("dnsmasq", ubus_object_methods);<br>
> <br>
> static struct ubus_object ubus_object = {<br>
> - .name = "dnsmasq",<br>
> + .name = NULL,<br>
> .type = &ubus_object_type,<br>
> .methods = ubus_object_methods,<br>
> .n_methods = ARRAY_SIZE(ubus_object_methods),<br>
> @@ -94,6 +94,7 @@ void ubus_init()<br>
> return;<br>
> }<br>
> <br>
> + <a href="http://ubus_object.name" rel="noreferrer" target="_blank">ubus_object.name</a> = daemon->ubus_name;<br>
> ret = ubus_add_object(ubus, &ubus_object);<br>
> if (ret)<br>
> {<br>
> <br>
<br>
<br>
_______________________________________________<br>
Dnsmasq-discuss mailing list<br>
<a href="mailto:Dnsmasq-discuss@lists.thekelleys.org.uk" target="_blank">Dnsmasq-discuss@lists.thekelleys.org.uk</a><br>
<a href="http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss" rel="noreferrer" target="_blank">http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss</a><br>
</blockquote></div>