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 ************************************************************************)
61 let hex = /[0-9a-fA-F]+/
63 (* Variable: number *)
64 let number = integer | decimal | decimal . /[eE]/ . integer | hex
66 (* Variable: address_re *)
67 let address_re = Rx.ip | Rx.hostname
71 from 4.2.1 of the upstream doc
72 Chrony comments start with: ! ; # or % and must be on their own line
74 let comment = Util.comment_generic /[ \t]*[!;#%][ \t]*/ "# "
77 No spaces or comment characters
79 let no_space = /[^ \t\r\n!;#%]+/
81 (* Variable: cmd_options
82 Server/Peer/Pool options with values
84 let cmd_options = "asymmetry"
89 | /maxdelay((dev)?ratio)?/
100 (* Variable: cmd_flags
101 Server/Peer/Pool options without values
103 let cmd_flags = "auto_offline"|"iburst"|"noselect"|"offline"|"prefer"
104 |"copy"|"require"|"trust"|"xleave"|"burst"|"nts"
106 (* Variable: ntp_source
107 Server/Peer/Pool key names
109 let ntp_source = "server"|"peer"|"pool"
111 (* Variable: allowdeny_types
112 Key names for access configuration
114 let allowdeny_types = "allow"|"deny"|"cmdallow"|"cmddeny"
116 (* Variable: hwtimestamp_options
117 HW timestamping options with values
119 let hwtimestamp_options = "minpoll"|"precision"|"rxcomp"|"txcomp"
120 |"minsamples"|"maxsamples"|"rxfilter"
122 (* Variable: hwtimestamp_flags
123 HW timestamping options without values
125 let hwtimestamp_flags = "nocrossts"
127 (* Variable: local_options
128 local options with values
130 let local_options = "stratum"|"distance"
132 (* Variable: local_flags
133 local options without values
135 let local_flags = "orphan"
137 (* Variable: ratelimit_options
138 Rate limiting options with values
140 let ratelimit_options = "interval"|"burst"|"leak"
142 (* Variable: refclock_options
143 refclock options with values
145 let refclock_options = "refid"|"lock"|"poll"|"dpoll"|"filter"|"rate"
146 |"minsamples"|"maxsamples"|"offset"|"delay"
147 |"precision"|"maxdispersion"|"stratum"|"width"
149 (* Variable: refclock_flags
150 refclock options without values
152 let refclock_flags = "noselect"|"pps"|"prefer"|"require"|"tai"|"trust"
155 Options without values
157 let flags = "dumponexit"
158 | "generatecommandkey"
166 (* Variable: log_flags
167 log has a specific options list
169 let log_flags = "measurements"|"rawmeasurements"|"refclocks"|"rtc"
170 |"statistics"|"tempcomp"|"tracking"
172 (* Variable: simple_keys
173 Options with single values
175 let simple_keys = "acquisitionport" | "authselectmode" | "bindacqaddress"
176 | "bindaddress" | "bindcmdaddress" | "bindacqdevice"
177 | "bindcmddevice" | "binddevice" | "clientloglimit"
178 | "clockprecision" | "combinelimit" | "commandkey"
179 | "cmdport" | "corrtimeratio" | "driftfile"
181 | "dumpdir" | "hwclockfile" | "include" | "keyfile"
182 | "leapsecmode" | "leapsectz" | "linux_freq_scale"
183 | "linux_hz" | "logbanner" | "logchange" | "logdir"
184 | "maxclockerror" | "maxdistance" | "maxdrift"
185 | "maxjitter" | "maxsamples" | "maxslewrate"
186 | "maxntsconnections"
187 | "maxupdateskew" | "minsamples" | "minsources"
188 | "nocerttimecheck" | "ntsdumpdir" | "ntsntpserver"
189 | "ntsport" | "ntsprocesses" | "ntsrefresh" | "ntsrotate"
190 | "ntsservercert" | "ntsserverkey" | "ntstrustedcerts"
191 | "ntpsigndsocket" | "pidfile" | "ptpport"
192 | "port" | "reselectdist" | "rtcautotrim" | "rtcdevice"
193 | "rtcfile" | "sched_priority" | "stratumweight" | "user"
195 (************************************************************************
196 * Group: Make some sub-lenses for use in later lenses
197 ************************************************************************)
198 (* View: host_flags *)
199 let host_flags = [ space . key cmd_flags ]
200 (* View: host_options *)
201 let host_options = [ space . key cmd_options . space . store number ]
202 (* View: log_flag_list *)
203 let log_flag_list = [ space . key log_flags ]
204 (* View: store_address *)
205 let store_address = [ label "address" . store address_re ]
207 (************************************************************************
208 * Group: Lenses for parsing out sections
209 ************************************************************************)
211 options without any arguments
213 let all_flags = [ Util.indent . key flags . eol ]
216 options with only one arg can be directly mapped to key = value
218 let kv = [ Util.indent . key simple_keys . space . (store no_space) . eol ]
220 (* Property: Options with multiple values
222 Each of these gets their own parsing block
223 - server|peer|pool <address> <options>
224 - allow|deny|cmdallow|cmddeny [all] [<address[/subnet]>]
226 - broadcast <interval> <address> <optional port>
227 - fallbackdrift <min> <max>
228 - hwtimestamp <interface> <options>
229 - initstepslew <threshold> <addr> <optional extra addrs>
231 - mailonchange <emailaddress> <threshold>
232 - makestep <threshold> <limit>
233 - maxchange <threshold> <delay> <limit>
234 - ratelimit|cmdratelimit|ntsratelimit <options>
235 - refclock <driver> <parameter> <options>
236 - smoothtime <maxfreq> <maxwander> <options>
237 - tempcomp <sensorfile> <interval> (<t0> <k0> <k1> <k2> | <pointfile> )
238 - confdir|sourcedir <directories>
242 Find all NTP sources and their flags/options
244 let host_list = [ Util.indent . key ntp_source
245 . space . store address_re
246 . ( host_flags | host_options )*
250 allow/deny/cmdallow/cmddeny has a specific syntax
252 let allowdeny = [ Util.indent . key allowdeny_types
253 . [ space . key "all" ]?
254 . ( space . store ( no_space - "all" ) )?
258 log has a specific options list
260 let log_list = [ Util.indent . key "log" . log_flag_list+ . eol ]
263 broadcast has specific syntax
265 let bcast = [ Util.indent . key "broadcast"
266 . space . [ label "interval" . store integer ]
267 . space . store_address
268 . ( space . [ label "port" . store integer ] )?
272 confdir and sourcedir have specific syntax
274 let dir_list = [ Util.indent . key /(conf|source)dir/
275 . [ label "directory" . space . store no_space ]+
279 fallbackdrift has specific syntax
281 let fdrift = [ Util.indent . key "fallbackdrift"
282 . space . [ label "min" . store integer ]
283 . space . [ label "max" . store integer ]
287 hwtimestamp has specific syntax
289 let hwtimestamp = [ Util.indent . key "hwtimestamp"
290 . space . [ label "interface" . store no_space ]
291 . ( space . ( [ key hwtimestamp_flags ]
292 | [ key hwtimestamp_options . space
297 initstepslew has specific syntax
299 let istepslew = [ Util.indent . key "initstepslew"
300 . space . [ label "threshold" . store number ]
301 . ( space . store_address )+
305 local has specific syntax
307 let local = [ Util.indent . key "local"
308 . ( space . ( [ key local_flags ]
309 | [ key local_options . space . store no_space ] )
314 mailonchange has specific syntax
316 let email = [ Util.indent . key "mailonchange" . space
317 . [ label "emailaddress" . store email_addr ]
319 . [ label "threshold" . store number ]
323 makestep has specific syntax
325 let makestep = [ Util.indent . key "makestep"
327 . [ label "threshold" . store number ]
329 . [ label "limit" . store integer ]
333 maxchange has specific syntax
335 let maxchange = [ Util.indent . key "maxchange"
337 . [ label "threshold" . store number ]
339 . [ label "delay" . store integer ]
341 . [ label "limit" . store integer ]
345 ratelimit/cmdratelimit has specific syntax
347 let ratelimit = [ Util.indent . key /(cmd|nts)?ratelimit/
348 . [ space . key ratelimit_options
349 . space . store no_space ]*
352 refclock has specific syntax
354 let refclock = [ Util.indent . key "refclock"
356 . [ label "driver" . store word ]
358 . [ label "parameter" . store no_space ]
359 . ( space . ( [ key refclock_flags ]
360 | [ key refclock_options . space . store no_space ] )
365 smoothtime has specific syntax
367 let smoothtime = [ Util.indent . key "smoothtime"
369 . [ label "maxfreq" . store number ]
371 . [ label "maxwander" . store number ]
372 . ( space . [ key "leaponly" ] )?
376 tempcomp has specific syntax
378 let tempcomp = [ Util.indent . key "tempcomp"
380 . [ label "sensorfile" . store path ]
382 . [ label "interval" . store number ]
384 . ( [ label "t0" . store number ] . space
385 . [ label "k0" . store number ] . space
386 . [ label "k1" . store number ] . space
387 . [ label "k2" . store number ]
388 | [ label "pointfile" . store path ] )
391 (************************************************************************
392 * Group: Final lense summary
393 ************************************************************************)
395 * All supported chrony settings
397 let settings = host_list | allowdeny | log_list | bcast | fdrift | istepslew
398 | local | email | makestep | maxchange | refclock | smoothtime
399 | dir_list | hwtimestamp | ratelimit | tempcomp | kv | all_flags
405 let lns = ( empty | comment | settings )*
408 * The files parsed by default
410 let filter = incl "/etc/chrony.conf"
412 let xfm = transform lns filter