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 a "!".
54 Not all letters are valid.
56 let type = /([fFwdDvpLcbCxXrRzZtThHaAm]|[AabcLp]\+)!?/
59 "-", or 4 bytes. Optionally starts with a "~". *)
60 let mode = /(-|~?[0-7]{4})/
63 "-", or one of the formats seen in the manpage: 10d, 5seconds, 1y5days.
64 optionally starts with a "~'. *)
65 let age = /(-|(~?[0-9]+(s|m|min|h|d|w|ms|us|((second|minute|hour|day|week|millisecond|microsecond)s?))?)+)/
68 The last field. It can contain spaces. *)
69 let argument = /([^# \t\n][^#\n]+)?[^# \t\n]/
72 Applies to the other fields: path, gid and uid fields *)
73 let field = /[^# \t\n]+/
76 A valid record, one line in the file.
77 Only the two first fields are mandatory. *)
78 let record = [ seq "record" . sep_opt_spc .
79 [ label "type" . store type ] . sep_spc .
80 [ label "path" . store field ] . ( sep_spc .
81 [ label "mode" . store mode ] . ( sep_spc .
82 [ label "uid" . store field ] . ( sep_spc .
83 [ label "gid" . store field ] . ( sep_spc .
84 [ label "age" . store age ] . ( sep_spc .
85 [ label "argument" . store argument ] )? )? )? )? )? .
88 (************************************************************************
89 * Group: THE TMPFILES LENSE
90 *************************************************************************)
94 Each line can be a comment, a record or empty. *)
95 let lns = ( empty | comment | record ) *
98 let filter = incl "/etc/tmpfiles.d/*.conf"
99 . incl "/usr/lib/tmpfiles.d/*.conf"
100 . incl "/run/tmpfiles.d/*.conf"
102 let xfm = transform lns filter
104 (* Local Variables: *)