/usr/share/augeas/lenses/dist/mdadm_conf.aug is in augeas-lenses 1.2.0-0ubuntu1.3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | (******************************************************************************
Mdadm_conf module for Augeas
Author: Matthew Booth <mbooth@redhat.com>
Copyright (C):
2011 Red Hat Inc.
Reference:
mdadm(5)
config.c and policy.c from mdadm-3.2.2
License:
This file is licensed under the LGPL v2+.
This is a lens for /etc/mdadm.conf. It aims to parse every valid configuration
file as of version 3.2.2, and many invalid ones too. This last point is a
feature, not a bug! madm will generate warnings for invalid configuration which
do not prevent correct operation of the tool. Wherever possible, we try to
allow for this behaviour.
Keywords in mdadm.conf are matched with a case-insensitive prefix match of at
least 3 characters. Keys in key/value pairs are also matched case-insensitively,
but require a full match. The exception is POLICY and PART-POLICY, where keys
are matched case-sensitively.
N.B. We can't use case-insensitive regular expressions in most places due to bug
#147.
*******************************************************************************)
module Mdadm_conf =
autoload xfm
(******************************************************************************
* PRIMITIVES
******************************************************************************)
let eol = Util.comment_or_eol
let comment = Util.comment
let empty = Util.empty
let value = /[^ \t\n#]+/
let value_no_eq = /[^ \t\n#=]+/
let value_no_eq_sl = /[^ \t\n#=\/]+/
let continuation = /\n[ \t]+/
let space = /[ \t]+/
let value_sep = ( del ( continuation | space . continuation? ) " "
| comment . del space " " )
(* We parse specific keys rather than having a catch-all owing to the varying
case of the syntax. This means the user can rely on 'array/uuid' rather than
additionally testing for 'array/UUID'.
It would be good to have an additional catchall, but I haven't been able to make
that work.
*)
let keyvalue (r:regexp) (lc:string) (uc:string) =
[ del ( r . /=/ ) ( uc . "=" ) . label lc . store value ]
let simplevalue (r:regexp) (lc:string) (uc:string) =
[ del r uc . label lc
. ( value_sep . [ label "value" . store value ] )* . eol ]
(******************************************************************************
* DEVICES
******************************************************************************)
let dev_re = /dev(i(ce?)?)?/i
let dev_containers_re = /containers/i
let dev_partitions_re = /partitions/i
let dev_containers = [ del dev_containers_re "containers" . label "containers" ]
let dev_partitions = [ del dev_partitions_re "partitions" . label "partitions" ]
let dev_device = [ label "name". store ( value - (dev_containers_re | dev_partitions_re)) ]
(* Strictly there must be at least 1 device, but we err on the side of parsing
*)
let dev_devices = ( value_sep . ( dev_containers
| dev_partitions
| dev_device ) )*
let device = [ del dev_re "DEVICE" . label "device" . dev_devices . eol ]
(******************************************************************************
* ARRAY
******************************************************************************)
let array_re = /arr(ay?)?/i
let arr_auto_re = /auto/i
let arr_bitmap_re = /bitmap/i
let arr_container_re = /container/i
let arr_devices_re = /devices/i
let arr_disks_re = /disks/i (* Undocumented *)
let arr_level_re = /level/i
let arr_member_re = /member/i
let arr_metadata_re = /metadata/i
let arr_name_re = /name/i
let arr_num_devices_re = /num-devices/i
let arr_spare_group_re = /spare-group/i
let arr_spares_re = /spares/i
let arr_super_minor_re = /super-minor/i
let arr_uuid_re = /uuid/i
let arr_devicename = [ store value_no_eq . label "devicename" ]
let arr_auto = keyvalue arr_auto_re "auto" "AUTO"
let arr_bitmap = keyvalue arr_bitmap_re "bitmap" "BITMAP"
let arr_container = keyvalue arr_container_re "container" "CONTAINER"
let arr_devices = keyvalue arr_devices_re "devices" "DEVICES"
let arr_disks = keyvalue arr_disks_re "disks" "DISKS"
let arr_level = keyvalue arr_level_re "level" "LEVEL"
let arr_member = keyvalue arr_member_re "member" "MEMBER"
let arr_metadata = keyvalue arr_metadata_re "metadata" "METADATA"
let arr_name = keyvalue arr_name_re "name" "NAME"
let arr_num_devices = keyvalue arr_num_devices_re "num-devices" "NUM-DEVICES"
let arr_spare_group = keyvalue arr_spare_group_re "spare-group" "SPARE-GROUP"
let arr_spares = keyvalue arr_spares_re "spares" "SPARES"
let arr_super_minor = keyvalue arr_super_minor_re "super-minor" "SUPER-MINOR"
let arr_uuid = keyvalue arr_uuid_re "uuid" "UUID"
let arr_options = ( value_sep . ( arr_devicename
| arr_auto
| arr_bitmap
| arr_container
| arr_devices
| arr_disks
| arr_level
| arr_member
| arr_metadata
| arr_name
| arr_num_devices
| arr_spare_group
| arr_spares
| arr_super_minor
| arr_uuid ) )*
let array = [ del array_re "ARRAY" . label "array" . arr_options . eol ]
(******************************************************************************
* MAILADDR
******************************************************************************)
let mailaddr_re = /mai(l(a(d(dr?)?)?)?)?/i
(* We intentially allow multiple mailaddr values here, even though this is
invalid and would produce a warning. This is better than not parsing the file.
*)
let mailaddr = simplevalue mailaddr_re "mailaddr" "MAILADDR"
(******************************************************************************
* MAILFROM
******************************************************************************)
(* N.B. MAILFROM can only be abbreviated to 5 characters *)
let mailfrom_re = /mailf(r(om?)?)?/i
let mailfrom = [ del mailfrom_re "MAILFROM" . label "mailfrom"
. ( value_sep . [ label "value" . store value ] )* . eol ]
(******************************************************************************
* PROGRAM
******************************************************************************)
let program_re = /pro(g(r(am?)?)?)?/i
let program = simplevalue program_re "program" "PROGRAM"
(******************************************************************************
* CREATE
******************************************************************************)
let create_re = /cre(a(te?)?)?/i
let cre_auto_re = /auto/i
let cre_owner_re = /owner/i
let cre_group_re = /group/i
let cre_mode_re = /mode/i
let cre_metadata_re = /metadata/i
let cre_symlinks_re = /symlinks/i
let cre_auto = keyvalue cre_auto_re "auto" "AUTO"
let cre_group = keyvalue cre_group_re "group" "GROUP"
let cre_metadata = keyvalue cre_metadata_re "metadata" "METADATA"
let cre_mode = keyvalue cre_mode_re "mode" "MODE"
let cre_owner = keyvalue cre_owner_re "owner" "OWNER"
let cre_symlinks = keyvalue cre_symlinks_re "symlinks" "SYMLINKS"
let cre_options = ( value_sep . ( arr_auto
| cre_owner
| cre_group
| cre_mode
| cre_metadata
| cre_symlinks) )*
let create = [ del create_re "CREATE" . label "create" . cre_options . eol ]
(******************************************************************************
* HOMEHOST
******************************************************************************)
let homehost_re = /hom(e(h(o(st?)?)?)?)?/i
let homehost = simplevalue homehost_re "homehost" "HOMEHOST"
(******************************************************************************
* AUTO
******************************************************************************)
let auto_re = /auto?/i
let aut_plus = [ key "+" . store value ]
let aut_minus = [ key "-" . store value ]
let aut_homehost = [ del /homehost/i "homehost" . label "homehost" ]
let aut_list = ( value_sep . ( aut_plus | aut_minus | aut_homehost ) )*
let auto = [ del auto_re "AUTO" . label "auto" . aut_list . eol ]
(******************************************************************************
* POLICY and PART-POLICY
******************************************************************************)
(* PART-POLICY is undocumented. A cursory inspection of the parsing code
suggests it's parsed the same way as POLICY, but treated slightly differently
thereafter. *)
let policy_re = /pol(i(cy?)?)?/i
let part_policy_re = /par(t(-(p(o(l(i(cy?)?)?)?)?)?)?)?/i
(* Unlike everything else, policy keys are matched case sensitive. This means we
don't have to mess around with explicit option matching, as the match string is
fixed for a working configuration. *)
let pol_option (act:string) =
[ del ( act . "=" ) ( act . "=" ) . label act . store value ]
let pol_options = ( value_sep . [ key value_no_eq_sl . del "=" "="
. store value ] )*
let policy = [ del policy_re "POLICY" . label "policy"
. pol_options . eol ]
let part_policy = [ del part_policy_re "PART-POLICY" . label "part-policy"
. pol_options . eol ]
(******************************************************************************
* LENS
******************************************************************************)
let lns = (comment
| empty
| device
| array
| mailaddr
| mailfrom
| program
| create
| homehost
| auto
| policy
| part_policy )*
let filter = incl "/etc/mdadm.conf"
. incl "/etc/mdadm/mdadm.conf"
let xfm = transform lns filter
|