3 Parses the chrony config file
5 Author: Pat Riehecky <riehecky@fnal.gov>
8 This lens tries to keep as close as possible to chrony config syntax
10 See http://chrony.tuxfamily.org/manual.html#Configuration-file
13 This file is licenced under the LGPL v2+, like the rest of Augeas.
18 About: Configuration files
19 This lens applies to /etc/chrony.conf
27 (************************************************************************
28 * Group: Import provided expressions
29 ************************************************************************)
31 let empty = Util.empty
39 (* Variable: email_addr *)
40 let email_addr = Rx.email_addr
45 (* Variable: integer *)
46 let integer = Rx.relinteger
48 (* Variable: decimal *)
49 let decimal = Rx.reldecimal
57 (************************************************************************
58 * Group: Create required expressions
59 ************************************************************************)
60 (* Variable: number *)
61 let number = integer | decimal
63 (* Variable: address_re *)
64 let address_re = Rx.ip | Rx.hostname
68 from 4.2.1 of the upstream doc
69 Chrony comments start with: ! ; # or % and must be on their own line
71 let comment = Util.comment_generic /[ \t]*[!;#%][ \t]*/ "# "
74 No spaces or comment characters
76 let no_space = /[^ \t\r\n!;#%]+/
78 (* Variable: cmd_options
79 Server/Peer/Pool options with values
81 let cmd_options = "key"
82 | /maxdelay((dev)?ratio)?/
91 (* Variable: cmd_flags
92 Server/Peer/Pool options without values
94 let cmd_flags = "auto_offline"|"iburst"|"noselect"|"offline"|"prefer"
97 (* Variable: ntp_source
98 Server/Peer/Pool key names
100 let ntp_source = "server"|"peer"|"pool"
102 (* Variable: allowdeny_types
103 Key names for access configuration
105 let allowdeny_types = "allow"|"deny"|"cmdallow"|"cmddeny"
107 (* Variable: local_options
108 local options with values
110 let local_options = "stratum"|"distance"
112 (* Variable: local_flags
113 local options without values
115 let local_flags = "orphan"
117 (* Variable: ratelimit_options
118 Rate limiting options with values
120 let ratelimit_options = "interval"|"burst"|"leak"
122 (* Variable: refclock_options
123 refclock options with values
125 let refclock_options = "refid"|"lock"|"poll"|"dpoll"|"filter"|"rate"
126 |"minsamples"|"maxsamples"|"offset"|"delay"
127 |"precision"|"maxdispersion"
129 (* Variable: refclock_flags
130 refclock options without values
132 let refclock_flags = "noselect"|"prefer"|"require"|"trust"
135 Options without values
137 let flags = "dumponexit"
138 | "generatecommandkey"
145 (* Variable: log_flags
146 log has a specific options list
148 let log_flags = /measurements|statistics|tracking|rtc|refclocks|tempcomp/
150 (* Variable: simple_keys
151 Options with single values
153 let simple_keys = "acquisitionport" | "bindacqaddress"
154 | "bindaddress" | "bindcmdaddress" | "clientloglimit"
155 | "combinelimit" | "commandkey"
156 | "cmdport" | "corrtimeratio" | "driftfile"
157 | "dumpdir" | "hwclockfile" | "include" | "keyfile"
158 | "leapsecmode" | "leapsectz" | "linux_freq_scale"
159 | "linux_hz" | "logbanner" | "logchange" | "logdir"
160 | "maxdistance" | "maxdrift"
161 | "maxclockerror" | "maxsamples" | "maxslewrate"
162 | "maxupdateskew" | "minsamples" | "minsources" | "pidfile"
163 | "port" | "reselectdist" | "rtcautotrim" | "rtcdevice"
164 | "rtcfile" | "sched_priority" | "stratumweight" | "user"
166 (************************************************************************
167 * Group: Make some sub-lenses for use in later lenses
168 ************************************************************************)
169 (* View: host_flags *)
170 let host_flags = [ space . key cmd_flags ]
171 (* View: host_options *)
172 let host_options = [ space . key cmd_options . space . store integer ]
173 (* View: log_flag_list *)
174 let log_flag_list = [ space . key log_flags ]
175 (* View: store_address *)
176 let store_address = [ label "address" . store address_re ]
178 (************************************************************************
179 * Group: Lenses for parsing out sections
180 ************************************************************************)
182 options without any arguments
184 let all_flags = [ Util.indent . key flags . eol ]
187 options with only one arg can be directly mapped to key = value
189 let kv = [ Util.indent . key simple_keys . space . (store no_space) . eol ]
191 (* Property: Options with multiple values
193 Each of these gets their own parsing block
194 - server|peer|pool <address> <options>
195 - allow|deny|cmdallow|cmddeny [all] [<address[/subnet]>]
197 - broadcast <interval> <address> <optional port>
198 - fallbackdrift <min> <max>
199 - initstepslew <threshold> <addr> <optional extra addrs>
201 - mailonchange <emailaddress> <threshold>
202 - makestep <threshold> <limit>
203 - maxchange <threshold> <delay> <limit>
204 - ratelimit|cmdratelimit <options>
205 - refclock <driver> <parameter> <options>
206 - smoothtime <maxfreq> <maxwander> <options>
207 - tempcomp <sensorfile> <interval> (<t0> <k0> <k1> <k2> | <pointfile> )
211 Find all NTP sources and their flags/options
213 let host_list = [ Util.indent . key ntp_source
214 . space . store address_re
215 . ( host_flags | host_options )*
219 allow/deny/cmdallow/cmddeny has a specific syntax
221 let allowdeny = [ Util.indent . key allowdeny_types
222 . [ space . key "all" ]?
223 . ( space . store ( no_space - "all" ) )?
227 log has a specific options list
229 let log_list = [ Util.indent . key "log" . log_flag_list+ . eol ]
232 broadcast has specific syntax
234 let bcast = [ Util.indent . key "broadcast"
235 . space . [ label "interval" . store integer ]
236 . space . store_address
237 . ( space . [ label "port" . store integer ] )?
241 fallbackdrift has specific syntax
243 let fdrift = [ Util.indent . key "fallbackdrift"
244 . space . [ label "min" . store integer ]
245 . space . [ label "max" . store integer ]
249 initstepslew has specific syntax
251 let istepslew = [ Util.indent . key "initstepslew"
252 . space . [ label "threshold" . store number ]
253 . ( space . store_address )+
257 local has specific syntax
259 let local = [ Util.indent . key "local"
260 . ( space . ( [ key local_flags ]
261 | [ key local_options . space . store no_space ] )
266 mailonchange has specific syntax
268 let email = [ Util.indent . key "mailonchange" . space
269 . [ label "emailaddress" . store email_addr ]
271 . [ label "threshold" . store number ]
275 makestep has specific syntax
277 let makestep = [ Util.indent . key "makestep"
279 . [ label "threshold" . store number ]
281 . [ label "limit" . store integer ]
285 maxchange has specific syntax
287 let maxchange = [ Util.indent . key "maxchange"
289 . [ label "threshold" . store number ]
291 . [ label "delay" . store integer ]
293 . [ label "limit" . store integer ]
297 ratelimit/cmdratelimit has specific syntax
299 let ratelimit = [ Util.indent . key /(cmd)?ratelimit/
300 . [ space . key ratelimit_options
301 . space . store no_space ]*
304 refclock has specific syntax
306 let refclock = [ Util.indent . key "refclock"
308 . [ label "driver" . store word ]
310 . [ label "parameter" . store no_space ]
311 . ( space . ( [ key refclock_flags ]
312 | [ key refclock_options . space . store no_space ] )
317 smoothtime has specific syntax
319 let smoothtime = [ Util.indent . key "smoothtime"
321 . [ label "maxfreq" . store number ]
323 . [ label "maxwander" . store number ]
324 . ( space . [ key "leaponly" ] )?
328 tempcomp has specific syntax
330 let tempcomp = [ Util.indent . key "tempcomp"
332 . [ label "sensorfile" . store path ]
334 . [ label "interval" . store number ]
336 . ( [ label "t0" . store number ] . space
337 . [ label "k0" . store number ] . space
338 . [ label "k1" . store number ] . space
339 . [ label "k2" . store number ]
340 | [ label "pointfile" . store path ] )
343 (************************************************************************
344 * Group: Final lense summary
345 ************************************************************************)
347 * All supported chrony settings
349 let settings = host_list | allowdeny | log_list | bcast | fdrift | istepslew
350 | local | email | makestep | maxchange | refclock | smoothtime
351 | ratelimit | tempcomp | kv | all_flags
357 let lns = ( empty | comment | settings )*
360 * The files parsed by default
362 let filter = incl "/etc/chrony.conf"
364 let xfm = transform lns filter