[augeas-devel] escaping special characters in the path sent to aug_get()

Laine Stump laine at redhat.com
Sun Dec 7 02:34:38 UTC 2014


On 12/05/2014 03:38 PM, Raphaël Pinson wrote:
> Hi Laine,
>
> I believe [0] might be of interest to you.
>
>
> Cheers,
>
>
> Raphael
>
> [0] https://github.com/hercules-team/augeas/commit/3fb6543af886bf3de8e21b0b8b8fc30877826e89
>

As far as I understand, this function is showing preprocessing of shell
commandline arguments to remove escaping prior to sending the args to
augeas APIs, *not* any unescaping within the augeas APIs. So we can
determine from it what escaping is understood by augtool, which may or
may not have any relationship to escaping understood by the augeas APIs.


>
> On Fri, Dec 5, 2014 at 7:02 PM, Laine Stump <laine at redhat.com
> <mailto:laine at redhat.com>> wrote:
>
>     I want to sanitize the path sent to aug_get(aug, path, &result) (and
>     probably other functions, and it's not clear to me what characters are
>     considered "special", nor how to escape them in the string. An example
>     of this, let's say I want to know the mac address of a user-supplied
>     network interface, so I do this:
>
>       sprintf(&path, "/files/sys/class/net/%s/address/content", intf)
>
>       r = aug_match(aug, path, &mac);
>
>     If the interface name contains special characters interpreted by
>     aug_match's "xpath-like" parser, then I won't necessarily get back the
>     results I expected.
>
>     So what I would like to do is precede this with a call to
>     "aug_escape(intf, &sanitized_intf)" which would escape any characters
>     having a special meaning to augeas. An API in augeas would be very
>     nice,
>     but since that doesn't exist, can someone point me at some
>     documentation
>     that is easier to understand than the comments in augeas.c? :-o
>
>
>     ========== Side Topic
>
>     One person suggested creating an augeas variable whose value was the
>     contents of intf, then referencing that variable in the path sent to
>     aug_match(); unfortunately, having a path string like this:
>
>         /files/sys/class/net/$interface/address/content
>
>     seems to never work. For that matter, defining a variable that
>     contains
>     the entire path, then calling aug_get(aug, "$interface", &mac) doesn't
>     even do what I want - variable substitution does work when the *entire
>     path string* is "$variableName", but the xpath-like evaluation still
>     takes place, so the special characters are still interpreted and
>     acted on.
>
>
>     _______________________________________________
>     augeas-devel mailing list
>     augeas-devel at redhat.com <mailto:augeas-devel at redhat.com>
>     https://www.redhat.com/mailman/listinfo/augeas-devel
>
>
>
>
> -- 
> Raphaël Pinson
> Infrastructure Developer & Training Leader
> +33 479 26 57 93
> +33 781 90 00 79
>
> Camptocamp France
> Savoie Technolac
> BP 352
> 48, avenue du Lac du Bourget
> 73372 Le Bourget du Lac, Cedex
> www.camptocamp.com <http://www.camptocamp.com>
>
>
> _______________________________________________
> augeas-devel mailing list
> augeas-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/augeas-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20141206/84819a45/attachment.htm>


More information about the augeas-devel mailing list