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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
|
.. -*- mode: rst -*-
.. _server-plugins-generators-rules:
=====
Rules
=====
The Rules plugin resolves the following Abstract Configuration Entities:
* Service
* Package
* Path
* Action
to literal configuration entries suitable for the client drivers to
consume.
For an entity specification to be included in the Literal configuration
the name attribute from an Abstract Entity Tag (from Base or Bundler)
must match the name attribute of an Entity tag in Rules, along with the
appropriate group associations of course.
Each file in the Rules directory has a priority. This allows the same
Entities to be served by multiple files. The priorities can be used to
break ties in the case that multiple files serve data for the same Entity.
Usage of Groups in Rules
========================
Groups are used by the Rules plugin, along with host metadata, for
selecting the Configuration Entity entries to include in the clients
literal configuration. They can be thought of as::
if client is a member of group1 then
assign to literal config
Nested groups are conjunctive (logical and).::
if client is a member of group1 and group2 then
assign to literal config
Group membership may be negated.
Tag Attributes in Rules
=======================
Running ``bcfg2-lint`` will check your configuration specification for
the presence of any mandatory attributes that are necessary for the
entry specified.
Rules Tag
---------
The Rules Tag may have the following attributes:
+----------+-------------------------------------+--------+
| Name | Description | Values |
+==========+=====================================+========+
| priority | Sets the priority for Rules in this | String |
| | Rules list.The higher value wins. | |
+----------+-------------------------------------+--------+
Rules Group Tag
---------------
The Rules Group Tag may have the following attributes:
+--------+-------------------------+--------------+
| Name | Description | Values |
+========+=========================+==============+
| name | Group Name | String |
+--------+-------------------------+--------------+
| negate | Negate group membership | (true|false) |
| | (is not a member of) | |
+--------+-------------------------+--------------+
Package Tag
-----------
The Package Tag may have the following attributes:
+------------+----------------------------------------------+----------+
| Name | Description | Values |
+============+==============================================+==========+
| name | Package name or regular expression | String |
| | | or regex |
+------------+----------------------------------------------+----------+
| version | Package Version or version='noverify' to | String |
| | not do version checking in the Yum driver | |
| | only (temporary work a round). | |
+------------+----------------------------------------------+----------+
| file | Package file name. Several other attributes | String |
| | (name, version) can be automatically defined | |
| | based on regular expressions defined in the | |
| | Pkgmgr plugin. | |
+------------+----------------------------------------------+----------+
| simplefile | Package file name. No name parsing is | String |
| | performed, so no extra fields get set | |
+------------+----------------------------------------------+----------+
| verify | verify='false' - do not do package | String |
| | verification | |
+------------+----------------------------------------------+----------+
| multiarch | Comma separated list of the architectures of | String |
| | this package that should be installed. | |
+------------+----------------------------------------------+----------+
| srcs | Filename creation rules for multiarch | String |
| | packages. | |
+------------+----------------------------------------------+----------+
| type | Package type. (rpm, yum, apt,sysv,blast) | String |
+------------+----------------------------------------------+----------+
Action Tag
----------
See :ref:`client-tools-actions`
Service Tag
-----------
+------------+-------------------------------+---------------------------------------------------------+
| Name | Description | Values |
+============+===============================+=========================================================+
| restart | Whether to restart the | ( true | false | interactive ) |
| | service when the bundle | |
| | changes (new in 1.3; replaces | |
| | "mode" attribute) | |
+------------+-------------------------------+---------------------------------------------------------+
| install | Whether to install the | ( true | false ) |
| | service (new in 1.3; replaces | |
| | "mode" attribute) | |
+------------+-------------------------------+---------------------------------------------------------+
| name | Service name or regular | String or regex |
| | expression | |
+------------+-------------------------------+---------------------------------------------------------+
| status | Should the service be on or | (on | off | ignore) |
| | off (default: off). | |
+------------+-------------------------------+---------------------------------------------------------+
| target | Service command for restart | String |
| | (default: restart) | |
+------------+-------------------------------+---------------------------------------------------------+
| type | Driver to use on the client | (chkconfig | deb | rc-update | smf | upstart | |
| | to manage this service. | systemd | freebsd | launchd ) |
+------------+-------------------------------+---------------------------------------------------------+
| sequence | Order for service startup | integer |
| | (debian services only) | |
+------------+-------------------------------+---------------------------------------------------------+
| parameters | Pass parameters to service | String |
| | (Upstart services only) | |
+------------+-------------------------------+---------------------------------------------------------+
Service mode specification
^^^^^^^^^^^^^^^^^^^^^^^^^^
.. versionadded:: 1.3.0
In the 1.3.0 release, the "mode" attribute has been replaced by a pair
of attributes, "restart" and "install," which control how a service is
handled more granularly than the old "mode" attribute. The old "mode"
attribute values are equivalent as follows:
+-----------------------------+------------------------------------------+
| Mode attribute | Equivalent |
+=============================+==========================================+
| ``mode="default"`` | ``restart="true" install="true"`` |
+-----------------------------+------------------------------------------+
| ``mode="interactive_only"`` | ``restart="interactive" install="true"`` |
+-----------------------------+------------------------------------------+
| ``mode="supervised"`` | ``restart="true" install="true"`` |
+-----------------------------+------------------------------------------+
| ``mode="manual"`` | ``restart="false" install="false"`` |
+-----------------------------+------------------------------------------+
The default is ``restart="true" install="true"``
Previously, "supervised" could be used to start a service during the
verification phase; this is no longer supported. Services that have
been stopped on a client will be started during the install phase.
Service status descriptions
^^^^^^^^^^^^^^^^^^^^^^^^^^^
* on
* start the service at boot time
* off
* don't start the service at boot time
* ignore
* Don't perform service status checks.
Client Tag
----------
The Client Tag is used in Rules for selecting the package entries to
include in the clients literal configuration. Its function is similar
to the Group tag in this context. It can be thought of as::
if client is name then
assign to literal config
The Client Tag may have the following attributes:
+--------+-------------------------+--------------+
| Name | Description | Values |
+========+=========================+==============+
| name | Client Name | String |
+--------+-------------------------+--------------+
| negate | Negate client selection | (true|false) |
| | (if not client name) | |
+--------+-------------------------+--------------+
Path Tag
--------
The Path tag has different values depending on the *type* attribute of
the path specified in your configuration. Below is a set of tables which
describe the attributes available for various Path types.
Note that ``secontext`` below expects a full context, not just the
type. For instance, "``system_u:object_r:etc_t:s0``", not just
``etc_t``. You can also specify "``__default__``", which will restore
the context of the file to the default set by policy. See
:ref:`server-selinux` for more information.
Attributes common to all Path tags:
+----------+---------------------------------------------------+-----------------+
| Name | Description | Values |
+==========+===================================================+=================+
| name | Full path or regular expression matching the path | String or regex |
+----------+---------------------------------------------------+-----------------+
device
^^^^^^
+-----------+---------------------+-------------------+
| Name | Description | Values |
+===========+=====================+===================+
| dev_type | Type of device | (block|char|fifo) |
+-----------+---------------------+-------------------+
| owner | Device owner | String |
+-----------+---------------------+-------------------+
| group | Device group | String |
+-----------+---------------------+-------------------+
| mode | Mode for the device | String |
+-----------+---------------------+-------------------+
| secontext | SELinux context | String |
+-----------+---------------------+-------------------+
| major | Major number (block | integer |
| | or char devices) | |
+-----------+---------------------+-------------------+
| minor | Minor number (block | integer |
| | or char devices) | |
+-----------+---------------------+-------------------+
directory
^^^^^^^^^
+-----------+------------------------------+------------+
| Name | Description | Values |
+===========+==============================+============+
| mode | File mode of the directory | String |
+-----------+------------------------------+------------+
| owner | Owner of the directory | String |
+-----------+------------------------------+------------+
| group | Group Owner of the directory | String |
+-----------+------------------------------+------------+
| secontext | SELinux context | String |
+-----------+------------------------------+------------+
| prune | prune unspecified entries | true|false |
| | from the Directory | |
+-----------+------------------------------+------------+
hardlink
^^^^^^^^
+-----------+------------------------------+--------+
| Name | Description | Values |
+===========+==============================+========+
| to | File to link to | String |
+-----------+------------------------------+--------+
| owner | Owner of the directory | String |
+-----------+------------------------------+--------+
| group | Group Owner of the directory | String |
+-----------+------------------------------+--------+
| secontext | SELinux context | String |
+-----------+------------------------------+--------+
nonexistent
^^^^^^^^^^^
+-----------+--------------------+-------------+
| Name | Description | Values |
+===========+====================+=============+
| type | Type of file | nonexistent |
+-----------+--------------------+-------------+
| recursive | Recursively remove | true |
| | directory contents | |
+-----------+--------------------+-------------+
permissions
^^^^^^^^^^^
+-----------+--------------------------+--------+
| Name | Description | Values |
+===========+==========================+========+
| mode | Mode of the file. | String |
+-----------+--------------------------+--------+
| owner | Owner of the file. | String |
+-----------+--------------------------+--------+
| group | Group of the file. | String |
+-----------+--------------------------+--------+
| secontext | SELinux context | String |
+-----------+--------------------------+--------+
symlink
^^^^^^^
+------+----------------------+--------+
| Name | Description | Values |
+======+======================+========+
| to | File to link to | String |
+------+----------------------+--------+
.. _server-plugins-generators-rules-acls:
ACLs
^^^^
.. versionadded:: 1.3.0
ACLs on a Path entry are specified not by attributes on the tag but by
child ``<ACL>`` tags. For instance:
.. code-block:: xml
<Path name="/etc/foo" type="directory" owner="root" group="root"
mode="0775">
<ACL type="default" scope="user" user="foouser" perms="rw"/>
<ACL type="default" scope="group" group="users" perms="rx"/>
</Path>
The ACL tag has the following attributes:
+-------+---------------------------------------------------+----------------+
| Name | Description | Values |
+=======+===================================================+================+
| type | ACL type | default|access |
+-------+---------------------------------------------------+----------------+
| scope | ACL scope | user|group |
+-------+---------------------------------------------------+----------------+
| user | User the ACL applies to ``(with scope="user"``) | String |
+-------+---------------------------------------------------+----------------+
| group | Group the ACL applies to ``(with scope="group"``) | String |
+-------+---------------------------------------------------+----------------+
| perms | Permissions for the ACL | See below |
+-------+---------------------------------------------------+----------------+
The ``perms`` attribute can either be a single octal digit (e.g.,
``6`` would indicate read and write, but not execute), or a symbolic
mode including 'r', 'w', and 'x'. You can include '-' for operations
that are not permitted, but it's not required. I.e., all of the
following are identical::
perms="5"
perms="rx"
perms="r-x"
It is not currently possible to manually set an effective rights mask;
the mask will be automatically calculated from the given ACLs when
they are applied.
Note that it is possible to set ACLs that demand different permissions
on a file than those specified in the ``perms`` attribute on the
``Path`` tag. For instance:
.. code-block:: xml
<Path name="/etc/foo" mode="0644" group="root" owner="root">
<ACL type="access" scope="user" user="foouser" perms="rwx"/>
</Path>
In this case, we've specified permissions of ``0644``, but the
effective rights mask will be "rwx," so setting the ACL will change
the permissions to ``0674``. When this happens, Bcfg2 will change the
permissions and set the ACLs on every run and the entry will be
eternally marked as bad.
SELinux Tag
-----------
The SELinux tag has different values depending on the *type* attribute
of the SELinux entry specified in your configuration. Below is a set
of tables which describe the attributes available for various SELinux
types. The types (except for ``module``) correspond to ``semanage``
subcommands.
Note that the ``selinuxtype`` attribute takes only an SELinux type,
not a full context; e.g., "``etc_t``", not
"``system_u:object_r:etc_t:s0``".
As it can be very tedious to create a baseline of all existing SELinux
entries, you can use ``selinux_baseline.py`` located in the ``tools/``
directory to do that for you.
In certain cases, it may be necessary to create multiple SELinux
entries with the same name. For instance, "root" is both an SELinux
user and an SELinux login record; or a given fcontext may need two
different SELinux types depending on whether it's a symlink or a plain
file. In these (few) cases, it is necessary to create BoundSELinux
entries directly in Bundler rather than using abstract SELinux entries
in Bundler and binding them with Rules.
See :ref:`server-selinux` for more information.
boolean
^^^^^^^
+-------+----------------------+---------+----------+
| Name | Description | Values | Required |
+=======+======================+=========+==========+
| name | Name of the boolean | String | Yes |
+-------+----------------------+---------+----------+
| value | Value of the boolean | on|off | Yes |
+-------+----------------------+---------+----------+
port
^^^^
+-------------+------------------------+---------------------------+----------+
| Name | Description | Values | Required |
+=============+========================+===========================+==========+
| name | Port number or range | ``<port>/<proto>`` or | Yes |
| | and protocol (tcp|udp) | ``<start>-<end>/<proto>`` | |
+-------------+------------------------+---------------------------+----------+
| selinuxtype | SELinux type to apply | String | Yes |
| | to this port | | |
+-------------+------------------------+---------------------------+----------+
fcontext
^^^^^^^^
+-------------+-------------------------+---------------------+----------+
| Name | Description | Values | Required |
+=============+=========================+=====================+==========+
| name | File specification | String | Yes |
+-------------+-------------------------+---------------------+----------+
| selinuxtype | SELinux type to apply | String | Yes |
| | to files matching this | | |
| | specification | | |
+-------------+-------------------------+---------------------+----------+
| filetype | File type to match. | (regular|directory| | No |
| | Default: all | symlink|pipe|all| | |
| | | socket|block|char) | |
+-------------+-------------------------+---------------------+----------+
node
^^^^
+-------------+------------------------------------+------------------+----------+
| Name | Description | Values | Required |
+=============+====================================+==================+==========+
| name | IP address and netmask of node. | <addr>/<netmask> | Yes |
| | Netmask can be numeric (/16) or | | |
| | dotted-quad (/255.255.0.0) | | |
+-------------+------------------------------------+------------------+----------+
| selinuxtype | SELinux type to apply to this node | String | Yes |
+-------------+------------------------------------+------------------+----------+
| proto | Protocol | (ipv4|ipv6) | Yes |
+-------------+------------------------------------+------------------+----------+
login
^^^^^
+-------------+-------------------------------+-----------+----------+
| Name | Description | Values | Required |
+=============+===============================+===========+==========+
| name | Unix username | String | Yes |
+-------------+-------------------------------+-----------+----------+
| selinuxuser | SELinux username | String | Yes |
+-------------+-------------------------------+-----------+----------+
user
^^^^
+-------------+-------------------------------+-----------+----------+
| Name | Description | Values | Required |
+=============+===============================+===========+==========+
| name | SELinux username | String | Yes |
+-------------+-------------------------------+-----------+----------+
| roles | Space-separated list of roles | String | No |
+-------------+-------------------------------+-----------+----------+
| prefix | Home directory context prefix | String | No |
+-------------+-------------------------------+-----------+----------+
interface
^^^^^^^^^
+-------------+-------------------------+-------------+----------+
| Name | Description | Values | Required |
+=============+=========================+=============+==========+
| name | Interface name | String | Yes |
+-------------+-------------------------+-------------+----------+
| selinuxtype | SELinux type to apply | String | Yes |
| | to this interface | | |
+-------------+-------------------------+-------------+----------+
permissive
^^^^^^^^^^
+-------------+------------------------------------+-------------+----------+
| Name | Description | Values | Required |
+=============+====================================+=============+==========+
| name | SELinux type to make permissive | String | Yes |
+-------------+------------------------------------+-------------+----------+
module
^^^^^^
See :ref:`server-plugins-generators-semodules`
Rules Directory
===============
The Rules/ directory keeps the XML files that define what rules are
available for a host. All the files in the directory are processed.
The names of the XML files have no special meaning to Bcfg2; they
are simply named so it's easy for the administrator to know what the
contents hold. All Rules could be kept in a single file if so desired.
Bcfg2 simply uses the Groups in the files and priorities to determine
how to assign Rules to a host's literal configuration.
.. code-block:: xml
<Rules priority="0">
<Path type='directory' group="root" name="/autonfs" owner="root" mode="0755"/>
<Path type='directory' group="utmp" name="/var/run/screen" owner="root" mode="0775"/>
<Path type='directory' group="root" name="/autonfs/stage" owner="root" mode="0755"/>
<Path type='directory' group="root" name="/exports" owner="root" mode="0755"/>
<Path type='directory' name="/etc/condor" owner="root" group="root" mode="0755"/>
<Path type='directory' name="/logs" group="wwwtrans" owner="root" mode="0775"/>
<Path type='directory' name="/mnt" group="root" owner="root" mode="0755"/>
<Path type='directory' name="/my" owner="root" group="root" mode="0755"/>
<Path type='directory' name="/my/bin" owner="root" group="root" mode="0755"/>
<Path type='directory' name="/nfs" owner="root" group="root" mode="0755"/>
<Path type='directory' name="/sandbox" mode="0777" owner="root" group="root"/>
<Path type='directory' name="/software" group="root" owner="root" mode="0755"/>
<Path type='permissions' mode="0555" group="audio" owner="root" name="/dev/dsp"/>
<Path type='permissions' mode="0555" group="audio" owner="root" name="/dev/mixer"/>
<Path type='symlink' name="/bin/whatami" to="/mcs/adm/bin/whatami"/>
<Path type='symlink' name="/chibahomes" to="/nfs/chiba-homefarm"/>
<Path type='symlink' name="/home" to="/nfs/mcs-homefarm"/>
<Path type='symlink' name="/homes" to="/home"/>
<Path type='symlink' name="/mcs" to="/nfs/mcs"/>
<Path type='symlink' name="/my/bin/bash" to="/bin/bash"/>
<Path type='symlink' name="/my/bin/tcsh" to="/bin/tcsh"/>
<Path type='symlink' name="/my/bin/zsh" to="/bin/zsh"/>
<Path type='symlink' name="/software/common" to="/nfs/software-common"/>
<Path type='symlink' name="/software/linux" to="/nfs/software-linux"/>
<Path type='symlink' name="/software/linux-debian_sarge" to="/nfs/linux-debian_sarge"/>
<Path type='symlink' name="/usr/bin/passwd" to="/usr/bin/yppasswd"/>
<Path type='symlink' name="/usr/bin/yppasswd" to="/mcs/bin/passwd"/>
<Path type='symlink' name="/usr/lib/libgd.so.1.8" to="/usr/lib/libgd.so.1.8.4"/>
<Path type='symlink' name="/usr/lib/libtermcap.so.2" to="/usr/lib/libtermcap.so"/>
<Path type='symlink' name="/usr/local/bin/perl" to="/usr/bin/perl"/>
<Path type='symlink' name="/usr/local/bin/perl5" to="/usr/bin/perl"/>
<Path type='symlink' name="/usr/local/bin/tcsh" to="/bin/tcsh"/>
<Service name='ntpd' status='on' type='chkconfig'/>
<Service name='haldaemon' status='on' type='chkconfig'/>
<Service name='messagebus' status='on' type='chkconfig'/>
<Service name='netfs' status='on' type='chkconfig'/>
<Service name='network' status='on' type='chkconfig'/>
<Service name='rawdevices' status='on' type='chkconfig'/>
<Service name='sshd' status='on' type='chkconfig'/>
<Service name='syslog' status='on' type='chkconfig'/>
<Service name='vmware-tools' status='on' type='chkconfig'/>
</Rules>
Using Regular Expressions in Rules
==================================
If you wish, you can configure the Rules plugin to support regular
expressions. This entails a small performance and memory usage
penalty. To do so, add the following setting to ``bcfg2.conf``::
[rules]
regex = yes
With regular expressions enabled, you can use a regex in the ``name``
attribute to match multiple abstract configuration entries.
Regular expressions are anchored at both ends, so ``<Service
name="bcfg2".../>`` will *not* match a Service named ``bcfg2-server``;
you'd have to explicitly specify ``<Service name="bcfg2.*".../>``.
Note that only one Rule can apply to any abstract entry, so you cannot
specify multiple regexes to match the same rule.
|