[augeas-devel] Re: [config-model-users] Semantic problem in augeas sshd lens ?

Raphaël Pinson raphink at gmail.com
Fri Aug 1 13:05:32 UTC 2008


On Fri, Aug 1, 2008 at 2:24 PM, Dominique Dumont <dominique.dumont at hp.com>wrote:

> Raphaël Pinson <raphink at gmail.com> writes:
>
> > It is an array as it is from what I understand. If you have several
> Subsystem entries,
> > they will be represented as :
> > /files/etc/ssh/sshd_config/Subsystem[1] = "sftp
> /usr/lib/openssh/sftp-server"
> > /files/etc/ssh/sshd_config/Subsystem[2] = "internal-sftp
> /another/command"
>
> Confirmed. This means that the path structure differs depending on the
> number of elements of the array... :-/
>

Hence the discussion on
https://www.redhat.com/archives/augeas-devel/2008-August/msg00002.html, to
be able to retrieve the exact path of a node after any modification of the
tree.



> And this notation is only valid for "leaf". As "higher" level arrays like
> /etc/host/ use another notation even with only one element in the array:
>
> augtool> print /files/etc/hosts
> /files/etc/hosts
> /files/etc/hosts/1
> /files/etc/hosts/1/ipaddr = "127.0.0.1"
> /files/etc/hosts/1/canonical = "localhost"
> /files/etc/hosts/1/alias = "localhost"



No, this is not another notation. /files/etc/hosts/1 and /files/etc/hosts/2
are not two /etc/hosts files ;) In the first case, Subsystem was declared
using "label" (or most likely "key", which gives the same result), resulting
in the same of the label being used to refer to an array of values. In the
second case, "seq" was used because the file is only made of the same kind
of entries. It could have been made into :

/files/etc/hosts/entry
/files/etc/hosts/entry/ipaddr = "127.0.0.1"
/files/etc/hosts/entry/canonical = "localhost"
/files/etc/hosts/entry/alias = "localhost"

which would then give trees like /files/etc/hosts/entry[1] and
/files/etc/hosts/entry[2] in the case of multiple entries, but since there's
only one kind of entry, it's really useless, hence the use of numbers only
to refer to lines (although I'm not a big fan of "seq", I find it harder to
parse the tree).


> Although I think it could well be split into :
> >
> > { "Subsystem"
> >     { "name" = "sftp" }
> >     { "command" = "/usr/lib/openssh/sftp-server" } }
> > { "Subsystem"
> >     { "name" = "internal-sftp" }
> >     { "command" = "/another/command" } }
> >
> > but that's another problem ;)
>
> Actually, that's how I represent them in Config::Model::OpenSsh. I
> think the end user will be more interested in configuring Subsystem by
> names instead of dealing with "artificial" numbers. This gives a
> structure like:
>
>  Subsystem:sftp=/usr/lib/openssh/sftp-server
>  Subsystem:internal-sftp=/usr/lib/openssh/sftp-server
>
> and you can set them from command line using this subsystem name
> oriented notation:
>
>  $ config-edit -model Sshd  Subsystem:sftp=/usr/lib/openssh/sftp-server \
>   Subsystem:internal-sftp=/usr/lib/openssh/sftp-server



That's not the way augeas would do it though. It would be more like :


sftp_subsystem = augeas.match("/files/etc/ssh/sshd_config/Subsystem/name",
"sftp")
internal_sftp_subsystem =
augeas.match("/files/etc/ssh/sshd_config/Subsystem/name", "internal-sftp")


and then using the returned path to set/rm/mv etc.


But that's also another problem ;-)
>

or another approach ;-)



Raphaël
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20080801/d909548a/attachment.htm>


More information about the augeas-devel mailing list