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

From: Gary Palmer <gpalmer_at_freebsd.org>
Date: Fri, 14 Sep 2018 14:45:27 +0100
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 \
> \"email_at_host.de: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 \
> "email_at_host.de: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
Received on Fri Sep 14 2018 - 11:45:29 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:18 UTC