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
70 let uuid = /UUID=[0-9a-f-]+/
72 (************************************************************************
74 *************************************************************************)
76 (************************************************************************
77 * View: comma_sep_list
78 * A comma separated list of options (opt=value or opt)
79 *************************************************************************)
80 let comma_sep_list (l:string) =
81 let value = [ label "value" . Util.del_str "=" . store optval ] in
82 let lns = [ label l . store word . value? ] in
83 Build.opt_list lns comma
85 (************************************************************************
88 *************************************************************************)
90 let record = [ seq "entry" .
91 [ label "target" . store target ] . sep_tab .
92 [ label "device" . store (fspath|uuid) ] .
93 (sep_tab . [ label "password" . store fspath ] .
94 ( sep_tab . comma_sep_list "opt")? )?
101 let lns = ( empty | comment | record ) *
103 (* Variable: filter *)
104 let filter = (incl "/etc/crypttab")
106 let xfm = transform lns filter