ppp.linkup: How is the !bg argument expanded and substituted?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ppp.linkup: How is the !bg argument expanded and substituted?

Hartmann, O.-2
Hello list,

my question may sound blunt but I miss something with the documentation
of ppp(8).

Background: My homeoffice is running a network and server
infrastructure I'd like to access from the internet, therefore, I use a
DDNS service. My gateway is a FreeBSD based small, efficient NanoBSD
based system acting as firewall, router and performing some gatewaying
stuff. Recently the usually used dns/ddclient stopped working on
recent CURRENT running on that gateway (FreeBSD 12.0-ALPHA5 #32
r338541: Sun Sep  9 09:27:47 CEST 2018 amd64, NETINET6 enabled,
secureretylevel=1, all NICs have only IPv6 linklocal, exterior IF is
tun0 with a regular IPv4 assign by my ISP and only linklocal IPv6).
dns/ddclient stopped working out of the blue and I need an alternative
to update my IP (ipv4) at my DDNS provider.

To achiev the requested IPv4 updates as done via ddclient I
used /etc/ppp/ppp.linkup with a !bg command this way:

!bg     /usr/local/bin/curl -v -X PUT -u \
\"[hidden email]:SOME_TOKEN_GIVEN_BY_PROVIDER\" \
-d '{\"ip_address\": \"auto\"}' https://api.twodns.de/hosts/all

It is ONE ROW, I broke it up for presentation here.

Somehow I needed to escape some quotes like \"; I tried to check how
ppp would emmit the !bg command via a logger statement with the very
same line - the reason is I can't see what ppp is doing and since DDNS
updates never were performed so far via ppp.linkup I consider some
mistakes here.

For the JSON data (after -d '{...}'), quoted tags are requisite.

When I issue the command on the gateway without the escaped quotes to
achieve the command line:

/usr/local/bin/curl -v -X PUT -u \
"[hidden email]:SOME_TOKEN_GIVEN_BY_PROVIDER" \
-d '{"ip_address": "auto"}' https://api.twodns.de/hosts/all

everythings works perfect: the IP gets updated, the DDNS provider
respons with status code "200 OK". So far.

But somehow this never happens or is successful with the !bg statement
from ppp.linkup when the IP changes on that link and ppp.linkup is
triggered. Since I do not see why (it seems that the response from
the !bg command is lost), I need to check the substitutions.

Can someone enlighted please shed some illumination on that problem? It
would really help to hint me to the doc were I can read about the way
the command string is parsed/interpreted by ppp (I only found the
substitutions for MYADDR, MYADDR6 and so on in man ppp(8)).

Thanks in advance,

Oliver
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: ppp.linkup: How is the !bg argument expanded and substituted?

Gary Palmer-2
On Fri, Sep 14, 2018 at 01:34:33PM +0200, Hartmann, O. wrote:

> Hello list,
>
> my question may sound blunt but I miss something with the documentation
> of ppp(8).
>
> Background: My homeoffice is running a network and server
> infrastructure I'd like to access from the internet, therefore, I use a
> DDNS service. My gateway is a FreeBSD based small, efficient NanoBSD
> based system acting as firewall, router and performing some gatewaying
> stuff. Recently the usually used dns/ddclient stopped working on
> recent CURRENT running on that gateway (FreeBSD 12.0-ALPHA5 #32
> r338541: Sun Sep  9 09:27:47 CEST 2018 amd64, NETINET6 enabled,
> secureretylevel=1, all NICs have only IPv6 linklocal, exterior IF is
> tun0 with a regular IPv4 assign by my ISP and only linklocal IPv6).
> dns/ddclient stopped working out of the blue and I need an alternative
> to update my IP (ipv4) at my DDNS provider.
>
> To achiev the requested IPv4 updates as done via ddclient I
> used /etc/ppp/ppp.linkup with a !bg command this way:
>
> !bg     /usr/local/bin/curl -v -X PUT -u \
> \"[hidden email]:SOME_TOKEN_GIVEN_BY_PROVIDER\" \
> -d '{\"ip_address\": \"auto\"}' https://api.twodns.de/hosts/all
>
> It is ONE ROW, I broke it up for presentation here.
>
> Somehow I needed to escape some quotes like \"; I tried to check how
> ppp would emmit the !bg command via a logger statement with the very
> same line - the reason is I can't see what ppp is doing and since DDNS
> updates never were performed so far via ppp.linkup I consider some
> mistakes here.
>
> For the JSON data (after -d '{...}'), quoted tags are requisite.
>
> When I issue the command on the gateway without the escaped quotes to
> achieve the command line:
>
> /usr/local/bin/curl -v -X PUT -u \
> "[hidden email]:SOME_TOKEN_GIVEN_BY_PROVIDER" \
> -d '{"ip_address": "auto"}' https://api.twodns.de/hosts/all
>
> everythings works perfect: the IP gets updated, the DDNS provider
> respons with status code "200 OK". So far.
>
> But somehow this never happens or is successful with the !bg statement
> from ppp.linkup when the IP changes on that link and ppp.linkup is
> triggered. Since I do not see why (it seems that the response from
> the !bg command is lost), I need to check the substitutions.
>
> Can someone enlighted please shed some illumination on that problem? It
> would really help to hint me to the doc were I can read about the way
> the command string is parsed/interpreted by ppp (I only found the
> substitutions for MYADDR, MYADDR6 and so on in man ppp(8)).

I'd skip the above and put the CURL command into a small script
which is run from the !bg command

Regards,

Gary
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[hidden email]"