3 Parses /etc/crypttab from the cryptsetup package.
5 Author: Frédéric Lespez <frederic.lespez@free.fr>
8 This lens tries to keep as close as possible to `man crypttab` where possible.
11 This file is licensed under the LGPL v2+, like the rest of Augeas.
14 Sample usage of this lens in augtool
16 * Create a new entry for an encrypted block devices
17 > ins 01 after /files/etc/crypttab/*[last()]
18 > set /files/etc/crypttab/01/target crypt_sda2
19 > set /files/etc/crypttab/01/device /dev/sda2
20 > set /files/etc/crypttab/01/password /dev/random
21 > set /files/etc/crypttab/01/opt swap
22 * Print the entry applying to the "/dev/sda2" device
23 > print /files/etc/crypttab/01
24 * Remove the entry applying to the "/dev/sda2" device
25 > rm /files/etc/crypttab/*[device="/dev/sda2"]
27 About: Configuration files
28 This lens applies to /etc/crypttab. See <filter>.
34 (************************************************************************
35 * Group: USEFUL PRIMITIVES
36 *************************************************************************)
38 (* Group: Separators *)
40 (* Variable: sep_tab *)
46 (* Group: Generic primitives *)
51 (* Variable: comment *)
52 let comment = Util.comment
55 let empty = Util.empty
60 (* Variable: optval *)
61 let optval = /[A-Za-z0-9_.:-]+/
63 (* Variable: target *)
64 let target = Rx.device_name
66 (* Variable: fspath *)
67 let fspath = Rx.fspath
69 (************************************************************************
71 *************************************************************************)
73 (************************************************************************
74 * View: comma_sep_list
75 * A comma separated list of options (opt=value or opt)
76 *************************************************************************)
77 let comma_sep_list (l:string) =
78 let value = [ label "value" . Util.del_str "=" . store optval ] in
79 let lns = [ label l . store word . value? ] in
80 Build.opt_list lns comma
82 (************************************************************************
85 *************************************************************************)
87 let record = [ seq "entry" .
88 [ label "target" . store target ] . sep_tab .
89 [ label "device" . store fspath ] .
90 (sep_tab . [ label "password" . store fspath ] .
91 ( sep_tab . comma_sep_list "opt")? )?
98 let lns = ( empty | comment | record ) *
100 (* Variable: filter *)
101 let filter = (incl "/etc/crypttab")
103 let xfm = transform lns filter