[augeas-devel] [Augeas] #47: Use 'domain' field as node name in limits.conf lens
Augeas
trac at fedorahosted.org
Thu Mar 19 09:23:23 UTC 2009
#47: Use 'domain' field as node name in limits.conf lens
------------------------------+---------------------------------------------
Reporter: markdrayton | Owner: lutter
Type: enhancement | Status: new
Priority: minor | Milestone: next
Component: Augeas | Version: 0.4.1
Keywords: limits.conf lens |
------------------------------+---------------------------------------------
limits.conf has 4 whitespace-separated fields:
`domain type item value`
e.g.
`@student - maxlogins 4`
limits users in the student group to a maximum of 4 logins.
Currently the domain field is used as the Augeas node name:
{{{
/files/etc/security/limits.conf/@student
/files/etc/security/limits.conf/@student/type = "-"
/files/etc/security/limits.conf/@student/item = "maxlogins"
/files/etc/security/limits.conf/@student/value = "4"
}}}
But the domain can be *. `print /files/etc/security/limits.conf/*` prints
all nodes, because * matches all of them. dlutter says escaping the * with
a backslash works but I can't persuade that into working:
{{{
[16:09:13] <lutter> raphink: you can escape any character in a path
expression with a backslash, so /foo/bar/\* matches the '*'
}}}
{{{
augtool> print /files/etc/security/limits.conf/\*/
augtool>
}}}
Maybe that doesn't work in my version (0.3.6). I can only see the * entry
by using a * as the node, which of course matches all:
{{{
/files/etc/security/limits.conf/#comment[1] = "foo"
/files/etc/security/limits.conf/#comment[2] = "blah"
/files/etc/security/limits.conf/@student
/files/etc/security/limits.conf/@student/type = "-"
/files/etc/security/limits.conf/@student/item = "maxlogins"
/files/etc/security/limits.conf/@student/value = "4"
/files/etc/security/limits.conf/*
/files/etc/security/limits.conf/*/type = "-"
/files/etc/security/limits.conf/*/item = "nofile"
/files/etc/security/limits.conf/*/value = "16384"
}}}
I can't add a new node:
{{{
augtool> ins * after /files/etc/security/limits.conf/*[last()]
Failed
}}}
raphink on #augeas helped me (thanks!) with a simple patch to set the node
name to domain, which avoids a literal * being in the tree:
{{{
/files/etc/security/limits.conf/#comment[39] = "foo"
/files/etc/security/limits.conf/#comment[40] = "blah"
/files/etc/security/limits.conf/domain[1] = "@student"
/files/etc/security/limits.conf/domain[1]/type = "-"
/files/etc/security/limits.conf/domain[1]/item = "maxlogins"
/files/etc/security/limits.conf/domain[1]/value = "4"
/files/etc/security/limits.conf/domain[2] = "*"
/files/etc/security/limits.conf/domain[2]/type = "-"
/files/etc/security/limits.conf/domain[2]/item = "nofile"
/files/etc/security/limits.conf/domain[2]/value = "16384"
}}}
Now setting:
{{{
augtool> set /files/etc/security/limits.conf/domain[last()] "*"
augtool> set /files/etc/security/limits.conf/domain[last()]/type "soft"
augtool> set /files/etc/security/limits.conf/domain[last()]/item "core"
augtool> set /files/etc/security/limits.conf/domain[last()]/value "0"
augtool> print /files/etc/security/limits.conf/
[..]
/files/etc/security/limits.conf/domain[3] = "*"
/files/etc/security/limits.conf/domain[3]/type = "soft"
/files/etc/security/limits.conf/domain[3]/item = "core"
/files/etc/security/limits.conf/domain[3]/value = "0"
}}}
Patch and new test attached. Diff'ed against 0.3.6 but neither of these
files is different to the ones currently in the Git repo.
--
Ticket URL: <https://fedorahosted.org/augeas/ticket/47>
Augeas <http://augeas.net/>
a configuration API
More information about the augeas-devel
mailing list