Ask Your Question
0

How to update /etc/nscd.conf using augeas

asked 2015-11-24 00:17:44 -0500

rgv gravatar image

updated 2015-11-24 11:13:48 -0500

Hi,

I have a requirement to update entry in /etc/nscd.conf, is it possible to do it with augeas? if so how can i update the below entry?

enable-cache hosts no

augeas { '/etc/nscd.conf':
incl    =>  "/etc/nscd.conf",
changes =>  "what should be here???",
notify  =>  Service[ "nscd"],
}

When i use augtool to get the available nodes i dont see etc/nscd.conf so that means augeas doesn't support etc/nscd.conf by default ?

Thanks

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2017-09-22 03:48:35 -0500

Hi,

if this is still relevant, I think this one works (although not completely understood):
module Nscd =
autoload xfm

let commentoreol = Util.commentoreol
let eol = Util.eol
let indent = Util.indent
let empty = Util.empty
let comment = Util.comment
(* let words = /[^# \/\s\t\n]+/*)
let words = /[0-9a-zA-Z-]+/
let vars = /(enable-cache|positive-time-to-live|negative-time-to-live|suggested-size|check-files|persistent|shared|max-db-size|auto-propagate)/
let databases = /(passwd|group|hosts|services|netgroup)/

let simplevar = [ indent . key words . Sep.space . store ( words - databases - vars ) . eol ]
let record = Sep.space .
[ label "vars" . store vars .
[ Sep.space . label "database" . store databases .
[ Sep.space . label "value" . store ( words - databases - vars ) ] ] ].
eol

let lns = ( empty | comment | simplevar | record ) *

let xfm = transform lns (incl "/etc/nscd.conf")

Example:
$ augtool -I . -l /etc/nscd.conf (it is capital i and a lower L)
augtool> ls /files/etc/nscd.conf
#comment[1] = /etc/nscd.conf
#comment[2] = An example Name Service Cache config file. This file is needed by nscd.
...
debug-level = 0
#comment[29] = reload-count 5
...
vars[1]/ = enable-cache
vars[2]/ = positive-time-to-live
vars[3]/ = negative-time-to-live
vars[4]/ = suggested-size
...
augtool> ls /files/etc/nscd.conf/vars[. = "enable-cache"]
database/ = passwd
database/ = group
database/ = hosts
database/ = services
database/ = netgroup
augtool> ls /files/etc/nscd.conf/vars[. = "enable-cache"]/database[. = "hosts"]
value = yes
augtool> get /files/etc/nscd.conf/vars[. = "enable-cache"]/database[. = "hosts"]/value
/files/etc/nscd.conf/vars[. = "enable-cache"]/database[. = "hosts"]/value = yes
augtool> set /files/etc/nscd.conf/vars[. = "enable-cache"]/database[. = "hosts"]/value no
augtool> ls /files/etc/nscd.conf/vars[. = "enable-cache"]/database[. = "hosts"]
value = no

Good luck :-)
Roman

edit flag offensive delete link more
0

answered 2015-11-24 19:43:45 -0500

GregLarkin gravatar image

I don't see any stock Augeas lenses to handle the /etc/nscd.conf format, although it looks pretty simple - comment lines and non-comment lines with 3 space-delimited tokens.

It seems like it should be pretty easy to take the existing inifile.aug base lens and create a custom lens to parse the nscd.conf file. However, "easy" is a relative term. :)

There is some help here (http://augeas.net/docs/writing-schemas.html), but it will still take some doing. I imagine that if you succeed in building a lens for that file, the Augeas team would welcome the contribution back to the product.

edit flag offensive delete link more

Comments

Thank you Greg!! i will try

rgv gravatar imagergv ( 2015-11-25 13:17:00 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-11-24 00:17:44 -0500

Seen: 150 times

Last updated: Nov 24 '15