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 = "key"
82 | /maxdelay((dev)?ratio)?/
92 (* Variable: cmd_flags
93 Server/Peer/Pool options without values
95 let cmd_flags = "auto_offline"|"iburst"|"noselect"|"offline"|"prefer"
96 |"require"|"trust"|"xleave"
98 (* Variable: ntp_source
99 Server/Peer/Pool key names
101 let ntp_source = "server"|"peer"|"pool"
103 (* Variable: allowdeny_types
104 Key names for access configuration
106 let allowdeny_types = "allow"|"deny"|"cmdallow"|"cmddeny"
108 (* Variable: hwtimestamp_options
109 HW timestamping options with values
111 let hwtimestamp_options = "minpoll"|"precision"|"rxcomp"|"txcomp"
113 (* Variable: hwtimestamp_flags
114 HW timestamping options without values
116 let hwtimestamp_flags = "nocrossts"
118 (* Variable: local_options
119 local options with values
121 let local_options = "stratum"|"distance"
123 (* Variable: local_flags
124 local options without values
126 let local_flags = "orphan"
128 (* Variable: ratelimit_options
129 Rate limiting options with values
131 let ratelimit_options = "interval"|"burst"|"leak"
133 (* Variable: refclock_options
134 refclock options with values
136 let refclock_options = "refid"|"lock"|"poll"|"dpoll"|"filter"|"rate"
137 |"minsamples"|"maxsamples"|"offset"|"delay"
138 |"precision"|"maxdispersion"
140 (* Variable: refclock_flags
141 refclock options without values
143 let refclock_flags = "noselect"|"prefer"|"require"|"trust"
146 Options without values
148 let flags = "dumponexit"
149 | "generatecommandkey"
156 (* Variable: log_flags
157 log has a specific options list
159 let log_flags = "measurements"|"rawmeasurements"|"refclocks"|"rtc"
160 |"statistics"|"tempcomp"|"tracking"
162 (* Variable: simple_keys
163 Options with single values
165 let simple_keys = "acquisitionport" | "bindacqaddress"
166 | "bindaddress" | "bindcmdaddress" | "clientloglimit"
167 | "combinelimit" | "commandkey"
168 | "cmdport" | "corrtimeratio" | "driftfile"
169 | "dumpdir" | "hwclockfile" | "include" | "keyfile"
170 | "leapsecmode" | "leapsectz" | "linux_freq_scale"
171 | "linux_hz" | "logbanner" | "logchange" | "logdir"
172 | "maxclockerror" | "maxdistance" | "maxdrift"
173 | "maxjitter" | "maxsamples" | "maxslewrate"
174 | "maxupdateskew" | "minsamples" | "minsources"
175 | "ntpsigndsocket" | "pidfile"
176 | "port" | "reselectdist" | "rtcautotrim" | "rtcdevice"
177 | "rtcfile" | "sched_priority" | "stratumweight" | "user"
179 (************************************************************************
180 * Group: Make some sub-lenses for use in later lenses
181 ************************************************************************)
182 (* View: host_flags *)
183 let host_flags = [ space . key cmd_flags ]
184 (* View: host_options *)
185 let host_options = [ space . key cmd_options . space . store number ]
186 (* View: log_flag_list *)
187 let log_flag_list = [ space . key log_flags ]
188 (* View: store_address *)
189 let store_address = [ label "address" . store address_re ]
191 (************************************************************************
192 * Group: Lenses for parsing out sections
193 ************************************************************************)
195 options without any arguments
197 let all_flags = [ Util.indent . key flags . eol ]
200 options with only one arg can be directly mapped to key = value
202 let kv = [ Util.indent . key simple_keys . space . (store no_space) . eol ]
204 (* Property: Options with multiple values
206 Each of these gets their own parsing block
207 - server|peer|pool <address> <options>
208 - allow|deny|cmdallow|cmddeny [all] [<address[/subnet]>]
210 - broadcast <interval> <address> <optional port>
211 - fallbackdrift <min> <max>
212 - hwtimestamp <interface> <options>
213 - initstepslew <threshold> <addr> <optional extra addrs>
215 - mailonchange <emailaddress> <threshold>
216 - makestep <threshold> <limit>
217 - maxchange <threshold> <delay> <limit>
218 - ratelimit|cmdratelimit <options>
219 - refclock <driver> <parameter> <options>
220 - smoothtime <maxfreq> <maxwander> <options>
221 - tempcomp <sensorfile> <interval> (<t0> <k0> <k1> <k2> | <pointfile> )
225 Find all NTP sources and their flags/options
227 let host_list = [ Util.indent . key ntp_source
228 . space . store address_re
229 . ( host_flags | host_options )*
233 allow/deny/cmdallow/cmddeny has a specific syntax
235 let allowdeny = [ Util.indent . key allowdeny_types
236 . [ space . key "all" ]?
237 . ( space . store ( no_space - "all" ) )?
241 log has a specific options list
243 let log_list = [ Util.indent . key "log" . log_flag_list+ . eol ]
246 broadcast has specific syntax
248 let bcast = [ Util.indent . key "broadcast"
249 . space . [ label "interval" . store integer ]
250 . space . store_address
251 . ( space . [ label "port" . store integer ] )?
255 fallbackdrift has specific syntax
257 let fdrift = [ Util.indent . key "fallbackdrift"
258 . space . [ label "min" . store integer ]
259 . space . [ label "max" . store integer ]
263 hwtimestamp has specific syntax
265 let hwtimestamp = [ Util.indent . key "hwtimestamp"
266 . space . [ label "interface" . store no_space ]
267 . ( space . ( [ key hwtimestamp_flags ]
268 | [ key hwtimestamp_options . space . store number ] )
272 initstepslew has specific syntax
274 let istepslew = [ Util.indent . key "initstepslew"
275 . space . [ label "threshold" . store number ]
276 . ( space . store_address )+
280 local has specific syntax
282 let local = [ Util.indent . key "local"
283 . ( space . ( [ key local_flags ]
284 | [ key local_options . space . store no_space ] )
289 mailonchange has specific syntax
291 let email = [ Util.indent . key "mailonchange" . space
292 . [ label "emailaddress" . store email_addr ]
294 . [ label "threshold" . store number ]
298 makestep has specific syntax
300 let makestep = [ Util.indent . key "makestep"
302 . [ label "threshold" . store number ]
304 . [ label "limit" . store integer ]
308 maxchange has specific syntax
310 let maxchange = [ Util.indent . key "maxchange"
312 . [ label "threshold" . store number ]
314 . [ label "delay" . store integer ]
316 . [ label "limit" . store integer ]
320 ratelimit/cmdratelimit has specific syntax
322 let ratelimit = [ Util.indent . key /(cmd)?ratelimit/
323 . [ space . key ratelimit_options
324 . space . store no_space ]*
327 refclock has specific syntax
329 let refclock = [ Util.indent . key "refclock"
331 . [ label "driver" . store word ]
333 . [ label "parameter" . store no_space ]
334 . ( space . ( [ key refclock_flags ]
335 | [ key refclock_options . space . store no_space ] )
340 smoothtime has specific syntax
342 let smoothtime = [ Util.indent . key "smoothtime"
344 . [ label "maxfreq" . store number ]
346 . [ label "maxwander" . store number ]
347 . ( space . [ key "leaponly" ] )?
351 tempcomp has specific syntax
353 let tempcomp = [ Util.indent . key "tempcomp"
355 . [ label "sensorfile" . store path ]
357 . [ label "interval" . store number ]
359 . ( [ label "t0" . store number ] . space
360 . [ label "k0" . store number ] . space
361 . [ label "k1" . store number ] . space
362 . [ label "k2" . store number ]
363 | [ label "pointfile" . store path ] )
366 (************************************************************************
367 * Group: Final lense summary
368 ************************************************************************)
370 * All supported chrony settings
372 let settings = host_list | allowdeny | log_list | bcast | fdrift | istepslew
373 | local | email | makestep | maxchange | refclock | smoothtime
374 | hwtimestamp | ratelimit | tempcomp | kv | all_flags
380 let lns = ( empty | comment | settings )*
383 * The files parsed by default
385 let filter = incl "/etc/chrony.conf"
387 let xfm = transform lns filter