3 Parses systemd tmpfiles.d files
5 Author: Julien Pivotto <roidelapluie@inuits.eu>
8 This lens tries to keep as close as possible to `man 5 tmpfiles.d` where possible.
11 This file is licenced under the LGPL v2+, like the rest of Augeas.
16 About: Configuration files
17 This lens applies to /etc/tmpfiles.d/*.conf /usr/lib/tmpfiles.d/*.conf and
18 /run/tmpfiles.d/*.conf. See <filter>.
21 The <Test_Tmpfiles> file contains various examples and tests.
27 (************************************************************************
28 * Group: USEFUL PRIMITIVES
29 *************************************************************************)
31 (* Group: Comments and empty lines *)
35 let sep_spc = Sep.space
38 Optional space (for the beginning of the lines) *)
39 let sep_opt_spc = Sep.opt_space
43 let comment = Util.comment
47 let empty = Util.empty
49 (* Group: Lense-specific primitives *)
52 One letter. Some of them can have a "+" and all can have an
53 exclamation mark ("!"), a minus sign ("-"), an equal sign ("="),
54 a tilde character ("~") and/or a caret ("^").
56 Not all letters are valid.
58 let type = /([fFwdDevqQpLcbCxXrRzZtThHaAm]|[fFwpLcbaA]\+)[-!=~^]*/
61 "-", or 3-4 bytes. Optionally starts with a "~" or a ":". *)
62 let mode = /(-|(~|:)?[0-7]{3,4})/
65 "-", or one of the formats seen in the manpage: 10d, 5seconds, 1y5days.
66 optionally starts with a "~'. *)
67 let age = /(-|(~?[0-9]+(s|m|min|h|d|w|ms|us|((second|minute|hour|day|week|millisecond|microsecond)s?))?)+)/
70 The last field. It can contain spaces. *)
71 let argument = /([^# \t\n][^#\n]*[^# \t\n]|[^# \t\n])/
74 Applies to the other fields: path, gid and uid fields *)
75 let field = /[^# \t\n]+/
78 A valid record, one line in the file.
79 Only the two first fields are mandatory. *)
80 let record = [ seq "record" . sep_opt_spc .
81 [ label "type" . store type ] . sep_spc .
82 [ label "path" . store field ] . ( sep_spc .
83 [ label "mode" . store mode ] . ( sep_spc .
84 [ label "uid" . store field ] . ( sep_spc .
85 [ label "gid" . store field ] . ( sep_spc .
86 [ label "age" . store age ] . ( sep_spc .
87 [ label "argument" . store argument ] )? )? )? )? )? .
90 (************************************************************************
91 * Group: THE TMPFILES LENSE
92 *************************************************************************)
96 Each line can be a comment, a record or empty. *)
97 let lns = ( empty | comment | record ) *
100 let filter = incl "/etc/tmpfiles.d/*.conf"
101 . incl "/usr/lib/tmpfiles.d/*.conf"
102 . incl "/run/tmpfiles.d/*.conf"
104 let xfm = transform lns filter
106 (* Local Variables: *)