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 | decimal . /[eE]/ . integer
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 = "asymmetry"
83 | /maxdelay((dev)?ratio)?/
94 (* Variable: cmd_flags
95 Server/Peer/Pool options without values
97 let cmd_flags = "auto_offline"|"iburst"|"noselect"|"offline"|"prefer"
98 |"require"|"trust"|"xleave"|"burst"
100 (* Variable: ntp_source
101 Server/Peer/Pool key names
103 let ntp_source = "server"|"peer"|"pool"
105 (* Variable: allowdeny_types
106 Key names for access configuration
108 let allowdeny_types = "allow"|"deny"|"cmdallow"|"cmddeny"
110 (* Variable: hwtimestamp_options
111 HW timestamping options with values
113 let hwtimestamp_options = "minpoll"|"precision"|"rxcomp"|"txcomp"
116 (* Variable: hwtimestamp_flags
117 HW timestamping options without values
119 let hwtimestamp_flags = "nocrossts"
121 (* Variable: local_options
122 local options with values
124 let local_options = "stratum"|"distance"
126 (* Variable: local_flags
127 local options without values
129 let local_flags = "orphan"
131 (* Variable: ratelimit_options
132 Rate limiting options with values
134 let ratelimit_options = "interval"|"burst"|"leak"
136 (* Variable: refclock_options
137 refclock options with values
139 let refclock_options = "refid"|"lock"|"poll"|"dpoll"|"filter"|"rate"
140 |"minsamples"|"maxsamples"|"offset"|"delay"
141 |"precision"|"maxdispersion"|"stratum"|"width"
143 (* Variable: refclock_flags
144 refclock options without values
146 let refclock_flags = "noselect"|"pps"|"prefer"|"require"|"tai"|"trust"
149 Options without values
151 let flags = "dumponexit"
152 | "generatecommandkey"
159 (* Variable: log_flags
160 log has a specific options list
162 let log_flags = "measurements"|"rawmeasurements"|"refclocks"|"rtc"
163 |"statistics"|"tempcomp"|"tracking"
165 (* Variable: simple_keys
166 Options with single values
168 let simple_keys = "acquisitionport" | "bindacqaddress"
169 | "bindaddress" | "bindcmdaddress" | "clientloglimit"
170 | "combinelimit" | "commandkey"
171 | "cmdport" | "corrtimeratio" | "driftfile"
172 | "dumpdir" | "hwclockfile" | "include" | "keyfile"
173 | "leapsecmode" | "leapsectz" | "linux_freq_scale"
174 | "linux_hz" | "logbanner" | "logchange" | "logdir"
175 | "maxclockerror" | "maxdistance" | "maxdrift"
176 | "maxjitter" | "maxsamples" | "maxslewrate"
177 | "maxupdateskew" | "minsamples" | "minsources"
178 | "ntpsigndsocket" | "pidfile"
179 | "port" | "reselectdist" | "rtcautotrim" | "rtcdevice"
180 | "rtcfile" | "sched_priority" | "stratumweight" | "user"
182 (************************************************************************
183 * Group: Make some sub-lenses for use in later lenses
184 ************************************************************************)
185 (* View: host_flags *)
186 let host_flags = [ space . key cmd_flags ]
187 (* View: host_options *)
188 let host_options = [ space . key cmd_options . space . store number ]
189 (* View: log_flag_list *)
190 let log_flag_list = [ space . key log_flags ]
191 (* View: store_address *)
192 let store_address = [ label "address" . store address_re ]
194 (************************************************************************
195 * Group: Lenses for parsing out sections
196 ************************************************************************)
198 options without any arguments
200 let all_flags = [ Util.indent . key flags . eol ]
203 options with only one arg can be directly mapped to key = value
205 let kv = [ Util.indent . key simple_keys . space . (store no_space) . eol ]
207 (* Property: Options with multiple values
209 Each of these gets their own parsing block
210 - server|peer|pool <address> <options>
211 - allow|deny|cmdallow|cmddeny [all] [<address[/subnet]>]
213 - broadcast <interval> <address> <optional port>
214 - fallbackdrift <min> <max>
215 - hwtimestamp <interface> <options>
216 - initstepslew <threshold> <addr> <optional extra addrs>
218 - mailonchange <emailaddress> <threshold>
219 - makestep <threshold> <limit>
220 - maxchange <threshold> <delay> <limit>
221 - ratelimit|cmdratelimit <options>
222 - refclock <driver> <parameter> <options>
223 - smoothtime <maxfreq> <maxwander> <options>
224 - tempcomp <sensorfile> <interval> (<t0> <k0> <k1> <k2> | <pointfile> )
228 Find all NTP sources and their flags/options
230 let host_list = [ Util.indent . key ntp_source
231 . space . store address_re
232 . ( host_flags | host_options )*
236 allow/deny/cmdallow/cmddeny has a specific syntax
238 let allowdeny = [ Util.indent . key allowdeny_types
239 . [ space . key "all" ]?
240 . ( space . store ( no_space - "all" ) )?
244 log has a specific options list
246 let log_list = [ Util.indent . key "log" . log_flag_list+ . eol ]
249 broadcast has specific syntax
251 let bcast = [ Util.indent . key "broadcast"
252 . space . [ label "interval" . store integer ]
253 . space . store_address
254 . ( space . [ label "port" . store integer ] )?
258 fallbackdrift has specific syntax
260 let fdrift = [ Util.indent . key "fallbackdrift"
261 . space . [ label "min" . store integer ]
262 . space . [ label "max" . store integer ]
266 hwtimestamp has specific syntax
268 let hwtimestamp = [ Util.indent . key "hwtimestamp"
269 . space . [ label "interface" . store no_space ]
270 . ( space . ( [ key hwtimestamp_flags ]
271 | [ key hwtimestamp_options . space
276 initstepslew has specific syntax
278 let istepslew = [ Util.indent . key "initstepslew"
279 . space . [ label "threshold" . store number ]
280 . ( space . store_address )+
284 local has specific syntax
286 let local = [ Util.indent . key "local"
287 . ( space . ( [ key local_flags ]
288 | [ key local_options . space . store no_space ] )
293 mailonchange has specific syntax
295 let email = [ Util.indent . key "mailonchange" . space
296 . [ label "emailaddress" . store email_addr ]
298 . [ label "threshold" . store number ]
302 makestep has specific syntax
304 let makestep = [ Util.indent . key "makestep"
306 . [ label "threshold" . store number ]
308 . [ label "limit" . store integer ]
312 maxchange has specific syntax
314 let maxchange = [ Util.indent . key "maxchange"
316 . [ label "threshold" . store number ]
318 . [ label "delay" . store integer ]
320 . [ label "limit" . store integer ]
324 ratelimit/cmdratelimit has specific syntax
326 let ratelimit = [ Util.indent . key /(cmd)?ratelimit/
327 . [ space . key ratelimit_options
328 . space . store no_space ]*
331 refclock has specific syntax
333 let refclock = [ Util.indent . key "refclock"
335 . [ label "driver" . store word ]
337 . [ label "parameter" . store no_space ]
338 . ( space . ( [ key refclock_flags ]
339 | [ key refclock_options . space . store no_space ] )
344 smoothtime has specific syntax
346 let smoothtime = [ Util.indent . key "smoothtime"
348 . [ label "maxfreq" . store number ]
350 . [ label "maxwander" . store number ]
351 . ( space . [ key "leaponly" ] )?
355 tempcomp has specific syntax
357 let tempcomp = [ Util.indent . key "tempcomp"
359 . [ label "sensorfile" . store path ]
361 . [ label "interval" . store number ]
363 . ( [ label "t0" . store number ] . space
364 . [ label "k0" . store number ] . space
365 . [ label "k1" . store number ] . space
366 . [ label "k2" . store number ]
367 | [ label "pointfile" . store path ] )
370 (************************************************************************
371 * Group: Final lense summary
372 ************************************************************************)
374 * All supported chrony settings
376 let settings = host_list | allowdeny | log_list | bcast | fdrift | istepslew
377 | local | email | makestep | maxchange | refclock | smoothtime
378 | hwtimestamp | ratelimit | tempcomp | kv | all_flags
384 let lns = ( empty | comment | settings )*
387 * The files parsed by default
389 let filter = incl "/etc/chrony.conf"
391 let xfm = transform lns filter