File: cfengine.texinfo

package info (click to toggle)
cfengine 1.4.9-3
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 3,540 kB
  • ctags: 1,861
  • sloc: ansic: 25,408; sh: 1,708; perl: 1,088; lex: 690; makefile: 435; lisp: 182; yacc: 101; csh: 24
file content (14837 lines) | stat: -rw-r--r-- 477,712 bytes parent folder | download
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
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552
13553
13554
13555
13556
13557
13558
13559
13560
13561
13562
13563
13564
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579
13580
13581
13582
13583
13584
13585
13586
13587
13588
13589
13590
13591
13592
13593
13594
13595
13596
13597
13598
13599
13600
13601
13602
13603
13604
13605
13606
13607
13608
13609
13610
13611
13612
13613
13614
13615
13616
13617
13618
13619
13620
13621
13622
13623
13624
13625
13626
13627
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
13651
13652
13653
13654
13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
13708
13709
13710
13711
13712
13713
13714
13715
13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
13728
13729
13730
13731
13732
13733
13734
13735
13736
13737
13738
13739
13740
13741
13742
13743
13744
13745
13746
13747
13748
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13766
13767
13768
13769
13770
13771
13772
13773
13774
13775
13776
13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
13790
13791
13792
13793
13794
13795
13796
13797
13798
13799
13800
13801
13802
13803
13804
13805
13806
13807
13808
13809
13810
13811
13812
13813
13814
13815
13816
13817
13818
13819
13820
13821
13822
13823
13824
13825
13826
13827
13828
13829
13830
13831
13832
13833
13834
13835
13836
13837
13838
13839
13840
13841
13842
13843
13844
13845
13846
13847
13848
13849
13850
13851
13852
13853
13854
13855
13856
13857
13858
13859
13860
13861
13862
13863
13864
13865
13866
13867
13868
13869
13870
13871
13872
13873
13874
13875
13876
13877
13878
13879
13880
13881
13882
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898
13899
13900
13901
13902
13903
13904
13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915
13916
13917
13918
13919
13920
13921
13922
13923
13924
13925
13926
13927
13928
13929
13930
13931
13932
13933
13934
13935
13936
13937
13938
13939
13940
13941
13942
13943
13944
13945
13946
13947
13948
13949
13950
13951
13952
13953
13954
13955
13956
13957
13958
13959
13960
13961
13962
13963
13964
13965
13966
13967
13968
13969
13970
13971
13972
13973
13974
13975
13976
13977
13978
13979
13980
13981
13982
13983
13984
13985
13986
13987
13988
13989
13990
13991
13992
13993
13994
13995
13996
13997
13998
13999
14000
14001
14002
14003
14004
14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
14016
14017
14018
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032
14033
14034
14035
14036
14037
14038
14039
14040
14041
14042
14043
14044
14045
14046
14047
14048
14049
14050
14051
14052
14053
14054
14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
14067
14068
14069
14070
14071
14072
14073
14074
14075
14076
14077
14078
14079
14080
14081
14082
14083
14084
14085
14086
14087
14088
14089
14090
14091
14092
14093
14094
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107
14108
14109
14110
14111
14112
14113
14114
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
14155
14156
14157
14158
14159
14160
14161
14162
14163
14164
14165
14166
14167
14168
14169
14170
14171
14172
14173
14174
14175
14176
14177
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190
14191
14192
14193
14194
14195
14196
14197
14198
14199
14200
14201
14202
14203
14204
14205
14206
14207
14208
14209
14210
14211
14212
14213
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251
14252
14253
14254
14255
14256
14257
14258
14259
14260
14261
14262
14263
14264
14265
14266
14267
14268
14269
14270
14271
14272
14273
14274
14275
14276
14277
14278
14279
14280
14281
14282
14283
14284
14285
14286
14287
14288
14289
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
14307
14308
14309
14310
14311
14312
14313
14314
14315
14316
14317
14318
14319
14320
14321
14322
14323
14324
14325
14326
14327
14328
14329
14330
14331
14332
14333
14334
14335
14336
14337
14338
14339
14340
14341
14342
14343
14344
14345
14346
14347
14348
14349
14350
14351
14352
14353
14354
14355
14356
14357
14358
14359
14360
14361
14362
14363
14364
14365
14366
14367
14368
14369
14370
14371
14372
14373
14374
14375
14376
14377
14378
14379
14380
14381
14382
14383
14384
14385
14386
14387
14388
14389
14390
14391
14392
14393
14394
14395
14396
14397
14398
14399
14400
14401
14402
14403
14404
14405
14406
14407
14408
14409
14410
14411
14412
14413
14414
14415
14416
14417
14418
14419
14420
14421
14422
14423
14424
14425
14426
14427
14428
14429
14430
14431
14432
14433
14434
14435
14436
14437
14438
14439
14440
14441
14442
14443
14444
14445
14446
14447
14448
14449
14450
14451
14452
14453
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
14469
14470
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481
14482
14483
14484
14485
14486
14487
14488
14489
14490
14491
14492
14493
14494
14495
14496
14497
14498
14499
14500
14501
14502
14503
14504
14505
14506
14507
14508
14509
14510
14511
14512
14513
14514
14515
14516
14517
14518
14519
14520
14521
14522
14523
14524
14525
14526
14527
14528
14529
14530
14531
14532
14533
14534
14535
14536
14537
14538
14539
14540
14541
14542
14543
14544
14545
14546
14547
14548
14549
14550
14551
14552
14553
14554
14555
14556
14557
14558
14559
14560
14561
14562
14563
14564
14565
14566
14567
14568
14569
14570
14571
14572
14573
14574
14575
14576
14577
14578
14579
14580
14581
14582
14583
14584
14585
14586
14587
14588
14589
14590
14591
14592
14593
14594
14595
14596
14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607
14608
14609
14610
14611
14612
14613
14614
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
14628
14629
14630
14631
14632
14633
14634
14635
14636
14637
14638
14639
14640
14641
14642
14643
14644
14645
14646
14647
14648
14649
14650
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
14667
14668
14669
14670
14671
14672
14673
14674
14675
14676
14677
14678
14679
14680
14681
14682
14683
14684
14685
14686
14687
14688
14689
14690
14691
14692
14693
14694
14695
14696
14697
14698
14699
14700
14701
14702
14703
14704
14705
14706
14707
14708
14709
14710
14711
14712
14713
14714
14715
14716
14717
14718
14719
14720
14721
14722
14723
14724
14725
14726
14727
14728
14729
14730
14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751
14752
14753
14754
14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803
14804
14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
14833
14834
14835
14836
14837
\input texinfo @c -*-texinfo-*-
@c *********************************************************************
@c
@c  This is a TEXINFO file. It generates both TEX documentation and
@c  the "on line" documentation "info" files.
@c
@c  The file is structured like a programming language. Each chapter
@c  starts with a chapter comment.
@c
@c  Menus list the subsections so that an online info-reader can parse
@c  the file hierarchically.
@c
@c  Last change: MB 31/08/95
@c
@c ***********************************************************************
@c %** start of header
@setfilename cfengine.info
@settitle GNU cfengine
@setchapternewpage odd
@c %** end of header
@defindex mb


@include version.texi

@titlepage
@title CFENGINE
@subtitle Edition @value{EDITION} for version @value{VERSION}
@author Mark Burgess
@author Centre of Science and Technology,
@author Faculty of Engineering, Oslo College, Norway

@c @smallbook

@page
@vskip 0pt plus 1filll
Copyright @copyright{} 1995/96/97 Mark Burgess

   Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

   Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided also
that the section entitled "GNU General Public License" is included
exactly as in the original, and provided that the entire resulting
derived work is distributed under the terms of a permission notice
identical to this one.

   Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that the section entitled "GNU General Public License"
may be included in a translation approved by the author instead of in
the original English.

This manual corresponds to CFENGINE
Edition @value{EDITION} for version @value{VERSION}
as last updated @value{UPDATED}.

@end titlepage


@c *************************** File begins here ************************

@ifinfo
@node Top, Overview, (dir), (dir)
@top Cfengine
@end ifinfo


@ifinfo
START-INFO-DIR-ENTRY
* cfengine: (cfengine.info).
                        Cfengine is a language based tool specifically
                        designed for configuring and maintaining BSD
                        and System-5-like operating systems attached
                        to a TCP/IP network.
END-INFO-DIR-ENTRY
@end ifinfo


@ifinfo
Copyright @copyright{} 1995/96/97 Mark Burgess

   Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

   Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided also
that the section entitled "GNU General Public License" is included
exactly as in the original, and provided that the entire resulting
derived work is distributed under the terms of a permission notice
identical to this one.

   Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that the section entitled "GNU General Public License"
may be included in a translation approved by the author instead of in
the original English.

This manual corresponds to CFENGINE
Edition @value{EDITION} for version @value{VERSION}
as last updated @value{UPDATED}.

@end ifinfo

@menu
* Overview::                    key concepts
* Getting started::             simple cfengine programs
* More advanced concepts::      adding sophistication
* Global configurations::       a tutorial
* Using cfengine as a front-end for cron::  
* Cfengine network services::   
* Security and cfengine::       
* Command reference::           comprehensive guide
* Writing scripts for cfengine::  a gallery of ideas
* Problem solving::             
* Using the help scripts::      making batch jobs with cfengine
* Example configuration file::  global config example
* Runtime Options::             reference guide
* Network protocol specs::      
* Variable Index::              guide to variables
* Concept Index::               guide to important concepts

* FAQ Index::                   

 --- The Detailed Node Listing ---

Overview

* What is cfengine?::           
* Site configuration::          the problem
* Key concepts::                the solution
* Functionality::               an advertisement

Key Concepts

* Control files::               textfiles which configure
* Network interface::           ethernet parameters
* Network File System (NFS)::   sharing resources
* Name servers (DNS)::          setting up a name service
* Monitoring important files::  permission and ownership
* Making links::                aliases

Getting started

* What you must have::          a skeleton cfengine program
* Program structure::           an overview
* Options::                     spices and conveniences
* Invoking cfengine::           from the command line
* CFINPUTS environment variable::  the cfengine search path
* What to aim for::             

More advanced concepts

* Classes basics::              
* Variable substitution::       
* Defining classes::            making decisions
* The generic class any::       a wildcard
* Debugging tips::              nullifying classes
* Access control::              specifying user access to programs
* Wildcards in directory names::  multiple searches
* File sweeps::                 
* Log files::                   
* Quoted strings::              
* Regular expressions::         
* Iterating over lists::        

Designing a global system configuration

* General considerations::      
* Using netgroups::             a common database for classes
* Files and links::             
* Copying files::               
* Managing processes::          
* NFS resources::               the cfengine model
* Using the automounter::       
* Editing files::               
* Disabling and the file repository::  
* Running user scripts::        
* Compressing logs::            
* ACLs::                        

Cfengine's model for NFS-mounted filesystems

* NFS filesystem resources::    a conceptual introduction
* Unique filesystem mountpoints::  avoiding collisions
* How does it work?::           
* Special variables::           binserver etc.
* Mount example::               example program

Using cfengine as a front end for @code{cron}

* Structuring cfengine.conf::   
* Splaying host times::         
* Building flexible time classes::  
* Scheduling interval::         

Cfengine and network services

* What services?::              
* How it works::                
* Configuring cfd::             

How it works

* Emulating rdist::             
* Remote execution of cfengine::  
* cfrun::                       
* Spamming and security::       
* cfd protocol::                
* Deadlocks and runaway loops::  

Configuring @code{cfd}

* Installation of cfd::         
* Configuration file cfd.conf::  
* TCP wrappers::                

Security and cfengine

* Hints for implementing security::  
* Who do you trust?::           
* Firewalls::                   

Command reference

* acl::                         
* binservers::                  
* broadcast::                   
* control::                     
* classes::                     
* copy::                        
* defaultroute::                
* disks::                       
* directories::                 
* disable::                     
* editfiles::                   
* files::                       
* groups::                      
* homeservers::                 
* ignore::                      
* import::                      
* links::                       
* mailserver::                  
* miscmounts::                  
* mountables::                  
* processes::                   
* required::                    
* resolve::                     
* shellcommands::               
* tidy::                        
* unmount::                     

acl

* ACEs::                        
* Solaris ACLs::                
* DFS ACLs::                    
* ACL Example::                 

control

* access::                      
* actionsequence::              
* addclasses::                  
* copylinks::                   
* domain::                      
* dryrun::                      
* editfilesize::                
* excludecopy::                 
* excludelinks::                
* ExpireAfter::                 
* homepattern::                 
* IfElapsed::                   
* Inform::                      
* interfacename::               
* linkcopies::                  
* mountpattern::                
* netmask::                     
* nfstype::                     
* repchar::                     
* repository::                  
* sensiblecount::               
* sensiblesize::                
* SplayTime::                   
* site::                        
* split::                       
* sysadm::                      
* Syslog::                      
* timezone::                    
* Verbose::                     
* Warnings::                    

copy

* hard links in copy::          
* Too many open files::         

files

* Syntax::                      summary
* Recursion::                   searching subdirectories
* Directory permissions::       file mode and ownership
* home directive::              a wildcard for user files
* Owner and group wildcards::   ignoring ownership
* Files linkchildren::          an `intelligent' feature
* touch::                       
* create::                      

links

* Single links::                with the -> directive
* Multiple Links::              with the +> directive
* Link Children::               an `intelligent' feature
* Relative and absolute links::  
* Hard links::                  

Cfengine script gallery

* Old files::                   tidying up
* Sharing files::               opening files for other users
* Disk clearing::               emergency clean-up script
* Script for making links::     maintaining links
* Ftp server::                  setting up an anonymous ftp server

Problem solving, bugs, FAQs and tips

* cf.preconf bootstrap file::   network bootstrapping
* cfrc resource file::          changing the internal defaults
* Problems with compilation and installation::  
* Bug reports and suggestions::  
* FAQS and Tips::               

FAQs and Tips

* General::                     
* AIX::                         
* HPUX::                        
* IRIX::                        
* LINUX::                       
* OSF::                         
* SUN (4.1.*)::                 
* SOLARIS 2::                   
* FreeBSD::                     

Using the help scripts

* cfwrap::                      a wrapper script
* cfmail::                      a simple mail agent
* noseyparker::                 software quotas
* backup ::                     
* cfbg::                        

Example configuration files

* cfengine.conf::               
* cf.groups::                   
* cf.main::                     
* cf.site::                     
* cf.motd::                     
* cf.users::                    
* cf.solaris::                  
* cf.linux::                    
* cf.freebsd::                  
* cfd.conf::                    
@end menu

@c **********************************************************************
@c INTRO
@c **********************************************************************

@unnumbered Foreword

Cfengine is the result of a continuing research project to help solve the
problems of system administration in a big network. Cfengine is an
expert system combined with a declarative language and a workhorse-robot.

Many people have contributed their experiences and wisdom to the
cfengine project. I apologise for not being able to mention everyone
here. Morten Hanshaugen and Hans Petter Holen made it possible to test
cfengine on a variety of systems at the university of Oslo. I am
grateful to Knut Borge for his experience and suggestions on many
occaision.  Ola Borrebaek and Richard Stallman have made key
observations which have influenced the development of cfengine in
important ways.  Audun Tornquist did some initial work on the `copy'
feature and donated the backup help-script to the distribution.  Gord
Matzigkeit contributed an early autoconf setup. Andrew Ford contributed
the self-documentation perl script. Ricky Ralston (Hewlett Packard)
provided invaluable information on HPUX-10 and discovered a number of
bugs and inaccuracies in the source code: our collaboration on making
1.3.0 the definitive system administration tool (before 1.4.0!)  has
been invaluable. David Masterson continues to provide me with the
results of detailed tests and new auto configuration improvements.
Brian White maintains the Debian linux package and has been helpful with
bug reports.  Rolf Ebert contributed the emacs cfengine mode file.
Max Okumoto ran the source code through `insight' and found lots of
accidentals. Sergio Tessaris has done lots of testing and bug tracking.
I am grateful to Ann-Mari Torvatn and Len Tower for reading
through and helping to improve the documentation. Finally, Demosthenes
Skipitaris and I added the new adaptive locks to cfengine 1.4.0.

For up to the minute information on cfengine, workshops, conferences and
all that jazz see the web page:

@smallexample
http://www.iu.hioslo.no/cfengine
@end smallexample
@noindent
Bug reports and queries by mail to
@smallexample
bug-cfengine@@prep.ai.mit.edu
@end smallexample
@noindent
(why not bug Jack Barron instead?)
Two newsgroups are also available now for discussions and
bug reports. The newsgroup gnu.cfengine.bug (with corresponding
mailing list  bug-cfengine@@prep.ai.mit.edu) is for bug reports,
and the group gnu.cfengine.help (with mailing list help-cfengine@@prep.ai.mit.edu)
is for general requests for help and user discussion.

Mark Burgess
Oslo, 1997

@unnumbered @sc{STATE OF MIND (for the critics)}

@sp 10
@table @emph

@item Kirk:
I'm curious, Doctor, why is it called the M5?

@item Daystrom:
Well you see, M1 to M4 were not entirely successful. This one is.
M5 is ready to take control of your ship.

@item Kirk:
Total control?

@item Daystrom:
That is what it is designed for.

@item Kirk:
There are some things that Men have to do to remain Men, your computer
takes that away.

@item Daystrom:
The computer can do your job ... One machine can do all those things
that Men do now. Men can go on to do greater things...

@end table



@sp 2

@emph{--ST: The ultimate computer}

@sp 2

@table @emph

@item Scientist:
Mad, mad? Of course I'm mad! But I have tenure!
@end table


@sp 2

@emph{--Cartoon from OMNI magazine, early 1980's}

@unnumbered @sc{Part I}

@sp 18

@center @titlefont{Tutorial section}

@c **********************************************************************
@c CHAPTER
@c **********************************************************************

@node Overview, Getting started, Top, Top
@chapter Overview

@emph{In this manual the word ``host'' is used to refer to a single computer
system -- i.e.  a single machine which has a name termed its ``hostname''.}

@menu
* What is cfengine?::           
* Site configuration::          the problem
* Key concepts::                the solution
* Functionality::               an advertisement
@end menu

@c -----------------------------------------------------------------------
@c SECTION
@c -----------------------------------------------------------------------

@node What is cfengine?, Site configuration, Overview, Overview
@section What is cfengine and who can use it?

Cfengine is a tool for setting up and maintaining BSD and System-5-like
operating system optionally attached to a TCP/IP network.  You can think
of cfengine as a very high level language---much higher level than Perl
or shell: a single statement can result in many hundreds of operations
being performed on multiple hosts. Cfengine is good at performing a lot
of common system administration tasks, and allows you to build on its
strengths with your own scripts. You can also use it as a netwide
front-end for @code{cron}.  Once you have set up cfengine, you'll be
free to use your time being like a human being, instead of playing R2-D2
with the system.

The main purpose of cfengine is to allow you to create a single, central
system configuration which will define how every host on your network
should be configured in an intuitive way.  An interpreter runs on every
host on your network and parses the master file (or file-set); the
configuration of each host is checked against this file and then, if you
request it, any deviations from the defined configuration are fixed
automatically.  You do not have to mention every host specifically by
name in order to configure them : instead you can refer to the
properties which distinguish hosts from one another.  Cfengine uses a
flexible system of ``classes'' which helps you to single out a specific
group of hosts with a single statement.

Originally cfengine was conceived of as a tool only for the superuser,
but during the course of its development it has become clear that it can
also be used as a scripting language by ordinary users.  It is a handy
tool for tidying your old junk files and for making `watchdog' scripts
to manage the access rights and permissions on your files when
collaborating with other users.  As a bonus it contains a text editing
language which can be used to perform controlled edits of line-based
text files.


Cfengine grew out of the need to control the accumulation of complex
shell scripts used in the automation of key system maintenance at
Oslo. There were very many scripts, written in shell and in perl,
performing tasks such as file tidying, find-database updates, process
checking and several other tasks.  In a heterogeneous environment,
shell-scripts work very poorly: shell commands have differing syntax
across different operating systems, the locations and names of key files
differ. In fact, the non-uniformity of unix was a major
headache. Scripts were filled with tests to determine what kind of
operating system they were being run on, to the point where they became
so complicated an unreadable that no-one was quite sure what they did
anymore. Other scripts were placed only on the systems where they were
relevant, out of sight and out of mind.  It quickly became clear that
our dream solution would be to replace this proliferation of scripts by
a single file containing everything to be checked on every host on the
network. By defining a new language, this file could hide all of the
tests by using classes (a generalized `switch/case' syntax) to label
operations and improve the readability greatly. The gradual refinement
of this idea resulted in the present day cfengine.

The remainder of this manual assumes that you know a little about
BSD/System-5 systems and have everyday experience in using either the
C-shell or the Bourne shell, or their derivatives.  If you are
experienced in system administration, you might like to skip the earlier
chapters and turn straight to the example @xref{Example configuration
file}.  This is the probably quickest way to learn cfengine for the
initiated.  If you are not so familiar with system administration and
would like a more gentle introduction, then we begin here...

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Site configuration, Key concepts, What is cfengine?, Overview
@section Site configuration

To the system administrator of a small network, with just a few
workstations or perhaps even a single mainframe system, it might seem
superfluous to create a big fuss about the administration of the system.
After all, it's easy to `fix' things manually should any problems
arise, making a link here, writing a script there and so on --- and its
probably not even worth writing down what you did because you know that
it will always be easy to fix next time around too...  But networks have
a tendency to expand and---before you know it---you have five different
types of operating system and each type of system has to be configured
in a special way, you have to make patches to each system and you can't
remember whether you fixed that host on the other side of the
building...  Also, you discover fairly quickly that what you thought of
as BSD or System 5 is not as standard as you thought and that none of
your simple scripts that worked on one system work on the others without
a considerable amount of hacking and testing.  You try writing a script
to help you automate the task, but end up with an enormous number of
@samp{if..then..else..} tests which make it hard to see what is really
going on.

To manage a network with many different flavours of operating system, in
a systematic way, what is needed is a more disciplined way of making
changes which is robust against re-installation.  After all, it would be
tragic to spend many hours setting up a system by hand only to lose
everything in an unfortunate disk-crash a week or even a year later when
you have forgotten what you had to do.  Upgrades of the operating system
software might delete your carefully worked out configuration.  What is
needed is a separate record of all of the patches required on all of the
systems on the network; a record which can be compared to the state of
each host at any time and which a suitable engine can use to fix any
deviations from that reference standard.

The idea behind cfengine is to focus upon a few key areas of basic
system administration and provide a language in which the
transparency of a configuration program is optimal.  It eliminates the
need for lots of tests by allowing you to organize your network
according to ``classes''.  From a single configuration file (or set of
files) you can specify how your network should be configured --- and
cfengine will then parse your file and carry out the instructions,
warning or fixing errors as it goes.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Key concepts, Functionality, Site configuration, Overview
@section Key Concepts

@emph{Some of the important issues in system
administration which cfengine can help with.}

@menu
* Control files::               textfiles which configure
* Network interface::           ethernet parameters
* Network File System (NFS)::   sharing resources
* Name servers (DNS)::          setting up a name service
* Monitoring important files::  permission and ownership
* Making links::                aliases
@end menu

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Control files, Network interface, Key concepts, Key concepts
@subsection Control files
@cindex Control files
@cindex Files, control
@cindex Files, configuration

One of the endearing characteristics of BSD and system 5 systems is
that they are configured through human-readable text files.  To add a
new user to the system you edit @file{/etc/passwd}, to add a new
disk you must edit @file{/etc/fstab} etc.  Many applications are also
configured with the help of text files.  When installing a new system
for the first time, or when changing updating the setup of an old system
you are faced with having to edit lots of files.  In some cases you will
have to add precisely the same line to the same file on every system in
your network as a change is made, so it is handy to have a way of
automating this procedure so that you don't have to load every file into
an editor by hand and make the changes yourself.  This is one of the
tasks which cfengine will automate for you.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Network interface, Network File System (NFS), Control files, Key concepts
@subsection Network interface
@cindex ifconfig
@cindex network interface
@cindex network configuration

Each host which you connect to an ethernet-based network running TCP/IP
protocols must have a so-called `net interface'.  This network interface
must be configured before it will work.  Normally one does this with the
help of the @code{ifconfig} command.  This can also be checked and
configured automatically by cfengine.

Network configuration involves telling the interface hardware what the
internet (IP) address of your system is, so that it knows which incoming
`packets' of data to pay attention to.  It involves telling the
interface how to interpret the addresses it receives by setting the
`netmask' for your network (see below).  Finally you must tell it which
dummy address is to be used for messages which are broadcast to all
hosts on your network simultaneously @xref{netmask}.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Network File System (NFS), Name servers (DNS), Network interface, Key concepts
@subsection Network File System (NFS) or distribution?
@cindex NFS

Probably the first thing you are interested in doing with a network
(after you've had your fill of the world wide web) is to make your files
available to some or all hosts on the network, no matter where in your
corporate empire (or university dungeon) you might be sitting.  In other
words, if you have a disk which is physically connected to host A, you
would like to make the contents of that disk available to hosts B, C,
D...  etc.  NFS (the network filesystem) does this for you.  The process
works by `filesystems'.

A filesystem is one partition of a disk drive -- or one unit of disk
space which can be accessed by a single `logical device'
@samp{/dev/something}.  To make a filesystem available to other hosts
you have to do three things.

@itemize @bullet
@item On the host the disk is physically connected to you must @emph{export} the filesystem
by adding something to the file @file{/etc/exports}.  This tells NFS who
is allowed to access the disk and who isn't.

@item On the host which is to access the filesystem you must create a mount point.  This
is a name in the directory tree at which you want to add the files to
your local filesystem.

@item On the host which is to access the files you must mount the filesystem onto the
mount point.  The mount operation is the jargon for telling the system
to access the device on which the data are stored.  Mounting is
analogous to opening a file: files are opened, filesystems are mounted.
@end itemize

@noindent
Only after all three of these have been done will a filesystem become
available across the network.  Cfengine will help you with the last two
in a very transparent way.  You could also use the text-editing facility
in cfengine to edit the exports file, but there are other ways update
the exports file using @emph{netgroups} which we shall not go into here.
If you are in doubt, look up the manual page on exports.

Some sites prefer to minimize the use of NFS filesystems, to
avoid one machine being dependent on another. They prefer to
make a local copy of the files on a remote machine instead.
Traditionally programs like @code{rdist} have been used for
this purpose. You may also use cfengine to copy files in this
way, @xref{Emulating rdist}.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Name servers (DNS), Monitoring important files, Network File System (NFS), Key concepts
@subsection Name servers (DNS)
@cindex Name server
@cindex DNS

There are two ways to specify addresses on the internet (called IP
addresses).  One is to use the textual address like @samp{ftp.uu.net}
and the other is to use the numerical form @samp{192.48.96.9}.  Alas,
there is no one-to-one correspondence between the numerical addresses
and the textual ones, thus a service is required to map one to the
other.

The service is performed by one or more special hosts on the network
called @emph{nameservers}.  Each host must know how to contact a
nameserver or it will probably hang the first time you give it an IP
address.  You tell it how to contact a nameserver by editing the
text-file @file{/etc/resolv.conf}.  This file must contain the domain
name for your domain and a list of possible nameservers which can be
contacted, in order of priority.  Because this is a special file which
every host must have, you don't have to use the editing facilities in
cfengine explicitly.  You can just define the nameservers for each host
in the cfengine file and cfengine will do the editing automatically.  If
you want to change the priority of nameservers later, or even change the
list then a simple change of one or two lines in the configuration file
will enable you to reconfigure every host on your network automatically
without having to do any editing yourself!

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Monitoring important files, Making links, Name servers (DNS), Key concepts
@subsection Monitoring important files
@cindex Monitoring important files
@cindex Files, checking permissions

Security is an important issue on any system.  In the busy life of a
system administrator it is not always easy to remember to set the correct
access rights on every file and this can result in either a security
breach or problems in accessing files.

A common scenario is that you, as administrator, fetch a new package
using ftp, compile it and install it without thinking too carefully.
Since the owner and permissions of the files in an ftp archive remains
those of the program author, it often happens that the software is left
lying around with the owner and permissions as set by the author of the
program rather than any user-name on @emph{your} system.  The user-id of
the author might be anybody on your system --- or perhaps nobody at all!
The files should clearly be owned by root and made readable and
unwritable to normal users.

Simple accidents and careless actions under stress could result in, say,
the password file being writable to ordinary users.  If this were the
case, the security of the entire system would be compromised.  Cfengine
therefore allows you to monitor the permissions, ownership and general
existence of files and directories and, if you wish, correct them or
warn about them automatically.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Making links,  , Monitoring important files, Key concepts
@subsection Making links
@cindex Links

One of the difficulties with having so many different variations on the
theme of BSD and system 5 based operating systems is that similar files
are not always where you expect to find them.  They have different names
or lie in different directories.  The usual solution to the problem is
to make an alias for these files, or a pointer from one filename to
another.  The name for such an alias is a @emph{symbolic link}.

It is often very convenient to make symbolic links.  For example, you
might want the sendmail configuration file @file{/etc/sendmail.cf} to be
a link to a global configuration file, say,
@smallexample
@file{/usr/local/mail/etc/sendmail.cf}
@end smallexample

@noindent
on every single host on your network so that there is only one file to
edit.  If you had to make all of these links yourself, it would take a
lifetime.  Cfengine will make such a link automatically and check it
each time time is run.  You can also ask it to tidy up old links which
have been left around and no longer point to existing files.  If you
reinstall your operating system later it doesn't matter because all your
links are defined in your cfengine configuration file, recorded for all
time.  Cfengine won't forget it, and you won't forget it because the
setup is defined in one central place.

Cfengine will also allow you to make hard links to regular files, but
not other kinds of file. A hard link to a symbolic link, is the same
as a hard link to the file the symbolic link points to.
@cindex Hard links

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Functionality,  , Key concepts, Overview
@section Functionality

The notes above give you a rough idea of what cfengine can be used for.
Here is a summary of cfengine's capabilities.

@itemize @bullet

@item Check and configure the network interface.

@item Edit textfiles for the system and for all users.

@item Make and maintain symbolic links, including multiple links from
a single command.

@item Check and set the permissions and ownership of files.

@item Tidy (delete) junk files which clutter the system.

@item Systematic, automated mounting of NFS filesystems.

@item Checking for the presence of important files and filesystems.

@item Controlled execution of user scripts and shell commands.

@item Cfengine follows a class-based decision structure.

@item Process management.

@end itemize

How do you run cfengine? You can run it as a cron job, or you can run it
manually. You may run cfengine scripts/programs as often
as you like.  Each time you run a script, the engine determines whether
anything needs to be done --- if nothing needs to be done, nothing is
done!  If you use it to monitor and configure your entire network from a
central file-base, then the natural thing is to run cfengine daily with
the help of @code{cron}.  @xref{cfwrap}, but also, @xref{cfrun}.


@c **********************************************************************
@c CHAPTER
@c **********************************************************************

@node Getting started, More advanced concepts, Overview, Top
@chapter Getting started

@menu
* What you must have::          a skeleton cfengine program
* Program structure::           an overview
* Options::                     spices and conveniences
* Invoking cfengine::           from the command line
* CFINPUTS environment variable::  the cfengine search path
* What to aim for::             
@end menu

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node What you must have, Program structure, Getting started, Getting started
@section What you must have in a cfengine program
@cindex Musts in cfengine

A cfengine configuration file for a large network can become long and complex
so, before we get down to details, let's try to strip away the complexity
and look only to the essentials.

Each cfengine program or configuration file is a list of declarations of
items to be checked and perhaps fixed.  You begin by creating a file
called @file{cfengine.conf}.  The simplest meaningful file you can
create is something like this:

@smallexample

# Comment...
 
control:

  actionsequence = ( links )

links:

  /bin -> /usr/bin

@end smallexample

@noindent
The
example above checks and makes (if necessary) a link from @file{/bin} to @file{/usr/bin}.
Let's examine this example more closely.  In a cfengine program:

@itemize @bullet

@item 
Use of space is unrestricted.  You can start new lines wherever you like.
You should generally have a space before and after parentheses to avoid
confusing the parser.

@item 
A comment is some text which is ignored by cfengine.  The @samp{#} symbol
designates a comment and means: ignore the remaining text on this line.
A comment symbol must have a space in front of it, or start a new line
so that cfengine knows you don't mean the symbol as part of another
word.

@item 
Words which end in a single colon define @emph{sections} in a program.  Under a
given section you group together all declarations of a given type.  Section names
must all be taken from a list defined by the language.  You cannot define your
own sections.

@item 
Words which end in two colons are so-called @emph{class} names.  They are
used for making decisions in cfengine.

@item 
Statements which are of the form @code{@var{name}=( @var{list} )} are
used to assign the value on the right hand side to the name on the left hand side
of the equals sign.

@end itemize

@noindent
In simple example above has three of the four types of object described
above.  The @code{control:} section of any program tells cfengine how to
behave.  In this example it adds the action @var{links} to the
actionsequence.  For @var{links} you could replace some other action.
The essential point is that, if you don't have an action sequence, your
cfengine program will do absolutely nothing! The action sequence is a
list which tells cfengine what do to and in which order.

The @code{links:} section of the file tells cfengine that what follows
is a number of links to be made.  If you write this part of the file,
but forget to add links to the actionsequence, then nothing will be
done! You can add any number of links in this part of the file and they
will all be dealt with in order when---and only when---you write
@var{links} in the action sequence.

To summarize, you @emph{must} have:

@itemize @bullet

@item Some declarations which specify things to be done.

@item An action sequence which tells cfengine which sections to process,
how many times and in which order they should be processed.

@end itemize

Now let's think a bit about how useful this short example program is.
On a SunOS system, where the directory @file{/bin} is in fact supposed
to be a link, such a check could be useful, but on some other system
where @file{/bin} is a not a link but a separate directory, this would
result in an error message from cfengine, telling you that @file{/bin}
exists and is not a link.  The lesson is that, if we want to use
cfengine to make @emph{one single} program which can be run on any host
of any type, then we need some way of restricting the above link so that
it only gets checked on SunOS systems.  We can write the following:

@smallexample

# Comment...
 
control:

  actionsequence = ( links  )

links:

  sun4:: 

       /bin -> /usr/bin
       # other links

   osf::

       # other links

@end smallexample

@noindent
The names which have double colons after them are called @emph{classes}
and they are used to restrict a particular action so that it only gets
performed if the host running the program is a member of that class.  If
you are familiar with C++, this syntax should make you think of classes
definitions in C++.  Classes works like this: the names above
@code{sun4}, @code{sun3}, @code{osf} etc.  are all internally defined by
cfengine.  If a host running, say, the OSF operating system executes the
file it automatically becomes a member of the class @code{osf}.  Since
it cannot be a member more than one of the above, this distinguishes
between different types of operating system and creates a hidden
@code{if}..@code{then}...@code{else} test.

This is the way in which cfengine makes decisions.  The key idea is that
actions are only carried out if they are in the same class as the host
running the program.  Classes are dealt with in detail in the next
chapter.

Now let's see how to add another kind of action to the action sequence.

@smallexample

# Comment...
 
control:

  actionsequence = ( tidy links )

links:

  /bin -> /usr/bin

tidy:

   /tmp  pattern=* age=7 recurse=inf

@end smallexample

@noindent
We have now added a new kind of declaration called @code{tidy:} which
deletes files.  In the example above, we are looking at files in the
directory @file{/tmp} which match the pattern @samp{*} and have not been
accessed for more than seven days.  The search for these files descends
recursively down any number of subdirectories.

To make any of this happen we must add the word @var{tidy} to the action
sequence.  If we don't, the declaration will be ignored.  Notice also
that, regardless of the fact that @code{links:} comes before
@code{tidy:}, the order in the action sequence tells us that all
@code{tidy} actions will be performed before @code{links:}.

The above structure can be repeated to build up a configuration file or script.


@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Program structure, Options, What you must have, Getting started
@section Program structure
@cindex Program structure
@cindex Structure of a program

@cindex Comments
To summarize the previous section, here is a sketch of a typical
cfengine configuration program showing a sensible structure.  The
various sections are listed in a sensible order which you would probably
use in the action sequence.

An individual section-declaration in the program looks something like this:

@smallexample

@var{action-type}:

   @var{class1}::

       @var{list of things to do...}

   @var{class2}::

       @var{list of things to do...}

@end smallexample 
@noindent
@code{action-type} is one of the following reserved words:

@smallexample

   groups, control, homeservers, binservers, mailserver, mountables,
   import, broadcast, resolve, defaultroute, directories, miscmounts,
   files, ignore, tidy, required, links, disable, shellcommands, 
   editfiles, processes

@end smallexample
 
@noindent
The order in which declarations occur is not important to cfengine from
a syntactical point of view, but some of the above actions define
information which you will want to refer to later.  All variables,
classes, groups etc.  must be defined before they are used.  That means
that it is smart to follow the order above for the sections in the first
line of the above list.

The order in which items are declared is not to be confused with the
order in which they are executed.  This is determined by the
@code{actionsequence}, @xref{control}.  Probably you will want to
coordinate the two so that they match as far as possible.
@cindex Order of actions
@cindex Sections, order of
@cindex Actions, order of

For completeness, here is a complete summary of the structure of a very
general cfengine configuration program.  The format is free and use of
space is unrestricted, though it is always a good idea to put a space in
front before and after parentheses when defining variables.
@cindex Free format
@cindex Program format
@cindex Format

@smallexample

######################################################################
# 
# Example of structure
#
######################################################################

groups:
 
   @var{group1} = ( @var{host} @var{host} ...  )
   @var{group2} = ( @var{host} @var{host} ...  ) 
   ...

######################################################################

control: 

   @var{class}::

   site      =  ( @var{mysite} )
   domain    =  ( @var{mydomain} )
   ...

    actionsequence = 
      (
      @var{action name}
      ....
      )

   mountpattern = ( @var{mountpoint} )
   homepattern = ( @var{wildcards matching home directories} ) 

   addclasses = ( @var{foo} @var{bar} )

######################################################################

homeservers:

   @var{class}::  
           @var{home servers}

binservers:

   @var{class}::
           @var{binary servers}

mailserver:

   @var{class}::
           @var{mail server}

mountables:

   @var{class}::

           @var{list of resources}


######################################################################

import: 

   @var{class}::    @var{include file}

   @var{class}::    @var{include file}


######################################################################

broadcast:

  @var{class}::  @var{ones}   # or zeros / zeroes

defaultroute:

   @var{class}::  @var{my-gw}


######################################################################

resolve:

   any::

       @var{list of nameservers}


   ...

@end smallexample 
@noindent



@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Options, Invoking cfengine, Program structure, Getting started
@section Optional features in cfengine
@cindex Optional features in cfengine

Cfengine doesn't do anything unless you ask it to.  When you run a
cfengine program it generates no output unless it finds something it
believes to be wrong.  It does not carry out any actions unless they are
declared in the action sequence.  In fact it's just like one of those
people you try to avoid at the office because they only complain about
what's wrong and never ever say anything positive.  But all this can
change.

If you like, you can make cfengine positively chatty.  Cfengine can be
run with a number of command line options @xref{Runtime Options}.  If
you run the program with the @samp{-v} or @samp{--verbose} options, it
will supply you cheerily with a resume of what it is doing.  Certain
warning messages also get printed in verbose mode.

You can ask cfengine to check lots of things -- the timezone for
instance, or the domain name.  In order for it to check these things, it
needs some information from you.  All of the switches and options which
change the way in which cfengine behaves get specified either on the
command line or in the @code{control:} section of the control file.
Some special control variables are used for this purpose.  Here is a
short example:

@smallexample

control:

  domain   = ( mydomain.no )
  netmask  = ( 255.255.255.0 )
  timezone = ( MET )

  mountpattern = ( /mydomain/mountpoint )

  actionsequence = 
     (
     checktimezone     # check time zone
     netconfig         # includes check netmask
     resolve           # includes domain
     mountinfo         # look for mounted disks under mountpattern
     )

@end smallexample

@noindent
To get verbose output you must run cfengine with the appropriate command
line option @samp{--verbose} or @samp{-v}.

Notice that setting values has a special kind of syntax: a variable
name, an equals sign and a value in parentheses.  This tells you that
the quantity of the left hand side assumes the value on the right hand
side.  There are lots of questions you might ask at this point.  The
answers to these will be covered as we go along and in the next chapter.

Before leaving this brief advertisement for control parameters, it is
worth noting the definition of @code{mountpattern} above.  This declares
a directory in which cfengine expects to find mounted disks.  It will be
explained in detail later, for now notice that this definition looks
rather stupid and inflexible.  It would be much better if we could use
some kind of variables to define where to look for mounted filesystems.
And of course you can...


Having briefly scraped the surface of what cfengine can do, turn to the
example @xref{Example configuration file} and take a look at what a
complete program can look like.  If you understand it, you might like to
skip through the rest of the manual until you find what you are looking
for.  If it looks mysterious, then the next chapter should answer some
questions in more depth.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Invoking cfengine, CFINPUTS environment variable, Options, Getting started
@section Invoking cfengine
@cindex Invoking cfengine
@cindex Starting cfengine
@cindex cfengine, starting

Cfengine may be invoked in a number of ways.  Here are some examples:
 
@example
@cartouche
host% cfengine

host% cfengine --file myfile

host% cfengine -f myfile -v -n

host% cfengine --help
@end cartouche
@end example

@cindex Default file
@cindex Config file, default name
@cindex @file{cfengine.conf}
The first of these (the default command, with no arguments) causes
cfengine to look for a file called @file{cfengine.conf} in the current
directory and execute it silently.  The second command reads the file
@file{myfile} and works silently.  The third works in verbose mode and
the @code{-n} option means that no actions should actually be carried
out, only warnings should be printed.  The final example causes cfengine
to print out a list of its command line options.
@vindex -n option
@vindex -f option
@vindex -v option

The complete list of options is listed in the summary at the beginning
of this manual, or you can see it by giving the @code{-h} option.
@xref{Runtime Options}
@cindex Help
@cindex -h option
@vindex -h option

In addition to running cfengine with a filename, you can also treat
cfengine files as scripts by starting your cfengine program with the
standard shell line:
@smallexample
#!/local/gnu/bin/cfengine -f
#
# My config script
#
@end smallexample 
@noindent
@cindex Verifying with -n option
Here we assume that you have installed cfengine under the directory
@file{/local/gnu/bin}.  By adding a header like this to the first line
of your program and making the file executable with the @code{chmod}
shell command, you can execute the program just by typing its
name---i.e.  without mentioning cfengine explicitly at all.

As a novice to cfengine, it is advisable to check all programs with the
@code{-n} option before trusting them to your system, at least until you
are familiar with the behaviour of cfengine.  This `safe' option allows
you to see what cfengine wants to do, without actually committing
yourself to doing it.


@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node CFINPUTS environment variable, What to aim for, Invoking cfengine, Getting started
@section CFINPUTS environment variable

Whenever cfengine looks for a file it asks a question: is the filename
an absolute name (that is a name which begins from @file{/} like
@code{/usr/file}), is it a file in the directory in which you invoke
cfengine or is it a file which should be searched for in a special
place?
@vindex -f option
@cindex CFINPUTS variable
@cindex Environment variable, CFINPUTS
@cindex File search paths
@cindex Path to input files

If you use an absolute filename either on the command line using
@code{-f} or in the @code{import} section of your program (a name which
begins with a slash '/'), then cfengine trusts the name of the file you
have given and treats it literally. If you specify the name of the
file as simple @samp{.} then cfengine reads its input from the
standard input.
@cindex STDIN, reading from
@cindex Piping input into cfengine

@cindex @file{cfengine.conf}
If you run cfengine without arguments (so that the default filename is
@file{cfengine.conf}) or you specify a file without a leading slash in
the @code{import} section, then the value of the environment variable
@code{CFINPUTS} is prepended to the start of the file name.  This allows
you to keep your configuration in a standard place, pointed to by
@code{CFINPUTS}.  For example:

@example
@cartouche

host# setenv CFINPUTS /usr/local/gnu/lib/cfengine/inputs

host# cfengine -f myfile

@end cartouche
@end example

@noindent 
In this example, cfengine tries to open 

@file{/usr/local/gnu/lib/cfengine/inputs/myfile}.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node What to aim for,  , CFINPUTS environment variable, Getting started
@section What to aim for

If you are a beginner to cfengine, you might not be certain exactly how
you want to use it. Here are some hints from Dr. Daystrom about how to
get things working quickly.

@itemize @bullet

@item
Run cfengine from cron every hour on all your systems. Be sure to
label long tasks, or tasks which do not need to be performed often
by a @emph{time class} which prevents it from being executed
all the time, @xref{Using cfengine as a front-end for cron}.

@emph{Running cfengine from cron means that it will be run
in parallel on your systems. Cfengine on one host does not
have to wait for cfengine on another host to complete.}

@item
Set up @code{cfd} on all your systems so that cfengine can be executed
remotely, so that you can immediately ``push" changes to all your
hosts with @code{cfrun}. Think carefully about whom you wish to give permission to run
cfengine from the net, @xref{Configuring cfd}. Set up you
@file{cfd.conf} file accordingly. You can also use this daemon to
grant access rights for remote file copying.

@emph{Cfrun polls all your hosts serially and gives you a concatenated
indexed list of problems on all hosts. The disadvantage with cfrun is
that each host has to wait its turn.}

@item
Don't forget to add @code{cfd} to the system startup scripts, or to @file{inittab}
so that it starts when you boot your system.

@item
Add @emph{all} your hosts to the @file{cfrun.hosts} file. It does not
matter that some may be master servers and others clients. The locking
mechanisms will protect you from silliness, @xref{Deadlocks and runaway
loops}. Cfengine will work it out. Cfrun allows you to remotely execute
cfengine on groups of hosts which satisfy a list of cfengine classes.

@end itemize

@noindent
When you have set up these components, you can sit back and edit the
configuration files and watch things being done.

@c **********************************************************************
@c CHAPTER
@c **********************************************************************


@node More advanced concepts, Global configurations, Getting started, Top
@chapter More advanced concepts

@menu
* Classes basics::              
* Variable substitution::       
* Defining classes::            making decisions
* The generic class any::       a wildcard
* Debugging tips::              nullifying classes
* Access control::              specifying user access to programs
* Wildcards in directory names::  multiple searches
* File sweeps::                 
* Log files::                   
* Quoted strings::              
* Regular expressions::         
* Iterating over lists::        
@end menu

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Classes basics, Variable substitution, More advanced concepts, More advanced concepts
@section Classes
@cindex Classes

The idea of classes is central to the operation of cfengine.  Saying
that cfengine is `class orientated' means that it doesn't make decisions
using @code{if}...@code{then}...@code{else} constructions the way other
languages do, but only carries out an action if the host running the
program is in the same class as the action itself.  To understand what
this means, imagine sorting through a list of all the hosts at your
site.  Imagine also that you are looking for the @emph{class} of hosts
which belong to the computing department, which run GNU/Linux operating
system and which have yellow spots! To figure out whether a particular
host satisfies all of these criteria you first delete all of the hosts
which are not GNU/Linux, then you delete all of the remaining ones which
don't belong to the computing department, then you delete all the
remaining ones which don't have yellow spots.  If you are on the
remaining list, then you are in the class of all
computer-science-Linux-yellow-spotted hosts and you can carry out the
action.

Cfengine works in this way, narrowing things down by asking if a host is
in several classes at the same time.  Although some information (like
the kind of operating system you are running) can be obtained directly,
clearly, to make this work we need to have lists of which hosts belong
to the computer department and which ones have yellow spots.

So how does this work in a cfengine program?  A program or configuration
script consists of a set of declarations for what we refer to as
@emph{actions} which are to be carried out only for certain classes of
host.  Any host can execute a particular program, but only certain
action are extracted --- namely those which refer to that particular
host.  This happens automatically because cfengine builds up a list of
the classes to which it belongs as it goes along, so it avoids having to
make many decisions over and over again.

By defining classes which classify the hosts on your network in some
easy to understand way, you can make a single action apply to many hosts
in one go -- i.e.  just the hosts you need.  You can make generic rules
for specific type of operating system, you can group together clusters
of workstations according to who will be using them and you can paint
yellow spots on them -- what ever works for you.

A @emph{cfengine action} looks like this:

@smallexample

@var{action-type}:

   @var{compound-class}::
     
       @var{declaration}
@end smallexample 

@noindent
A single class can be one of several things:

@itemize @bullet

@item The name of an operating system architecture e.g.  @code{ultrix}, @code{sun4} etc.
This is referred to henceforth as a @emph{hard class}.

@item The (unqualified) name of a particular host. If your system returns a fully
qualified domain name for your host, cfengine truncates it so as to unqualify
the name.

@item The name of a user-defined group of hosts.

@item A day of the week (in the form @code{Monday Tuesday Wednesday..}).

@item An hour of the day (in the form Hr00, Hr01 ... Hr23).

@item Minutes in the hour (in the form Min00, Min17 ... Min45).

@item A five minute interval in the hour (in the form Min00_05, Min05_10 ... Min55_00)

@item A day of the month (in the form Day1 ... Day31).

@item A month (in the form January, February, ... December).

@item A year (in the form Yr1997, Yr2001).

@item An arbitrary user-defined string.  @xref{addclasses,Runtime options}.

@end itemize

A compound class is a sequence of simple classes connected by dots or
`pipe' symbols (vertical bars).  For example:

@cindex Compound classes
@cindex Classes, compound
@smallexample

myclass.sun4.Monday::

sun4|ultrix|osf::

@end smallexample 
@noindent
A compound class evaluates to `true' if all of the individual classes
are separately true, thus in the above example the actions which follow
@code{compound_class::} are only carried out if the host concerned is in
@code{myclass}, is of type @code{sun4} and the day is Monday!
In the second example, the host parsing the file must be either of
type @code{sun4} @emph{or} @code{ultrix} @emph{or} @code{osf}.
In other words, compound classes support two operators: AND and OR,
written @samp{.} and @samp{|} respectively. Cfengine doesn't
care how many of these operators you use (since it skips over blank
class names), so you could write either

@smallexample

solaris|irix::

@end smallexample

@noindent
or

@smallexample

solaris||irix::

@end smallexample

@noindent
depending on your taste. On the other hand, the order in which cfengine
evaluates AND and OR operations @emph{does} matter, and the rule
is that AND takes priority over OR, so that @samp{.} binds classes
together tightly and all AND operations are evaluated before ORing
the final results together. This is the usual behaviour in programming
languages. You can use round parentheses in cfengine classes to
override these preferences. 

Cfengine allows you to define switch on and off dummy classes so that
you can use them to select certain subsets of action.  In particular,
note that by defining your own classes, using them to make compound
rules of this type, and then switching them on and off, you can also
switch on and off the corresponding actions in a controlled way.  The
command line options @code{-D} and @code{-N} can be used for this
purpose.  See also @ref{addclasses}.
@vindex -N option
@vindex -D option
@cindex Classes, defining and undefining

@cindex NOT operator
@cindex Logical NOT
@vindex !
@cindex !
A logical NOT operator has been added to allow you to exclude
certain specific hosts in a more flexible way. The logical NOT
operator is (as in C and C++) @samp{!}. For instance, the
following example would allow all hosts except for @code{myhost}:

@smallexample
   @var{action}:

    !myhost::

        @var{command}
@end smallexample

@noindent
and similarly, so allow all hosts in a user-defined group @code{mygroup},
@emph{except} for @code{specialhost}, you would write

@smallexample
   @var{action}:

    mygroup.!myhost::

        @var{command}
@end smallexample

@noindent
which reads `mygroup AND NOT myhost'. The NOT operator can also be
combined with OR. For instance

@smallexample

   @var{class1}|!@var{class2}
@end smallexample

@noindent
would select hosts which were either in class 1, or those
which were not in class 2.

Finally, there is a number of reserved classes.  The following are hard
classes for various operating system architectures.  They do not need to
be defined because each host knows what operating system it is running.
Thus the appropriate one of these will always be defined on each host.
Similarly the day of the week is clearly not open to definition, unless
you are running cfengine from outer space.  The reserved classes are:

@smallexample
ultrix, sun4, sun3, hpux, hpux10, aix, solaris, osf, irix4, irix, irix64
        freebsd, netbsd, bsd4_3, newsos, solarisx86, aos,
            nextstep, bsdos, linux, debian, cray
@end smallexample 

@noindent
If these classes are not sufficient to distinguish the hosts on
your network, cfengine provides more specific classes which
contain the name and release of the operating system. To find out
what these look like for your systems you can run cfengine in
`parse-only-verbose' mode:

@smallexample

  cfengine -p -v

@end smallexample
@noindent
and these will be displayed. For example, solaris 2.4 systems
generate the additional classes @code{sunos_5_4} and @code{sunos_sun4m},
@code{sunos_sun4m_5_4}.

Cfengine uses both the unqualified and fully host names as classes. Some
sites and operating systems use fully qualified names for their
hosts. i.e. @code{uname -n} returns to full domain qualified
hostname. This spoils the class matching algorithms for cfengine, so
cfengine automatically truncates names which contain a dot `.'  at the
first `.' it encounters. If your hostnames contain dots (which do not
refer to a domain name, then cfengine will be confused. The moral is:
don't have dots in your host names! @emph{NOTE: in order to ensure that
the fully qualified name of the host becomes a class you must define the
domain variable.} The dots in this string will be replaced by underscores.
@cindex Fully qualified names
@cindex Dots in hostnames
@cindex Host name gets truncated

In summary, the operator ordering in cfengine classes is as follows:
@cindex Operator ordering
@mbindex Brackets (parentheses) in classes.
@mbindex Parentheses in classes.

@table @samp

@item ()
Parentheses override everything.

@item !
The NOT operator binds tightest.

@item .
The AND operator binds more tightly than OR.

@item |
OR is the weakest operator.

@end table


@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Variable substitution, Defining classes, Classes basics, More advanced concepts
@section Variable substitution
@cindex Variable substitution
@cindex Variables, environment
@cindex Variables, cfengine
@cindex Environment variables
@vindex site
@vindex faculty
@vindex binserver
@vindex host
@vindex timezone
@vindex domain
@vindex sysadm

@cindex Variables and Macros
@cindex Macros
@cindex Environment variables

When you are building up a configuration file it is very useful to be
able to use variables.  If you can define your configuration in terms of
some key variables, it can be changed more easily later, it is more
transparent to the reader of the program and you can also choose to
define the variables differently on different types of system.  Another
way of saying this is that cfengine variables also belong to classes.
Cfengine makes use of variables in three ways.

@itemize @bullet
@item Environment variables from the shell
@item Special variables used in cfengine features
@item General macro-string substitution.
@end itemize

@noindent
Environment variables are fetched directly from the shell on whatever
system is running the program.  An example of a special variable is the
@code{domain} variable from the previous section.  Straightforward macro
substitution allows you to define a symbol name to be replaced by an
arbitrary text string.  All these definitions (apart from shell
environment variables, of course) are made in the control part of the
cfengine program:

@smallexample

control:

  myvar = ( /usr/local/mydir/lib/very/long/path )   # define macro

...

links:

  $(myvar) -> /another/directory

@end smallexample

@noindent
Here we define a macro called @code{myvar}, which is later used to
define the creation of a link.  As promised we can also define
class-dependent variables:

@smallexample

control:

  sun4:: myvar = ( sun )
  hpux:: myvar = ( HP )

@end smallexample


Cfengine gives you access to the shell environment variables and allows
you to define variables of your own.  It also keeps a few special
variables which affect the way in which cfengine works.  When cfengine
expands a variable it looks first at the name in its list of special
variables, then in the list of user-defined macros and finally in the
shell environment for a match.  If none of these are found it expands to
the empty string.

Variables are referred to in either of two different ways, depending on
your taste.  You can use the forms @code{$(variable)} or
@code{$@{variable@}}.  The variable in braces or parentheses can be the
name of any user defined macro, environment variable or one of the
following special internal variables.

@table @code

@item AllClasses
A long string in the form @samp{CFALLCLASSES=class1:class2...}. This variable
is a summary of all the defined classes at any given time. It is always
kept up to date so that scripts can make use of cfengine's class data.
@cindex CFALLCLASSES
@vindex CFALLCLASSES
@cindex Class data and scripts
@cindex Scripts, passing classes to

@item arch
The current detailed architecture string---an amalgamation of the
information from @emph{uname}. Non-definable.
@vindex $(arch)


@item binserver
The default server for binary data.  @xref{NFS resources}.
Non definable.
@vindex $(binserver) 

@item class
The currently defined system hard-class (e.g. @code{sun4}, @code{hpux}).
Non-definable.
@vindex $(class)

@item domain
The currently defined domain.
@vindex $(domain)

@item faculty
The faculty or site as defined in control (see site).
@vindex $(faculty)

@item fqhost
The fully qualified (DNS/BIND) hostname of the system, which
includes the domain name as well.
@vindex $(fqhost)

@item host
The hostname of the machine running the program.
@vindex $(host)

@item MaxCfengines
The maximum number of cfengines which should be allowed to
co-exist concurrently on the system. This can prevent excessive
load due to unintentional spamming in situations where several
cfengines are started independently. The default value is unlimited.
@vindex MaxCfengines

@item OutputPrefix
This quoted string can be used to change the default `cfengine:'
prefix on output lines to something else. You might wish to shorten
the string, or have a different prefix for different hosts. The value
in this variable is appended with the name of the host. The default is
equivalent to,
@smallexample
  OutputPrefix = ( "cfengine:$(host):")
@end smallexample
@vindex OutputPrefix

@item RepChar
The character value of the string used by the file repository in
constructing unique filenames from path names. This is the character which
replaces @samp{/} @xref{repchar}.
@vindex repchar

@item site
This variable is identical to @code{$(faculty)} and may be used interchangeably.
@vindex $(site) 

@item split
The character on which list variables are split @xref{split}.
@vindex split

@item sysadm
The name or mail address of the system administrator.
@vindex $(sysadm)

@item timezone
The current timezone as defined in @code{control}.
@vindex $(timezone)

@item UnderscoreClasses
If this is set to `on' cfengine uses hard-classes which begin with
an underscore, so as to avoid name collisions. See also @xref{Runtime Options}.
@vindex underscoreclasses
@cindex underscoreclasses
@cindex Name collision
@cindex Hostname collision
@cindex Hard class name collision
@vindex underscoreclasses
@end table

@noindent
These variables are kept special because they play a special role in
setting up a system configuration.  @xref{Global configurations}.  
You are encouraged to use them to define fully
generalized rules in your programs.  Variables can be used to advantage
in defining filenames, directory names and in passing arguments to shell
commands.  The judicious use of variables can reduce many definitions to
a single one if you plan carefully.

@cartouche

@emph{NOTE: the above control variables are not case sensitive, unlike
user macros, so you should not define your own macros with these names.}


@end cartouche

The following variables are also reserved and may be used to produce
troublesome special characters in strings.
@table @code

@item cr
Expands to the carriage-return character.
@vindex $(cr)

@item dblquote
Expands to a double quote @code{"}
@vindex $(dblquote)

@item dollar
Expands to @samp{$}.
@vindex $(dollar)

@item lf
Expands to a line-feed character (unix end of line).
@vindex $(lf)

@item n
Expands to a newline character.
@vindex $(n)


@item quote
Expands to a single quote @code{'}.
@vindex $(quote)


@item spc
Expands simply to a single space. This can be used to place spaces in
filenames etc.
@vindex $(spc)

@item tab
Expands to a single tab character.
@vindex $(tab)

@end table

@noindent
You can use variables in the following places:

@itemize @bullet
@item In any directory name.  The @code{$(binserver)} variable is not always appropriate in this context.  For instance
@end itemize

@smallexample

links:

  osf::
      /$(site)/$@{host@}/directory -> somefile

@end smallexample 

@itemize @bullet
@item In any quoted string.  @xref{shellcommands}.
@end itemize
@smallexample
shellcommands:

  any::

   "/bin/echo $(timezone) | /bin/mail $(sysadm)"
   '/bin/echo "double quotes!"'

@end smallexample 
@cindex Variables, using

@noindent
The latter possibility enables cfengine's variables to be passed
on to user-defined scripts.

@itemize @bullet
@item To define the values of options passed to various actions,
in the form @code{@var{option}=$(variable)}.
@end itemize


Variables can be defined differently under different classes by
preceding the definition with a class name.  For example:

@smallexample
control:

   sun4::  my_macro = ( User_string_1 )
   irix::  my_macro = ( User_string_2 )

@end smallexample 
@noindent
Here the value assigned to @code{$(my_macro)} depends on which of the
classes evaluates to true.  This feature can be used to good effect to
define the mail address of a suitable system administrator for different
groups of host.
@smallexample
control:

 physics::   sysadm = ( mark,fred )
 chemistry:: sysadm = ( localsys@@domain )

@end smallexample 
@vindex -a option
@cindex System administrator, name

@noindent
Note, incidentally, that the @samp{-a} option
can be used to print out the mail address of the system administrator
for any wrapper scripts.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Defining classes, The generic class any, Variable substitution, More advanced concepts
@section Defining classes and making exceptions
@cindex Exceptions
@cindex Excluding actions in a controlled way

Because cfengine works at a very high level, doing very many things for
very few lines of code it might seem that some flexibility is lost.
When we restrict certain actions to special classes it is occasionally
useful to be able to switch off classes temporarily so as to cancel the
special actions.

You can define classes of your own which can be switched on and off,
either on the command line or from the action sequence.  For example,
suppose we define a class @emph{include}.  We use @code{addclasses} to
do this.

@smallexample
addclasses = ( include othersymbols )
@end smallexample 

@noindent
The purpose of this
would be to allow certain `excludable actions' to be defined.  
Actions defined by

@smallexample

any.include::
               @var{actions}

@end smallexample 
@noindent
will normally be carried out, because we have defined @code{include} to
be true using @code{addclasses}.  But if cfengine is run in a restricted
mode, in which @code{include} is set to false, we can exclude these
actions.

So, by defining the symbol @code{include} to be false, you can exclude
all of the actions which have @code{include} as a member.  There are two
ways in which this can be done, one is to negate a class globally using

@example
@cartouche

cfengine -N include 

@end cartouche
@end example

@noindent
This undefines the class @code{include} for the entire duration of the
program.

Another way to specify actions is to use a class to select only a subset
of all the actions defined in the actionsequence.  You do this by adding
a class name to one on the actions in action sequence by using a dot
@samp{.} to separate the words.  In this case the symbol only evaluates
to `true' for the duration of the action to which it it attached.  Here
is an example:
@smallexample

  links.onlysome
  shellcommands.othersymbols.onlysome

@end smallexample 
@noindent
In the first case @emph{@code{onlysome} is defined to be true} while
this instance of @code{links} is executed.  That means that only actions
labelled with the class @code{onlysome} will be executed as a result of
that statement.  In the latter case, both @code{onlysome} and
@code{othersymbols} are defined to be true for the duration of
@code{shellcommands}.

This syntax would normally be used to omit certain time-consuming
actions, such as tidying all home directories.  Or perhaps to
synchronize certain actions which have to happen in a certain order.

For more advanced uses of cfengine you might want to be able to
define a class on the basis of the success or failure of a user-program,
a shell command or user script. Consider the following example

@smallexample

groups:

   have_cc = ( "/bin/test -f /usr/ucb/cc" "/bin/test -f /local/gnu/cc"  )

@end smallexample
@noindent
Note that as of version 1.4.0 of cfengine, you may use the word
@code{classes} as an alias for @code{groups}.  Whenever cfengine meets
an object in a class list or variable, which is surrounded by either
single, double quotes or reversed quotes, it attempts to execute the
string as a command passed to the Bourne shell. If the resulting command
has return code zero (proper exit) then the class on the left hand side
of the assignment (in this case @samp{have_cc}) will be true. If the
command returns any other value (an error number) the result is
false. Since groups are the logical OR of their members (it is
sufficient that one of the members matches the current system), the
class @samp{have_cc} will be defined above if either @file{/usr/ucb/cc}
or @file{/local/gnu/cc} exist, or both.
@cindex Classes based on shell commands
@cindex Shell commands which define classes
@cindex User programs which define classes
@mbindex Define classes based on result of user program

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node The generic class any, Debugging tips, Defining classes, More advanced concepts
@section The generic class @code{any}
@vindex any
@cindex Wildcard, any class
@cindex Class, generic any

The generic wildcard @code{any} may be used to stand for any class.
Thus instead of assigning actions for the class @code{sun4} only you
might define actions for any architecture by specifying:
@smallexample

  any::
        @var{actions}

@end smallexample

If you don't specify any class at all then cfengine assumes a default value of @code{any} for the
class.  

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Debugging tips, Access control, The generic class any, More advanced concepts
@section Debugging tips

A useful trick when debugging is to eliminate unwanted actions by
changing their class name.  Since cfengine assumes that any class it
does not understand is the name of some host, it will simply ignore
entries it does not recognize.  For example:

@smallexample
   myclass::
@end smallexample 

@noindent
can be changed to

@smallexample
   Xmyclass::
@end smallexample 

@noindent
Since @code{Xmyclass} no longer matches any defined classes, and is not
the name of any host it will simply be ignored.  The @code{-N} option
can also be used to the same effect.  @xref{Runtime Options}.
@vindex -N option
@cindex -N option
@cindex Annulling entries when debugging
@cindex Debugging, annulling entries

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Access control, Wildcards in directory names, Debugging tips, More advanced concepts
@section Access control

It is sometimes convenient to be able to restrict the access of a
program to a handful of users.  This can be done by adding an access
list to the @code{control:} section of your program.  For example,

@smallexample
control:
    ...
    access = ( mark root )

@end smallexample

@noindent
would cause cfengine to refuse to run the program for any other users
except mark and root.  Such a restriction would be useful, for instance,
if you intended to make set-user-id scripts but only wished certain
users to be able to run them.  If the access list is absent, all users
can execute the program.
@cindex Setuid scripts
@cindex Access control
@cindex Restricting access

Note: if you are running cfengine via the @code{cfrun} program
@cindex cfrun
then cfengine is always started with the same user identity as 
the cfd process on the remote host.
@cindex cfd and access keyword
Normally this is the root user identity. This means that
the access keyword will have no effect on the use of
the command @code{cfrun}.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Wildcards in directory names, File sweeps, Access control, More advanced concepts
@section Wildcards in directory names
@cindex Wildcards, in directory names
@cindex Directory Names, use of wildcards

In the two actions @code{files} and @code{tidy} you define directory
names at which file checking or tidying searches should start.  One
economical feature is that you can define a whole group of directories
at which identical searches should start in one fell swoop by making use
of @emph{wildcards}.  For example, the directory names

@smallexample
     /usr/*/*
     /bla/*/ab?/bla
@end smallexample 
@noindent
represent all of the @emph{directories} (and only directories) which
match the above wildcard strings.  Cfengine opens each matching
directory and iterates the action over all directories which match.

The symbol @samp{?} matches any single character, whereas @samp{*}
matches any number of characters, in accordance with shell
file-substitution wildcards.
@cindex Wildcards
@cindex Patterns

When this notation is used in directory names, it always defines the
starting point for a search.  It does not tell the command how to
search, only where to begin.  The @code{pattern} directive in
@code{tidy} can be used to specify patterns when tidying files and under
@code{files} all files are considered, @xref{tidy}, and @ref{files},
@ref{Recursion}.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node File sweeps, Log files, Wildcards in directory names, More advanced concepts
@section File sweeps

File sweeps are searches through a directory tree in which many files
are examined and considered for processing in some way.  There are many
instances where one uses cfengine to perform a file sweep.

@itemize @bullet

@item
As part of a @code{files} action, for checking access rights and ownership
of files.
@cindex  @code{files}, file sweeps

@item
As part of a @code{tidy} action, for checking files for deletion.
@cindex  @code{tidy}, file sweeps

@item
As part of a @code{copy} action, while recursively checking whether to
copy a file tree.
@cindex  @code{copy}, file sweeps

@end itemize
@noindent
The problem with file sweeps is that they can be too sweeping! Often you
are not interested in examining every single file in a file tree. You might
wish to perform a search

@itemize @bullet

@item
excluding certain named directories and their subdirectories, @xref{ignore}.

@item
excluding certain files and directories matching a specific pattern.

@item
including only a subset of files matching specific patterns.

@end itemize
@noindent
The tidy action is slightly different in this respect, since it
always expects to match a specific pattern. One is generally not interested
in a search which deletes everything except for a named pattern: this
would be too dangerous. For this reason, the syntax of @code{tidy}
is different and is documented in the section on tidying, @xref{tidy}.

For file sweeps within  @code{files} and  @code{copy} you can specify
specific search parameters using the keywords @code{include=}
and @code{exclude=}. 
@cindex  @code{include=}
@cindex  @code{exclude=}
@vindex  @code{include=}
@vindex  @code{exclude=}
For example,
@smallexample
files:

   /usr/local/bin m=0755 exclude=*.ps action=fixall

@end smallexample
@noindent
In this example cfengine searches the entire file tree (omitting
any directories listed in the ignore-list, @xref{ignore}) and omitting
any files ending in the extension @file{.ps}.

Specifying the  @code{include=} keyword is slightly different since it
automatically restricts the search to only named patterns, whenever
you have one or more instances of it. If you include patterns in this
way, cfengine ignores any files which do not match the given patterns.
It also ignores any patterns which you have specified in the global
ignore-list as well as patterns excluded with   @code{exclude=@var{pattern}}.
In other words, exclusions always override inclusions.

If you exclude a pattern or a directory and wish to treat it in
some special way, you need to code an explicit check for that pattern
as a separate entity. For example, to handle the exluded  @file{.ps}
files above, you would need to code something like this:
@smallexample
files:

   /usr/local/bin m=0644 include=*.ps action=fixall

@end smallexample

Note: don't be tempted to enclose your wildcards in quotes. The quotes
will be treated literally and the pattern might not match the way you
would expect. 
@cindex exclude=, problems

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Log files, Quoted strings, File sweeps, More advanced concepts
@section Log files written by cfengine
@cindex Log files
@cindex .cfengine.rm
@cindex /etc/cfengine/cfengine.log
@cindex /var/log/cfengine/cfengine.log

Cfengine keeps two kinds of log-file privately and it allows you to log
its activity to syslog.  Syslog logging may be switched on with the
@code{Syslog} variable, @xref{Syslog}.

The first log cfengine keeps is for every user
(every subdirectory of a home directory filesystem).  A file
@code{~/.cfengine.rm} keeps a list of all the files which were deleted
during the last pass of the @code{tidy} function.  This is useful for
users who want to know files have been removed without their blessing.
This helps to identify what is happening on the system in case of
accidents.

@vindex /etc/cfengine/cfengine.log
Another file is built when cfengine searches through file trees in the
@code{files} action.  This is a list of all programs which are setuid
root, or setgid root.  Since such files are a potential security risk,
cfengine always prints a warning when it encounters a new one (one which
is not already in its list).  This allows the system administrator to
keep a watchful eye over new programs which appear and give users root
access.  The cfengine log is called @code{/etc/cfengine/cfengine.log}.  The file
is not readable for general users.
@cindex setuid root log
@cindex setgid root log


@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Quoted strings, Regular expressions, Log files, More advanced concepts
@section Quoted strings

In several cfengine commands, you use quoted strings to define a quantity
of text which may contain spaces. For example

@smallexample

control:

  macro = ( "mycommand" )

editfiles:

  @{ $(HOME)/myfile

   AppendIfNoSuchLine 'This text contains space'
  @}

@end smallexample

@noindent
In each case you may use any one of the three types of quote marks in
order to delimit strings,

@smallexample

  ' @var{or} " @var{or} `

@end smallexample

If you choose, say @code{"}, then you may not use this symbol within the
string itself. The same goes for the other types of string delimiters.
Unlike the shell, cfengine treats these three delimiters in precisely
the same way. There is no difference between them.
@cindex Strings
@cindex Quoting strings
@vindex "
@vindex '
@vindex `
@mbindex How do I quote quotes?
If you need to quote a quoted string, then you should choose a delimiter
which does not conflict with the substring.

Note that you can use special variables for certain symbols in a string
@xref{Variable substitution}.



@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Regular expressions, Iterating over lists, Quoted strings, More advanced concepts
@section Regular expressions

Regular expressions can be used in cfengine in connection with
@code{editfiles} and @code{processes} to search for lines matching
certain expressions.  A regular expression is a generalized wildcard. In
cfengine wildcards, you can use the characters '*' and '?' to match any
character or number of characters.  Regular expressions are more
complicated than wildcards, but have far more flexibility.

@emph{NOTE: the special characters @samp{*} and @samp{?} 
used in wildcards do not have the
same meanings as regular expressions!}.

Some regular expressions match only a single string. For example, every
string which contains no special characters is a regular expression
which matches only a string identical to itself. Thus the regular
expression @samp{cfengine} would match only the string "cfengine", not
"Cfengine" or "cfengin" etc.  Other regular expressions could match more
general strings. For instance, the regular expression @samp{c*} matches
any number of c's (including none). Thus this expression would match the
empty string, "c", "cccc", "ccccccccc", but not "cccx".

Here is a list of regular expression special characters and operators.

@table @samp

@item \
The backslash character normally has a special purpose: either to
introduce a special command, or to tell the expression interpreter that
the next character is not to be treated as a special character.
The backslash character stands for itself only when protected by square
brackets @code{[\]} or quoted with a backslash itself @samp{\\}.

@item \b
Matches word boundary operator.

@item \B
Match within a word (operator).

@item \<
Match beginning of word.

@item \>
Match end of word.

@item \w
Match a character which can be part of a word.

@item \W
Match a character which cannot be part of a word.

@item @var{any character}
Matches itself.

@item .
Matches any character

@item *
Match zero or more instances of the previous object. e.g. @samp{c*}.
If no object precedes it, it represents a literal asterisk.

@item +
Match one or more instances of the preceding object.

@item ?
Match zero or one instance of the preceding object.

@item @{ @}
Number of matches operator. @samp{@{5@}} would  match exactly 5
instances of the previous object. @samp{@{6,@}} would match at least
6 instances of the previous object. @samp{@{7,12@}} would match at least
7 instances of, but no more than 12 instances of the preceding object.
Clearly the first number must be less than the second to make a valid
search expression.

@item |
The logical OR operator, OR's any two regular expressions.

@item [@var{list}]
Defines a list of characters which are to be considered as a single
object (ORed). e.g. @samp{[a-z]} matches any character in the range a to
z, @samp{abcd} matches either a, b, c or d.  Most characters are
ordinary inside a list, but there are some exceptions: @samp{]} ends the
list unless it is the first item, @samp{\} quotes the next character,
@samp{[:} and @samp{:]} define a character class operator (see below),
and @samp{-} represents a range of characters unless it is the first
or last character in the list.

@item [^@var{list}]
Defines a list of characters which are NOT to be matched. i.e.
match any character except those in the list.

@item @samp{[:@var{class}:]}
Defines a class of characters, using the ctype-library.
  @table @code

  @item alnum
  Alpha numeric character

  @item alpha
  An alphabetic character

  @item blank
  A space or a TAB

  @item cntrl
  A control character.

  @item digit
  0-9

  @item graph
  same as print, without space

  @item lower
  a lower case letter

  @item print
  printable characters (non control characters)

  @item punct
  neither control nor alphanumeric symbols

  @item space
  space, carriage return, line-feed, vertical tab and form-feed.

  @item upper
  upper case letter

  @item xdigit
  a hexadecimal digit 0-9, a-f

  @end table

@item @samp{(..)}
Groups together any number of operators.

@item \@var{digit}
Back-reference operator (refer to the GNU regex documentation).

@item ^
Match start of a line.

@item $
Match the end of a line.

@end table

@noindent
Here is a few examples. Remember that some commands look for
a regular expression match of part of a string, while others
require a match of the entire string @xref{editfiles}.

@smallexample

^#        match string beginning with the # symbol
^[^#]      match string not beginning with the # symbol
^[A-Z].+  match a string beginning with an uppercase letter
          followed by at least one other character  

@end smallexample


@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Iterating over lists,  , Regular expressions, More advanced concepts
@section Iterating over lists

Shell list variables are normally defined by joining together a list of
directories using a concatenation character such as @samp{:}. A typical
example of this is the PATH variable:

@example

PATH=/usr/bin:/usr/local/bin:/usr/sbin

@end example

It is convenient to be able to use such variables to force cfengine to
iterative over a list. This gives us a compact way of writing repeated
operations and it allows a simple method of communication with the shell
environment. For security reasons, iteration is supported only in the
following contexts:


@itemize @bullet

@item
in the `to' field of a multiple link action,

@item
in the `from' field of a copy action,

@item
in the directory field of a tidy action,

@item
in the directory field of the files action,

@item
in the ignore action,

@item
in a shell command.

@end itemize

This typically allows communication with PATH-like 
environment variables in the shell.
@cindex split
@cindex Iteration over lists
@mbindex Iterating over lists
@vindex split

In these contexts, any variable which has the form of
a list joined together by colons will be iterated over
at compilation time. Note that you can change the value
of the list separator using the @code{split} variable
in the control section of the program @xref{split}.

For example, to link all of the binary files in the PATH
environment variable to a single directory, tidying
dead links in the process, you would
write

@smallexample

control:

  actionsequence = ( links tidy )

links:

  /allbin +> $(PATH)

tidy:

  # Hopefully no-match matches nothing

  /allbin pattern=no-match age=0 links=tidy

@end smallexample

@noindent
@var{no-match} is not a reserved word in cfengine, this is
just a string you do not expect to match any file.

Alternatively, you might want to define an internal list using
a space as a separator:
@mbindex split, using a space

@smallexample

control:

   split = ( " " )

   mylist = ( "mark ricky bad-dude" )

tidy:

   /mnt/home1/$(mylist) pattern=*.cfsaved age=1

@end smallexample

@noindent
This example iterates the tidy action over the directories @file{/mnt/home1/mark},
@file{/mnt/home1/ricky} and @file{/mnt/home1/bad-dude}. 

The number of list variables in any path or filename should normally be
restricted to one or two, since the haphazard combination of two lists
will seldom lead to any meaningful pattern.  The only obvious exception
is perhaps to iterate over a common set of child-directories like
@file{bin}, @file{lib} etc in several different package directories.
@cindex Multiple package configuration
@cindex Package configuration, multiple
@mbindex Configure multiple packages


@c **********************************************************************
@c CHAPTER
@c **********************************************************************

@node Global configurations, Using cfengine as a front-end for cron, More advanced concepts, Top
@chapter Designing a global system configuration

This chapter is about building strategies for putting together a
site configuration for your entire network.

@menu
* General considerations::      
* Using netgroups::             a common database for classes
* Files and links::             
* Copying files::               
* Managing processes::          
* NFS resources::               the cfengine model
* Using the automounter::       
* Editing files::               
* Disabling and the file repository::  
* Running user scripts::        
* Compressing logs::            
* ACLs::                        
@end menu

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node General considerations, Using netgroups, Global configurations, Global configurations
@section General considerations

In order to use any system administration tool successfully, you have
to make peace with your system by deciding exactly what you expect and
what you are willing to do to achieve the results. You need to decide
what you will consider to be acceptable and what is to be considered
completely untenable. You need to make these decisions because otherwise
you will only be confused later when things don't go the way you expected.
@cindex System policy
@cindex Policy for running the system

Experience shows that the most successful policies for automation involve
keeping everything as simple as possible. The more uniform or alike your
machines are, the easier they are to run and the happier users are.
Sometimes people claim that they need such great flexibility that all
their machines should be different. This belief tends to be inversely
proportional to the number of machines they run and generally only
applies to very special development environments!  Usually you will only
need one or to machines to be special and most can be made very similar.

Site configuration is about sharing and controlling resources.  The
resources include disks (filespace), files, data, programs, passwords
and physical machines. Before planning your sitewide configuration you
should spend some time deciding how you would like things to work.

In the remaining parts of this chapter, you will find some hints
and tips about how to proceed, but remember that when push comes
to shove, you must make your own choices.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Using netgroups, Files and links, General considerations, Global configurations
@section Using netgroups
@cindex netgroups
@cindex NIS
@vindex /etc/exports
@cindex Exporting filesystems

If you use the network information service (NIS) on your local network
then you may already have defined @emph{netgroups} consisting of lists
of hosts which belong to specific owners at your site.  If you have,
then you can use these groups within cfengine.  This means that you can
use the same groups in the @code{/etc/exports} file as you use to define
the mount groups and classes.  @xref{groups}.

A netgroup is a list of hostnames or user names which are registered in
the network information service (NIS) database under a specific name.
In our case we shall only be interested in lists of hostnames.

To make a netgroup you need to define a list in the file
@code{/etc/netgroup} on your NIS server.  If you are not the NIS
administrator, you will have to ask to have a netgroup installed.  The
form of a netgroup list of hosts is:

@smallexample

mylist-name      (host1,,) (host2,,) (host3,,) (host4,,)

norway-sun4-host (saga,,) (tor,,) (odin,,)
foes-linux-hosts (borg,,)

@end smallexample 
@noindent
Each list item has three entries, but only the first is relevant for a
host list.  See the manual pages on netgroups for a full explanation of
the meaning of these fields.

The usefulness of netgroups is that they can be used to stand for a list
of hostnames in system files like @file{/etc/exports}.  This compresses
the amount of text in this file from a long list to a single name.  It
also means that if you use the same list of hosts from a netgroup inside
cfengine when defining groups and classes, you can be sure that you are
always using the same list.  In particular it means that you don't have
to update multiple copies of a list of hosts.

The netgroups can now be used in cfengine programs by using the @code{+}
or @code{@@+} symbols in the @code{groups} section.  @xref{groups}.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Files and links, Copying files, Using netgroups, Global configurations
@section Files and links

File and link management takes several forms.
Actions are divided into three categories called
@code{files}, @code{tidy} and @code{links}. The first of
these is used to check the existence of, the ownership
and permissions of files. The second concerns the systematic
deletion of garbage files. The third is a link manager
which tests, makes and destroys links. The monitoring
of file access bits and ownership can be set up for
individual files and for directory trees, with controlled
recursion. Files which do not meet the specified criteria
can be `fixed' ---i.e. automatically set to the correct
permissions, or can simply be brought to the attention of
the system administrator by a warning.
The syntax of such a command is as follows:

@smallexample

files:

  @var{class}::

    /@var{path} mode=@var{mode} owner=@var{owner} group=@var{group}

         recurse=@var{no-of-levels} action=@var{action}

@end smallexample

@noindent
The directory or file name is the point at which cfengine
begins looking for files. From this point the search for files
proceeds recursively into subdirectories with a maximum limit set by
the @code{recurse} directive, and various options for dealing with
symbolic links and device boundaries. The mode-string defines the
allowed file-mode (by analogy with @samp{chmod}) and the owner and group
may specify lists of acceptable user-ids and group-ids. The action
taken in response to a file which does not meet acceptable criteria is
specified in the action directive. It includes warning about or
directly fixing all files, or plain files or directories only. Safe
defaults exist for these directives so that in practice they may be
treated as options.

For example,
@smallexample
files:

  any::
       /usr/*/bin mode=a+rx,o-w own=root r=inf act=fixall

@end smallexample

@noindent
which (in abbreviated form) would check recursively all files and
directories starting from directories matching the wildcard 
(e.g. @file{/usr/local/bin}, @file{/usr/ucb/bin}).  By default, @code{fixall}
causes the permissions and ownership of the files to be fixed without
further warning. 

One problem with symbolic links is that the files they point to can
get deleted leaving a `hanging pointer'. Since cfengine can make
many hundreds of links without any effort, there is the danger that, in time,
the system could become full of links which don't point anywhere. To
combat this problem, you can set the option @code{links=tidy} in the files
section. If this is set, cfengine will remove any symbolic links which
do not point to existing files @xref{files}.

The creation of symbolic links is illustrated in figure 1 and
the checking algorithm was discussed in section 2. In addition to
the creation of single links, one may also specify the creation of
multiple links with a single command. The command

@smallexample
links:

   binaryhost::

      /local/elm/bin +> /local/bin

@end smallexample

@noindent
links all of the files in @file{/local/elm/bin} to corresponding files
in @file{/local/bin}. This provides, amongst other things, one simple
way of installing software packages in regular `bin' directories without
controlling users' PATH variable. A further facility makes use of
cfengine's knowledge of available (mounted) binary resources to search
for matches to specific links. Readers are referred to the full
documentation concerning this feature.

The need to tidy junk files has become increasingly evident during the
history of cfengine. Files build up quickly in areas like @file{/tmp},
@file{/var/tmp}. Many users use these areas for receiving large
ftp-files so that their disk usage will not be noticed!  To give
another example, just in the last few months the arrival of
netscape World Wide Web client, with its caching
facilities, has flooded hard-disks at Oslo with hundreds of megabytes of
WWW files. In addition the regular appearance of @file{core} files@footnote{On
some systems, core dumps cannot be switched off!}
and compilation by-products (@samp{.o} files and @samp{.log} files
etc.) fills disks with large files which many users do not understand.
The problem is easily remedied by a few lines in the cfengine
configuration. Files can be deleted if they have not been accessed for
n-days. Recursive searches are both possible and highly practical
here. In following example:

@smallexample
tidy:

   AllHomeServers::

      home                 pattern=core       r=inf age=0
      home/.wastebacket    pattern=*          r=inf age=14
      home/.netscape-cache pattern=cache????* r=inf age=2
      home/.MCOM-cache     pattern=cache????* r=inf age=2
      home/.netscape       pattern=cache????*  r=inf age=2

@end smallexample

@noindent
all hosts in the group @samp{AllHomeServers} are instructed to
iterate over all users' home directories (using the wildcard
@code{home}) and look for files matching special patterns.
Cfengine tests the @emph{access time} of files and deletes
only files older than the specified limits. Hence all core
files, in this example, are deleted immediately, whereas files in the
subdirectory @file{.wastebasket} are deleted
only after they have lain there untouched for 14 days, and so on.

@cindex Tidying files
@cindex Backup policy

As a system administrator you should, of course, exercise great caution
when making rules which can delete users' files.  A single slip of the
hand can result in a rule which will irretrievably delete files.

When making a `tidy' strategy you should probably coordinate with your
backup policy.  You should not delete files until after you have taken a
backup, so that --- if the worst should happen --- you are covered
against possible accidents.

Cfengine helps to some extent to keep track of what files it deletes.
When tidying users' home directories it creates a log file of all files
which were deleted on the last tidy operation.  This log is called
@code{~/.cfengine.rm}.

You might consider tidying certain files only once a week, in which case
a command such as

@smallexample

tidy:

   AllHomeServers.Sunday::

       @var{files to tidy}

@end smallexample 
@noindent
could be useful.  Nonsense files, such as `core' files could be tidied every night.

@cindex core files, caution!
@emph{NOTE! Be careful when telling cfengine to delete core files.  If
you write a wildcard like @code{core*}, then you could risk deleting
important system files such as @code{core.h}.}


@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Copying files, Managing processes, Files and links, Global configurations
@section Copying files

The administration of a system often requires the copying of files. The
reason for this is usually that we would like to distribute a copy of a
particular file, from some master location and ensure that all of the
copies are up to date. Another use for this is to install software from
one directory (perhaps on a CD ROM) to another.

Cfengine helps this process by allowing you to copy a single file or a
file tree, from one directory to another, perhaps checking the
permissions and owners of a file to adjust the copies in some special
way. The files are checked by cfengine using one of two methods.

@itemize @bullet

@item
A date-stamp comparison with a master file, using last-change times, can
be used to tell cfengine to recopy a file from the master if the master
file is newer than the copy.

@item
A checksum can be computed for each file and compared with one for
the master file. If the contents of the copy file differs in any way from
the master, the file will be re-copied.

@end itemize

@noindent
Cfengine allows you to do the following

@itemize @bullet

@item
Copy a single file to another file in a different location, perhaps with a
new name, new permissions and a different owner.

@item
Copy a single file to all users on the system, changing the owner of the
file for each user automatically. (This could be used to distribute and
update standard setup files.)

@item
Recursively copy an entire file tree, omitting files which match a list
of wildcard-patterns, or linking certain files instead of copying.

@end itemize
@noindent
You can find out more about copying in the reference section @xref{copy}.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Managing processes, NFS resources, Copying files, Global configurations
@section Managing processes

Cfengine allows you to check for the existence of processes on your
system, send those processes signals (such as kill) and perhaps
restart those processes. Typical applications for this are sending
@file{cron} and @file{inetd} the HUP signal, after editing their
configuration files, or killing unwanted processes (such as user
programs which hog the system at peak usage times).

You can read more about this in the reference section @xref{processes}.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node NFS resources, Using the automounter, Managing processes, Global configurations
@section Cfengine's model for NFS-mounted filesystems
@cindex cfengine model
@cindex NFS mounted filesystems

Most of the filesystems that you will want to make available across the
network are going to fall into one of two categories.  In cfengine
parlance these are called @emph{home directories} and @emph{binary
directories}.  A home directory is a place where users' login
directories are kept.  This is traditionally a directory called
@file{/home} or @file{/users} or some subdirectory of these.  A binary
directory is a place where compiled software is kept.  Such files (which
do not belong to the pure operating system release) are often placed in
a directory called @file{/usr/local} or simply @file{/local}.

In this chapter we shall consider a scheme for using cfengine to make NFS filesystem management
quite painless.

@menu
* NFS filesystem resources::    a conceptual introduction
* Unique filesystem mountpoints::  avoiding collisions
* How does it work?::           
* Special variables::           binserver etc.
* Mount example::               example program
@end menu

@c .....................................................
@c SUBSECTION
@c .....................................................

@node NFS filesystem resources, Unique filesystem mountpoints, NFS resources, NFS resources
@subsection NFS filesystem resources
@cindex NFS resources

Using the Network File System (NFS) in a large workstation environment
requires a bit of planning.  The idea of NFS is to share files on one
host with other hosts.  In most cases, filesystems to be shared across
the network fall into two categories: @emph{binary} filesystems (those
which contain compiled software) and @emph{user} or @emph{home}
filesystems (which contain users' login areas).

The most simple minded way to share resources would be to mount every
resource (each available NFS filesystem) onto every host.  To avoid
collisions, each filesystem would have to have a unique name.  This is
one possibility, but not a very intelligent one.  As experienced users
will realize, cross-mounting too many NFS filesystems is a recipe for
all kinds of trouble.

@cindex Binary server
@cindex Home server
Cfengine offers a simple model which can help you pick out only the
resources you need from the list of NFS filesystems.  It will then mount
them automatically and edit the appropriate filesystem tables.  It does
this by defining classes of hosts.  For instance --- you really don't
need to mount a binary filesystem for an @code{ultrix} system onto an
@code{HPUX} system.  There would be no point --- binary resources are
@emph{architecture} or @emph{hard-class dependent}.  But home directories
are architecture independent.

Cfengine lets you to define a list of allowed servers for various hosts
so that only filesystems from the servers will be considered for mounting!

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Unique filesystem mountpoints, How does it work?, NFS filesystem resources, NFS resources
@subsection Unique filesystem mountpoints
@cindex Mount points
@cindex Naming convention

The first step towards treating NFS filesystems as network resources is
to invent a naming scheme so that every filesystem has a unique name on
which it can be mounted.  If we don't sort this out now, we could find
two or more hosts with a filesystem called @code{/usr/local}, both of
which we might like to mount since they contain different software.

A simple but extremely useful naming scheme is the following.
@footnote{This unique naming scheme was suggested to me originally by
Knut Borge at USIT of the University of Oslo.}  If you don't like this
scheme you can invent your own, but the remainder of the text will
encourage you to use this one.  If you follow this scheme, exactly
as described here, you will never have any problems with mount points.
We shall describe the scheme in detail below. Here are some points
to digest:

@itemize @bullet

@item
When mounting a remote filesystem on your local system, the local and
remote directories should always have exactly the same name.

@item
The name of every filesystem mountpoint should be unique and tell
you something meaningful about where it is located and
what its function is.

@item
You can always make links from special unique names to more general
names like @file{/usr/local}. If you this involves compiled software and
you do this on one host, you should do it on others which are of the
same type.

@item
It doesn't matter whether software compiles in the path names
of special directories into software as long as you follow
the points above.

@end itemize

@noindent
Each filesystem is given a directory
name composed of three parts:

@smallexample

/site/host/contents

@end smallexample 
@noindent
The first directory (which only exists to create a suitable mountpoint)
is the name of your local site.  If you are a physics department at a
university (with a separate setup) you could call this `physics'.  It
could be your company name or whatever.  The second piece is the name of
the host to which the disk space is physically attached.  The final
piece is the name of the filesystem.  Here are some typical examples:

@smallexample
/physics/einstein/local    # /usr/local for einstein@@physics
/physics/newton/u1         # user partition 1 for newton@@physics
@end smallexample 
@noindent
On the machines which are home to the `local' partition, it is better to
make a link to @code{/usr/local} than call the filesystem
@code{/usr/local} directly.  This is because it makes the procedure of
organizing the entire network much clearer.

It is worth noting that, when you ask cfengine to mount such a resource,
it will automatically make the mount directory and can easily be asked
to make a link to @code{/usr/local}, so this small amount of extra work
is really no work at all.

The whole naming convention is compactly summarized by defining a mount
point variable.  @xref{mountpattern}.  With the present scheme, this can
be defined as

@smallexample
mountpattern = ( /$(site)/$(host) )
@end smallexample 
@noindent
so that it evaluates to the name of the host executing the file
regardless of who that may be.  This variable is used together with the
@code{homepattern} pattern variable, which is used to distinguish
between home directories and binary resources.  @xref{homepattern}.  You
can think of this as being part of the naming convention.  In this text,
we use the convention @code{u1 u2 u3...} for home disks.  You could
equally well use @code{home1 home2...} etc.  As long as the name is
unique, it doesn't matter.

The full list of named resources should now be listed in the
@code{mountables} list, which is simply a list of all the resources
available for mounting on the network.  @xref{mountables}.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node How does it work?, Special variables, Unique filesystem mountpoints, NFS resources
@subsection How does it work?
@cindex Binary servers, declaring
@cindex Home servers, declaring
@cindex cfengine model, how it works

Once you have defined your unique names, how does cfengine know what to
mount? The idea is now to define a list of servers for each class of
hosts.  @xref{binservers,homeservers}.

Suppose we make a @code{binserver} declaration:

@smallexample

binservers:

  mygroup.sun4::

     einstein
     newton

@end smallexample 

@noindent
This would tell cfengine that it should mount all binary resources from
hosts @code{einstein} or @code{newton} onto any host of type @code{sun4}
in the group @code{mygroup}.  Every filesystem which is listed in
@code{mountables} and is not a home directory will be mounted.
@xref{mountables}.

Home directories and binary resources are kept separate automatically by
cfengine, because a home directory is one whose contents-name matches
the @code{homepattern} pattern variable.  @xref{Unique filesystem
mountpoints}.

A @code{homeserver} declaration:


@smallexample

homeservers:

  mygroup::
   
     einstein
     newton
     schwinger
     feynman
 
@end smallexample 

@noindent
would correspondingly mean mount all the home directory resources on the
hosts in the list on all hosts in the group @code{mygroup}.  Clearly it
is unnecessary to distinguish between the architecture platform types of
the actual servers for user directories.

In each case, cfengine will mount filesystems, make the appropriate
directories for the mount point and edit the filesystem table.
@xref{actionsequence}.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Special variables, Mount example, How does it work?, NFS resources
@subsection Special variables
@cindex Linking to binservers
@cindex Special variables
@cindex Variables, cfengine model
@vindex binserver

Once you have mounted a resource on a unique directory, you have access
to all of the relevant filesystems on your network --- but you really
wanted the `local' filesystem to be mounted on @code{/usr/local}.  All
you need do now is to make a link:

@smallexample

links:

  any::

      /usr/local  -> /$(site)/$(binserver)/local

@end smallexample 

@noindent
The meaning of this is that, on any host, the directory
@code{/usr/local} should be a link to the `nearest' binary server's
`local' resource.  The @code{$(binserver)} variable can in principle
expand to any binary server in the list.  In practice, cfengine goes
through the list in order and picks the first filesystem resource which
matches.

Could this lead to a collision? Suppose we are on the host `einstein'
and we execute the above command.  The host `einstein' has a filesystem
@code{/physics/einstein/local} on its local disk --- it is in fact the
binary server for the network, so it certainly doesn't need to mount any
NFS filesystems.  But this is no problem because cfengine automatically
treats @code{$(host)} as the highest priority binary server for any
host.  That means that if you have a local filesystem, it will always
have priority.

@cindex Binary server, matching
@cindex binserver variable and actionsequence
@vindex binserver
In contrast, if the host `schwinger' ran the command above, it would
find no local filesystem called @code{/physics/schwinger/local}, so it
would go along the list of defined binary servers, find `einstein' and
try again.  It will succeed in finding `einstein' @emph{provided all the
binary servers were mounted before the link command is executed}.  This
means that you should structure the @code{actionsequence} so that all
filesystems are mounted before any links are made.

With a little practice, the cfengine model can lead to an enormous
simplification of the issue of NFS-mountable resources.

@cindex Exporting filesystems
NOTE: cfengine does not try to export filesystems, only mount already
exported filesystems.  If you want to automate this procedure also, you
can use the @code{editfiles} facility to add entries to
@file{/etc/exports} @xref{editfiles}.  In practice this is very
difficult to do and perhaps not desirable.

@node Mount example,  , Special variables, NFS resources
@subsection Example programs for mounting resources


Let's write a very simple configuration for a network with only one
server called hal, where all the hosts are of the same operating system
type.  In such an example we can avoid using classes altogether.

@smallexample

control:

  site   = ( univ )
  domain = ( univ.edu )

  actionsequence =
     (
     mountall
     mountinfo
     addmounts
     mountall
     links
     )

binservers:

   hal

homeservers:

   hal

mailserver:

   hal:/var/spool/mail

mountables:

   hal:/univ/home1
   hal:/univ/home2
   hal:/univ/local

links:

   /usr/local -> /univ/local

@end smallexample

In this example, we have only one type of host so the configuration is
the same for each of them: no class references are required.  If we look
through the action sequence we see that the program first mounts all the
filesystems which are already defined on each host.  It does this to be
sure that everything which is already set up to be mounted is mounted.
Let's assume that there are no problems with this.

The next thing that happens is that @code{mountinfo} builds a list of
the filesystems which each host has successfully mounted.  Then by
calling @code{addmounts} we ask cfengine to check whether the host is
missing any filesystems.  What happens is that cfengine first looks to
see what servers are defined for each host.  In this case all hosts on
the network have only one server: hal.  Hal is defined as a server for
both binary data and `home' data --- i.e.  users' home directories.  The
list @code{mountables} tells cfengine what filesystems are available
over the network for the server hal.  There are three filesystems which
can be mounted, called @file{/univ/home1}, @file{/univ/home2} and
@file{/univ/local}.  Cfengine checks to see whether each of these
filesystems is mounted and, if not, it builds the necessary directories,
edits the necessary files and mounts the filesystems.

Finally we come to @code{links} in the action sequence.  This tells
cfengine to look at the defined links.  There is one link defined: a
link from @file{/usr/local} to the mounted filesystem
@file{/univ/local}.  Cfengine checks and tries to make the link if
necessary.  If all goes well, each host on the network should now have
at least three filesystems mounted and a link from @file{/usr/local} to
@file{/univ/local}.


Here is another simple example program for checking and automatically
mounting an NFS based @code{/usr/local} and all home directories onto
all hosts on a small network.  Here we have several servers and must
therefore use some classes.

@smallexample
#
#  Mounts
#


control: 

   site      = ( mysite )
   domain    = ( mysite.country ) 
   sysadm    = ( mark ) 
   netmask   = ( 255.255.255.0 )

   actionsequence = 
      (
      mountall
      mountinfo
      addmounts
      mountall
      links
      )

   mountpattern = ( /$(site)/$(host) )
   homepattern   = ( u? )                # u1 u2 u3 etc..

groups:

   MyGroup =
      (
      host1
      host2
      binserver1
      binserver2
      )

######################################################################

homeservers:

   MyGroup:: host1


binservers:

   MyGroup.sun4::   server1
   MyGroup.ultrix:: server2

mailserver:

   host1:/usr/spool/mail

mountables:

   host1:/mysite/host1/u1
   host1:/mysite/host1/u2
   server1:/mysite/server1/local
   server2:/mysite/server2/local


##########################################################################

links:

      /usr/local  -> /$@{site@}/$@{binserver@}/local

@end smallexample 

Let's suppose we run this program on host2 which is an ultrix machine.
This host belongs to the class @code{mygroup} and the hard-class
@code{ultrix}.  This tells us that its homeserver is host1, its binary
server is server2 and its mailserver is host1.  Moreover, since the
homepattern matches any filesystem ending in u-something, it recognizes
the two home directories in the mountables list --- and therefore the
two binary directories also.

The action sequence starts by mounting all of the filesystems currently
in the filesystem table @file{/etc/fstab}.  It then scans the list of
mounted filesystems to find out what is actually mounted.  Since the
homeserver is host1, we know that our host has to mount all
home-filesystems from this server, so it checks for
@file{host1:/mysite/host1/u1} and @file{host1:/mysite/host1/u2}.  If
they are not present they are added to @file{/etc/fstab}@footnote{Note:
if the filesystem was in the fstab but not actually mounted a warning is
issued telling you that the filesystem was probably not exported
correctly on host1.}.  Next, we know that the binary server is server1,
so we should check for @file{server1:/mysite/server1/local}.  The mail
server is also checked for and added if necessary.  Cfengine then tries
to mount all filesystems once again, so that the new filesystems should
be added.

Note that, in the process of adding the filesystems to
@file{/etc/fstab}, cfengine creates the directories up to and including
the point at which the filesystems should be mounted.  If something
prevents this --- if we try to mount on top of a plain file for instance
--- then this will result in an error.

Finally, we reach the link section and we try to expand the variables.
@code{$(site)} expands to @file{mysite}.  @code{$(binserver)} expands
first to the hostname (host2), but @file{/mysite/host2/local} does not
exist, so it then goes to the binserver list, which substitutes server1
for the value of @code{$(binserver)}.  Since
@file{/mysite/server1/local} does exist and is now mounted, cfengine
makes a link to this directory from @file{/usr/local}.  The script is
then completed.

If the script is run again, everything should now be in place so nothing
happens.  If for some reason it failed the first time, it will fail
again.  At any rate it will either do the job once and for all or signal
an error which must be corrected by human intervention@footnote{One
possibility is that an NFS filesystem cannot be mounted because the host
serving the filesystem is out of service.  If this is the case then a
subsequent re-run when the server resumes normal service will succeed.}.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Using the automounter, Editing files, NFS resources, Global configurations
@section Using the automounter
@cindex automount

The automounter is a daemon based service which replaces static mounting
of NFS filesystems with a dynamical model. When the automounter is
running, filesystems are mounted only when a user tries to access a file
which resides on one of those filesystem. After a given period (usually
five minutes) any filesystem which has not been accessed is
unmounted. The advantage of this scenario is that hanging servers do not
affect the behaviour of hosts which mount their filesystems, unless a
specific file is being accessed.  In both cases, filesystems must be
exported in order to be mountable.

It is not the purpose of this section to explain the use of the
automounter in detail, only to offer hints as to how cfengine can be
used to simplify and rationalize automount configuration for the already
initiated.  Let us begin by comparing the behaviour of the automounter
with the cfengine model for mounted filesystems.

The automounter is designed to be used together with a global
configuration file, distributed by NIS (the network information
service). As such, all hosts read the same configuration
file. This makes it appear as though all hosts end up mounting every
filesystem in the automount configuration database, but this is not so
in practice because filesystems are only mounted if required. Thus a
system which does not require a filesystem will not attempt to mount it.
Moreover, the existence of a global configuration file does not affect
which hosts have the right to mount certain filesystems (which is specified
by exports or share on the relevant server), thus a request to mount
a non-exported filesystem will result in an access denial. The automounter
is configured locally on each host in files named @file{/etc/auto_master},
@file{auto_direct} etc.
@cindex @file{auto_master}
@cindex @file{auto_direct}

In the cfengine static mounting scheme, you define a list of binary
and home servers. The filesystem table is modified on the basis of
these decisions, and filesystems are only added if cfengine deems it
appropriate to mount them on a given host. The idea here is to minimize
the number of filesystems mounted to those which are known to be required.
Again the issue of access permissions must be arranged separately. These
filesystems are placed directly in @file{/etc/fstab}, or the equivalent for
your system.

From cfengine, you can use the automounter instead of the static mount model
by

@itemize @bullet

@item
omitting @code{addmounts}, @code{mountinfo}, @code{mountall} 
from the actionsequence, in the control part
of your cfengine program,

@item
using @code{editfiles} to edit the relevant configuration files
such as @file{/etc/auto_master}, or @file{auto_direct} etc,

@item
using the @code{AutomountDirectResources} command in editfiles
to dump the list of cfengine class-based list of mountables
into a file of your choice in the correct format for
autmount's direct maps,

@item
using @code{processes} @xref{processes} to restart the automounter
(send the hangup signal @code{hup}), or perhaps stop and restart
the daemon by sending the @code{term} signal (you should never
send the @code{kill} signal),

@item
using the multiple link facilities to link in indirect mounted
filesystems as required, and @code{files} or @code{tidy} to
clean up stale links afterwards,

@item
perhaps using @code{copy} to distribute basic automount configuration
files to multiple systems.

@end itemize

The automounter was created to solve certain problems which cfengine now
solves (in the author's opinion) better. For example, the use of the
`hosts' map in the automounter mounts filesystems like 
@file{/usr/local} on different (uniquely named) mountpoints for each host
in order to avoid name space collisions. Using cfengine and a unique
naming scheme, you can achieve the same thing more cleanly, without all
of the gratuitous linking and unlinking which the automounter performs
by itself. Moreover, the idea of a unique name-space is better practice
and more in keeping with new global filesystem ideas such as AFS and DFS.
@cindex AFS
@cindex DFS
The only advantage of the automounter is that one avoids the annoying
error messages from hung servers about "NFS server not responding".
In that respect, it seems sensible to use only direct mounts and a
unique name space.

@cindex Home directories and automount
@cindex @file{/home}
@cindex @file{/users}
Some systems advocate grouping all users' login (home) directories
under a common directory called @file{/home} or @file{users}.
The automounter goes through all manner of contortions to achieve
this task. If you use a unique naming scheme like the one
advocated here, this is a trivial task. You simply arrange to mount
or automount all user directories, such as
@mbindex How to keep all users in @file{/home}

@smallexample
   /@var{site}/@var{host}/home1
   /@var{site}/@var{host}/home2
   ...
@end smallexample

@noindent
and then link them as follows:

@smallexample

   /home +> /@var{site}/@var{host}/home1
   /home +> /@var{site}/@var{host}/home2
   ...

@end smallexample

Finally, you should be aware that the automounter does not like
to be mixed with static mount and unmount operations. Automounted
filesystems take priority over statically mounted filesystems, but
the automounter can be confused by manually mounting or unmounting
filesystems while it is running.




@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Editing files, Disabling and the file repository, Using the automounter, Global configurations
@section Editing Files

A very convenient characteristic of BSD/System 5 systems is that they
are configured primarily by human-readable textfiles. This makes it easy
for humans to configure the system and it also simplifies the automation
of the procedure.  Most configuration files are line-based text files, a
fact which explains the popularity of, for example, the Perl programming
language.  Cfengine does not attempt to compete with Perl or its
peers. Its internal editing functions operate at a higher level which
are designed for transparency rather than flexibility.  Fortunately most
editing operations involve appending a few lines to a file, commenting
out certain lines or deleting lines.

For example, some administrators consider the finger service to be
a threat to security and want to disable it. This could be done
as follows.

@smallexample

editfiles:

      @{ /etc/inetd.conf

      HashCommentLinesContaining "finger"
      @}

@end smallexample

Commands containing the word `Comment' are used to `comment out' certain
lines from a text-file---i.e. render a line impotent without actually
deleting it. Three types of comment were supported originally: shell
style (hash) @samp{#}, @samp{%} as used in TeX and on AIX systems, and
C++-style @samp{//}.

A more flexible way of commenting is also possible, using directives
which first define strings which signify the start of a comment and the
end of a comment. A single command can then be used to render a comment.
The default values of the comment-start string is @samp{# } and the
default comment-end string is the empty string.  For instance, to define
C style comments you could write:

@smallexample

  @{ @var{file}

  SetCommentStart "/* "
  SetCommentEnd   " */"

  # Comment out all lines containing printf!

  CommentLinesMatching ".*printf.*"
  @}

@end smallexample

Other applications for these editing commands include monitoring and
controlling root-access to hosts by editing files such as @file{.rhosts}
and setting up standard environment variables in global shell resource
files--- for example, to set the timezone. You can use the editing
feature to update and distribute the message of the day file,
or to configure sendmail, @xref{FAQS and Tips}.

An extremely powerful feature of cfengine is the ability to
edit a similar file belonging to every user in the system. For example,
as a system administrator, you sometimes need to ensure that users
have a sensible login environment. Changes in the system might require
all users to define a new environment variable, for instance. This is
achieved the with @code{home} pseudo-wildcard. If one writes

@smallexample

  @{ home/.cshrc

  AppendIfNoSuchLine "# Sys admin/cfengine: put next line here"
  AppendIfNoSuchLine "setenv PRINTER newprinter"
  @}

@end smallexample
@noindent
then the users' files are checked one-by-one for the given lines of
text, and edited if necessary.

Files are loaded into cfengine and edited in memory. They are
only saved again if modifications to the file are carried out,
in which case the old file is preserved by adding a suffix
to the filename. When files are edited, cfengine generates a
warning for the administrator's inspection so that the reason
for the change can be investigated.

The behaviour of cfengine should not be confused with that of @emph{sed}
or @emph{perl}.  Some functionality is reproduced for convenience, but
the specific functions have been chosen on the basis of (i) their
readability and (ii) the fact that they are
`frequently-required-functions'. A typical file editing session involves
the following points:

@itemize @bullet
@item Load file into memory.
@item Is the size of the file within sensible user-definable limits? 
If not, file could be binary, refuse to edit.
@item Check each editing command and count the number of edits made.
@item If number of edits is greater than zero, rename the old file
and save the edited version in its place. Inform about the edit.
@item If no edits are made, do nothing, say nothing.
@end itemize

Equivalent one-line sed operations involve editing the same file
perhaps many times to achieve the same results---without the
safety checks in addition.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Disabling and the file repository, Running user scripts, Editing files, Global configurations
@section Disabling and the file repository

The existence of certain files can compromise the integrity of your
system and you may wish to ensure that they do not exist. For example,
some manufacturers sell their workstations with a @samp{+} symbol in
the file @file{/etc/hosts.equiv}.
@cindex @file{/etc/hosts.equiv}
This means that anyone in your NIS domain has password free access
to the system!! Since this is probably not a good idea, you will
want to disable this file by renaming it, or simply deleting it.

@smallexample

  disable:

     /etc/hosts.equiv

@end smallexample

@noindent
Other files compromise the system because they grow so large that they
fill an entire disk partition. This is typically true of log files such as
the system 5 files @file{/var/adm/wtmpx} and
@file{/var/lp/logs/lpsched}. Other files like @var{/var/adm/messages}
get "rotated" by the system so that they do not grow so large as to
fill the disk. You can make cfengine rotate these files too, by
writing
@cindex @file{/var/adm/wtmpx}
@cindex @file{/var/lp/logs/lpsched}

@smallexample

disable:

    Sunday::

    /var/lp/logs/lpsched  rotate=3

@end smallexample

@noindent
Now, when cfengine is run, it renamed the file @file{lpsched} to
a file called @file{lpsched.1}. It also renames @file{lpsched.1}
as @file{lpsched.2} and so on, until a maximum of 3 files are
kept. After passing 3, the files `fall off the end' and
are deleted permanently. This procedure prevents any log files
from growing too large. If you are not interested in keeping
back-logs, then you may write @code{rotate=empty} and cfengine
will simply empty the log file.
@cindex Rotating files
@cindex Log files, rotating

When ever cfengine disables a file (@code{disable} or @code{links} with
the @samp{!}  operator), or saves a new file on top of an old one
(@code{copy} or @code{editfiles}), it makes a backup of the
original. Usually disabled files are renamed by appending the string
@file{.cfdisabled} the the filename; copied files are saved by appending
the string @file{.cfsaved}. 
@cindex @file{.cfsaved} files
@cindex @file{.cfdisabled} files
It is possible to switch off backup file
generation in the copy feature by setting the variable
@code{backup=false}, but a better way of managing disabled and backed-up
files is to use a directory in which you collect all such files for the
whole system. This directory is called the file repository and is set in
the control part of the program, as follows:

@smallexample

  control:

     repository = ( @var{directory-name} )
@end smallexample

If this variable is defined, cfengine collects all backup and disabled files
(except for rotated files) in this directory, using a unique pathname.
You can then inspect these files in the repository and arrange to tidy
the repository for old files which are no longer interesting.


@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Running user scripts, Compressing logs, Disabling and the file repository, Global configurations
@section Running user scripts

Above all, the aim of cfengine is to present a simple interface to
system administrators. The actions which are built into the engine are
aimed at solving the most pressing problems, not at solving every
problem.  In many cases administrators will still need to write
scripts to carry out more specific tasks. These scripts can still be
profitably run from cfengine. Variables and macros defined in cfengine
can be passed to scripts so that scripts can make maximal advantage of
the class based decisions. Also note that, since the days of the week
are also classes in cfengine, it is straightforward to run weekly
scripts from the cfengine environment (assuming that the configuration
program is executed daily). An obvious use for this is to update
databases, like the fast-find database one day of the week, or to run
quota checks on disks.

@smallexample
shellcommands:

   myhost.Sunday::

      "/usr/bin/find/updatedb"

@end smallexample

@noindent
Cfengine scripts can be passed variables using normal variable
substitution:

@smallexample
control:

   cfbin     = ( /local/gnu/lib/cfengine/bin )
   backupdir = ( /iu/dax/backup )   

shellcommands:
  
  "$(cfbin)/cfbackup -p -f $(backupdir) -s /iu/nexus/u1"

@end smallexample

If you need to write a particularly complex script to expand cfengine's
capabilities, it might be useful to have full access to the defined
classes. You can do this in one of two ways:

@itemize @bullet

@item 
Pass the variable @code{$(allclasses)} to the script. This contains a
list of all classes in the form of a string 

@smallexample

      CFALLCLASSES=@var{class1}:@var{class2}:...

@end smallexample

@noindent
This variable always contains an up to date list of the defined
classes.

@item
Use the command line option @samp{-u} or @samp{--use-env}. When this
is defined, cfengine defines an internal environment variable
called @samp{CFALLCLASSES} which contains the same list as above.
Unfortunately, system 5 boxes don't seem to like having to update
an environment variable continuously and tend to dump core, so
this is not the default behaviour!

@end itemize
          
    
@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Compressing logs, ACLs, Running user scripts, Global configurations
@section Compressing old log files

In the previous two sections we have looked at how to rotate old log files
and how to execute shell commands. If you keep a lot of old log files around
on your system, you might want to compress them so that they don't take up
so much space. You can do this with a shell command. The example
below looks for files matching a shell wildcard. Names of the form
@file{file.1}, @file{file.2}...@file{file.10} will match this wildcard
and the compression program sees that they get compressed. The output
is dumped to avoid spurious messages.

@smallexample

shellcommands:

  "$(gnu)/gzip /var/log/*.[0-9] /var/log/*.[0-9][0-9]  > /dev/null 2>&1"

@end smallexample

Cfengine will also recognize rotated files if they have been compressed, with
suffixes @file{.Z}, @file{.gz}, @file{.rbz} or @file{.rbz}.


    
@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node ACLs,  , Compressing logs, Global configurations
@section Managing ACLs

@cindex Access control lists
@cindex ACLs
@cindex Permissions, extended

Access control lists are extended file permissions. They allow you to
open or close a file to a named list of users (without having to
create a special group for those users).  They also allow you to open
or close a file for a named list of groups.  Several unix-like
operating systems have had access control lists for some time; but they
do not seem to have caught on.  

There is a number of reasons for this dawdling in the past.  The tools
for setting ACLs are generally interactive and awkward to use.
Because a named list of users would lead to excessive verbosity in an
@kbd{ls -l} listing, one does not normally see them. There is
therefore the danger that the hidden information would lead to
undetected blunders in opening files to the wrong users.  ACLs are
also different on every vendor's filesystems and they don't work over
intersystem NFS.  In spite of these reservations, ACLs are a great
idea. Here at Oslo College, it seems that users are continually asking
how they can open a file just for the one or two persons they wish to
collaborate with. They have grown used to Novell/PC networks which
embraced the technology from Apollo/NCS much earlier. Previously the
Unix answer to users has always been: go ask the system administrator
to make a special group for you.  Then do the @samp{chmod} thing. And
then they would say: so what's so great about this Unix then?

Addressing this lack of standardization has been the job of a POSIX
draft committee. Some vendors have made their implementations in
the image of this draft. Solaris 2.6 has a good implementation.
In spite of this, even these systems have only
awkard tools for manipulating ACLs. Not the kind of thing you want
to be around much, if you have better things to do.
But the incompatibility argument applies only to multiple vendor
headbutting. Some institutions who share data on a global basis opt
for advanced solutions to network filesystems, such as AFS and DFS.
Filesystems such as DCE's DFS make extensive use of file ACLs, and
they are not operating system specific.  Even so, DFS provides only interactive
tools for examining and setting file permissions, and this is of
little use to system administrators who would rather relegate that sort
of thing to a script.

The need for this kind of thing is clear. Systems which make use of ACLs
for security can be brought to their knees by changing a few ACLs. Take
the Apollo/Domain OS as an example. All one needs to do to kill the
system is to change a few ACLs and forget what they were supposed to
be. Suddenly the system is crippled, nothing works. The only solution,
if you don't have a backup, is to remove all of the security. Unix has a
simpler security philosophy when it comes to the operating system files,
but ACLs would be a valuable addition to the security of our data.


A cfengine bare-bones file-checking program looks like this:

@smallexample
#
# Free format cfengine program
#

 control:

   ActionSequence - ( files )

 files:

   classes::

     /directory/file  mode=644 
                      owner=mark,ds
                      group=users,adm
                      acl=zap 
                      action=fixplain

  # ... more below

@end smallexample

@vindex @code{acl}
@cindex ACL aliases
@noindent
This program simply checks the permissions and ownership of the named
file. The regular file mode, owner and group are specified
straightforwardly.  The new feature here is the @code{acl} directive. It
is a deceptively simply looking animal, but it hides a wealth of
complexity.  The @code{zap} is, of course, not an access control
list.  Rather, cfengine uses a system of aliases to refer to ACLs, so
that the clutter of the complex ACL definitions does not impair the
clarity of a file command.  An ACL alias is defined in a separate part
of the program which looks like this:

@smallexample
 # ...contd


 acl:

   @{ zap

   method:append
   fstype:solaris
   user:rmz:rwx
   user:len:r
   @}

@end smallexample
@noindent
As you can see, an ACL is a compound object---a bundle of information
which specifies which users have which permissions.  Because ACLs are
@emph{lists} the alias objects must also know whether the items are to
be appended to an existing list or whether they are to replace an
existing list. Also, since the permission bits, general options and
programming interfaces are all different for each type of filesystem,
we have to tell cfengine what the filesystem type is.

It is possible to associate several ACL aliases with a file.
When cfengine checks a files with ACLs, it reads the existing
ACL and compares it to the new one. Files are only modified if
they do not conform to the specification  in the cfengine
program. Let's look at a complete example:

@smallexample
 files:

   $(HOME)/myfile acl=acl_alias1 action=fixall

 acl:

   @{ acl_alias1

   method:append
   fstype:solaris
   user:len:rwx
   @}

@end smallexample
@noindent
ACLs are viewed in Solaris with the command @samp{getfacl}.
Suppose that, before running this program, our test-file had permissions

@smallexample
   user:*:rwx
   user:mark:rwx           #effective:r-x
   group:*:r-x              #effective:r-x
   mask:r-x
   other:r-x
   default_user:rw-
   default_group:r--
   default_mask:-w-
   default_other:rwx
@end smallexample

@noindent
After the cfengine run, the ACL would become:

@smallexample
   user:*:rwx
   user:mark:rwx           #effective:r-x
   user:len:rwx            #effective:r-x
   group:*:r-x              #effective:r-x
   mask:r-x
   other:r-x
   default_user:rw-
   default_group:r--
   default_mask:-w-
   default_other:rwx
@end smallexample

@noindent
Suppose we wanted to to remove 'w' bit for user @samp{jacobs}, or make sure
that it was never there.

@smallexample
	@{ acl_alias1

	method:append
	fstype:solaris
	user:jacobs:-w
	@}
@end smallexample

@noindent
Note that the method used here is append. That means that, whatever other
access permissions we might have granted on this file, the user @samp{jacobs}
(a known cracker) will have no write permissions on the file. Had we
used the method @code{overwrite} above, we would have eliminated all
other access permissions for every user and added the above.
If we really wanted to burn @samp{jacobs}, we could remove all rights to
the file like this

@smallexample

  user:jacobs:noaccess

@end smallexample

@noindent
The keyword @code{noaccess} removes all bits. Note that this is not
necessarily the same as doing a @code{-rwx}, since some filesystems,
like DFS, have more bits than this. Then, if we want to forgive and forget,
the ACLs may be removed for @code{jacobs} with the syntax

@smallexample
  user:jacobs:default
@end smallexample

In Solaris, files inherit default ACLs from the directory they
lie in; these are modified by the umask setting to generate
their own default mask.
@cindex ACLs, solaris

DFS ACLs look a little different. They are examined with the 
@samp{acl_edit} command or with
@cindex ACLs, DFS

@smallexample
dcecp -c acl show <filename>
@end smallexample

@noindent
In order to effect changes to the DFS, you have to perform a DCE login
to obtain authentication cookies. The user @samp{cell_admin} is a
special user account for administrating a local DFS cell.  Suppose we
have a file with the following DCE ACL:

@smallexample
  mask_obj:r-x---
  user_obj:rwxcid
  user:cell_admin:r--c-- #effective:r-----
  group_obj:r-x--d       #effective:r-x---
  other_obj:r-x---
@end smallexample

@noindent
Now we want to add @samp{wx} permissions for user
@samp{cell_admin}, and add new entries with @samp{rx} permissons
for group @code{acct-admin} and user @samp{root}.  This is done with the
following ACL alias:

@smallexample

   @{ acl_alias2

   method:append
   fstype:dfs
   user:/.../iu.hioslo.no/cell_admin:wx
   group:/.../iu.hioslo.no/acct-admin:rx
   user:/.../iu.hioslo.no/root:rx
   user:*:-x
   @}

@end smallexample

@noindent
The local cell name @file{/.../iu.hioslo.no} is required here. Cfengine
can not presently change ACLs in other cells remotely, but if your
cfengine program covers all of the cell servers, then this is no
limitation, since you can still centralize all your ACLs in one
place. It is just that the execution and checking takes place at
distributed locations. This is the beauty of cfengine.  After running
cfengine, with the above program snippet, the ACL then becomes:

@smallexample
  mask_obj:r-x---
  user_obj:rwcid
  user:cell_admin:rwxc-- #effective:r-x---
  user:root:r-x---       #effective:r-x---
  group_obj:r-x--d       #effective:r-x---
  group:acct-admin:r-x---
  other_bj:r-x---
@end smallexample

@noindent
For the sake of simplicity we have only used standard Unix
bits @samp{rwx} here, but more complicated examples may be found
in DFS. For example,

@smallexample

 user:mark:+rwx,-cid

@end smallexample

@noindent
which sets the read, write, execute flags, but removes the
control, insert and delete flags. In the DFS, files
inherit the inital object ACL of their parent directory,
while new directories inherit the initial container object.

The objects referred to in DFS as @code{user_obj}, @code{group_obj}
and so forth refer to the owner of a file. i.e. they are equivalent
to the same commands acting on the user who owns the file concerned.
To make the cfengine user-interface less cryptic and more in tune
with the POSIX form, we have dropped
the @samp{_obj} suffices. A user field of @samp{*} is a simple
abbreviation for the owner of the file.

A problem with any system of lists is that one can generate a sequence
which does one thing, and then undoes it and redoes something else,
all in the same contradictory list. To avoid this kind of accidental
interaction, cfengine insists that each user has only one ACE
(access control entry), i.e. that all the permissions for a given user
be in one entry.

@c **********************************************************************
@c CHAPTER
@c **********************************************************************

@node Using cfengine as a front-end for cron, Cfengine network services, Global configurations, Top
@chapter Using cfengine as a front end for @code{cron}

One of cfengine's strengths is its use of classes to identify systems
from a single file or set of files. Many administrators think that it
would be nice if the cron daemon also worked in this way. One possible
way of setting up cron from a global configuration would be to use the
cfengine @code{editfiles} facility to edit each cron file separately. A
much better way is to use cfengine's time classes to work like a user
interface for cron.  This allows you to have a single, central cfengine
file which contains all the cron jobs on your system without losing any
of the fine control which cron affords you. All of the usual advantages
apply:
@itemize @bullet

@item
It is easier to keep track of what cron jobs are running on the
system when you have everything in one place.

@item
You can use all of your carefully crafted groups and user-defined
classes to identify which host should run which programs.
@end itemize
@cindex Cron jobs, controlling with cfengine

The central idea behind this scheme is to set up a regular cron
job on every system which executes cfengine at frequent intervals.
Each time cfengine is started, it evaluates time classes and
executes the shell commands defined in its configuration file.
In this way we use cfengine as a wrapper for the cron scripts,
so that we can use cfengine's classes to control jobs for mulitple
hosts. Cfengine's time classes are at least as powerful as @code{cron}'s
time specification possibilities, so this does not restrict you
in any way, @xref{Building flexible time classes}. The only price
is the overhead of parsing the cfengine configuration file.
@mbindex How can I use cfengine to make a global cron file?

To be more concrete, imagine installing the following @file{crontab}
file onto every host on your network:

@cartouche
@smallexample
#
# Global Cron file
#
0,15,30,45 * * * * /usr/local/cfengine/inputs/run-cfengine

@end smallexample
@end cartouche

@noindent
This file contains just a single cron job, namely a script which calls
cfengine.  Here we are assuming that you will not want to execute any
cron script more often than every fifteen minutes. If this is too
restrictive, the above can be changed. We refer to the time interval
between runs of the script @file{run-cfengine} as the `scheduling interval'
and discuss its implications in more detail below.

@cindex @file{run-cfengine} file.
The script @file{run-cfengine} would replace any @file{cfdaily} or
@file{cfhourly} scripts which you might have, and can as simple as this

@cartouche
@smallexample
#!/bin/sh
#
# Script run-cfengine

export CFINPUTS=/usr/local/cfengine/inputs

/usr/local/gnu/bin/cfengine

#
# Should we pipe mail to a special user?
#
@end smallexample
@end cartouche

@noindent
or it could be more fancy. You could also use the @file{cfwrap} script,
@xref{cfwrap}, if you have perl on all your systems, to pipe mail
to the mail address described in the cfengine file, @xref{sysadm}.

@cartouche
@smallexample
#
# Global Cron file
#
0,15,30,45 * * * * @var{path}/cfwrap @var{path}/run-cfengine

@end smallexample
@end cartouche

@noindent
You might not want to run your entire system configuration 
@file{cfengine.conf} every time cron fires up cfengine. An alternative
would be to keep a separate fil for cron jobs called, say,
@file{cf.cron}. You would then replace the @file{run-cfengine}
file by

@cartouche
@smallexample
#!/bin/sh
#
# Script run-cfengine

export CFINPUTS=/usr/local/cfengine/inputs

/usr/local/gnu/bin/cfengine -f cf.cron

#
# Should we pipe mail to a special user?
#
@end smallexample
@end cartouche

@noindent
There is no particular advantage to doing this unless you are running
cfengine on some very slow hardware. A better way to approach the
problem is to think of the @file{cf.cron} file as a module which can be
imported into the main configuration file. This gives you the maximum
amount of flexibilty, since it allows you to decide exactly what you
want to happen any any given time from the central file.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@menu
* Structuring cfengine.conf::   
* Splaying host times::         
* Building flexible time classes::  
* Scheduling interval::         
@end menu

@node Structuring cfengine.conf, Splaying host times, Using cfengine as a front-end for cron, Using cfengine as a front-end for cron
@section Structuring @file{cfengine.conf}

The structure of @file{cfengine.conf} needs to reflect your policy
for running jobs on the system. You need to switch on relevant tasks
and switch off unwanted tasks depending on the time of day. This can
be done in three ways:

@itemize @bullet

@item
By placing individual actions under classes which restrict the times at
which they are executed,

@smallexample

  @var{action}:

        Hr00.Min10_15||Hr12.Min45_55::

           @var{Command}

@end smallexample


@item
By choosing a different @code{actionsequence} depending on the
time of day.

@smallexample

  control:

        Hr00::   # Action-sequence for daily run at midnight

           actionsequence = ( @var{sequence} )

       !Hr00::   # Action-sequence otherwise

            actionsequence = ( @var{sequence} )

@end smallexample

@item
By importing modules based on time classes.

@smallexample

  import:

        Hr00:: cf.dailyjobs

        any::  cf.hourlyjobs

@end smallexample

@end itemize

@noindent
The last of these is the most efficient of the three, since cfengine
does not even have to spend time parsing the files for actions which
you know you will not want.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Splaying host times, Building flexible time classes, Structuring cfengine.conf, Using cfengine as a front-end for cron
@section Splaying host times

The trouble with starting every cfengine at the same time using a global
cron file is that it might lead to contention or inefficiency. For
instance, if a hundred cfengines all suddenly wanted to copy a file from
a master source simultaneously this would lead to a big load on the
server. We can prevent this from happening by introducing a time delay
which is unique for each host and not longer than some given interval.
Cfengine uses a hashing algorithm to generate a number between zero
and a maximum value in minutes which you define, like this:

@smallexample

 control:
 
    SplayTime = ( 60 ) # minutes

@end smallexample

@noindent
If this number is non-zero, cfengine goes to sleep after parsing its
configuration file and reading the clock. Every machine will go to sleep
for a different length of time, which is no longer than the time you
specify in minutes. A hashing algorithm, based on the fully qualified
name of the host, is used to compute a unique time for hosts. The
shorter the interval, the more clustered the hosts will be. The longer
the interval, the lighter the load on your servers.  This `splaying' of
the run times will lighten the load on servers, even if they come
from domains not under your control but have a similar cron policy.
@cindex Splaying host times
@cindex Contention during copying under load
@cindex Load balancing

Splaying can be switched off temporarily with the @samp{-q} or @samp{--no-splay}
options.


@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Building flexible time classes, Scheduling interval, Splaying host times, Using cfengine as a front-end for cron
@section Building flexible time classes

@cindex Time classes
@mbindex How can I make complex time intervals using time classes?
@mbindex Time classes, picking out complex time intervals
Each time cfengine is run, it reads the system clock and defines the
following classes based on the time and date:

@table @code

@item Yr@var{xx}::
The current year, e.g. @samp{Yr1997}, @samp{Yr2001}. This class is probably
not useful very often, but it might help you to turn on the new-year lights,
or shine up your systems for the new millenium!
@cindex Years

@item @var{Month}::
The current month can be used for defining very long term variations in
the system configuration, e.g. @samp{January}, @samp{February}. These
classes could be used to determine when students have their summer vacation,
for instance, in order to perform extra tidying, or to specially maintain some
administrative policy for the duration of a conference.
@cindex Months

@item @var{Day}::
The day of the week may be used as a class, e.g. @samp{Monday}, @samp{Sunday}.
@cindex Day of the week

@item Day@var{xx}::
A day in the month (date) may be used to single out by date, e.g. the first
day of each month defines @samp{Day1}, the 21st @samp{Day21} etc.

@item Hr@var{xx}::
An hour of the day, in 24-hour clock notation: @samp{Hr00}...@samp{Hr23}.

@item Min@var{xx}::
The precise minute a which cfengine was started: @samp{Min00} ... @samp{Min59}.
This is probably not useful alone, but these values may be combined
to define arbitrary intervals of time.

@item Min@var{xx}_@var{xx}::
The five-minute interval in the hour at which cfengine was executed, in the form
@samp{Min00_05}, @samp{Min05_10} .. @samp{Min55_00}.

@end table

Time classes based on the precise minute at which cfengine started are
unlikely to be useful, since it is improbable that you will want to ask
cron to run cfengine every single minute of every day: there would be no
time for anything to complete before it was started again. Moreover,
many things could conspire to delay the precise time at which cfengine
were started. The real purpose in being able to detect the precise
start time is to define composite classes which refer to arbitrary
intervals of time. To do this, we use the @code{group} or @code{classes}
action to create an alias for a group of time values.
@cindex Grouping time values
@cindex @code{groups} and time intervals
Here are some creative examples:

@smallexample

classes:  # synonym groups:

  LunchAndTeaBreaks = ( Hr12 Hr10 Hr15 )

  NightShift        = ( Hr22 Hr23 Hr00 Hr01 Hr02 Hr03 Hr04 Hr05 Hr06 )

  ConferenceDays    = ( Day26 Day27 Day29 Day30 )

  QuarterHours      = ( Min00 Min15 Min30 Min45 )

  TimeSlices        = ( Min01 Min02 Min03 Min33 Min34 Min35)

@end smallexample
@noindent
In these examples, the left hand sides of the assignments are
effectively the ORed result of the right hand side. This if any
classes in the parentheses are defined, the left hand side class
will become defined. This provides an excellent and readable way of
pinpointing intervals of time within a program, without having to
use @samp{|} and @samp{.} operators everywhere.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Scheduling interval,  , Building flexible time classes, Using cfengine as a front-end for cron
@section Choosing a scheduling interval

How often should you call your global cron script? There are several
things to think about:

@itemize @bullet

@item
How much fine control do you need? Running cron jobs once each hour is
usually enough for most tasks, but you might need to exercise finer
control for a few special tasks.

@item
Are you going to run the entire cfengine configuration file
or a special light-weight file?

@item
System latency. How long will it take to load, parse and run the
cfengine script?

@end itemize

Cfengine has an intelligent locking and timeout policy which should be
sufficient to handle hanging shell commands from previous crons so that
no overlap can take place, @xref{Spamming and security}.



@c **********************************************************************
@c CHAPTER
@c **********************************************************************

@node Cfengine network services, Security and cfengine, Using cfengine as a front-end for cron, Top
@chapter Cfengine and network services

This chapter describes how you can set up a cfengine network service to handle
remote file distribution and remote execution of cfengine without having
to open your hosts to possible attack using the @code{rsh} protocols.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@menu
* What services?::              
* How it works::                
* Configuring cfd::             
@end menu

@node What services?, How it works, Cfengine network services, Cfengine network services
@section Cfengine network services

By starting the daemon called @code{cfd}, you can set up a line of
communication between hosts, allowing them to exchange files across
the network or execute cfengine remotely on another system.
@cindex @code{cfd} daemon
@cindex @code{cfrun} program
@cindex @code{cfwatcher} program
Cfengine network services are built around the following components:

@table @code

@item cfengine
The configuration engine, whose only contact with the netork is via
remote copy requests. This component does the hard work of configuring
the system based on rules specified in the file @file{cfengine.conf}. It
does not and cannot grant any access to a system from the network.
@cindex @file{cfengine.conf} file

@item cfd
A daemon which acts as both a file server and a remote-cfengine
executor. This daemon authenticates requests from the network and
processes them according to rules specified in @file{cfd.conf}.
It works as a file server and as a mechanism for starting
cfengine on a local host and piping its output back to the
network connection.
@cindex @file{cfd.conf} file

@item cfrun
This is a simple initiation program which can be used
to run cfengine on a number of remote hosts. It cannot
be used to tell cfengine what to do, it can only ask cfengine
on the remote host to run the configuration file it already
has. Anyone could be allowed to run this program, it does not
require any special user privileges. A locking mechanism
in cfengine prevents its abuse by spamming.

@item cfwatch
This program (which is not a part of the distribution: it is left for
others to implement) should provide a graphical user interface for
watching over the configuration of hosts running cfengine and logging
their output.

@end table

@noindent
With these components you can emulate programs like @code{rdist}
@cindex @code{rdist} program
@cindex Remote distribution of files
@cindex Remote execution of cfengine
whose job it is to check and maintain copies of files on client machines.
You may also decide who has permission to run cfengine and how often it
may be run, without giving away any special user privileges.


@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node How it works, Configuring cfd, What services?, Cfengine network services
@section How it works


@c ...........................................
@c SUBSECTION
@c ...........................................

@menu
* Emulating rdist::             
* Remote execution of cfengine::  
* cfrun::                       
* Spamming and security::       
* cfd protocol::                
* Deadlocks and runaway loops::  
@end menu

@node Emulating rdist, Remote execution of cfengine, How it works, How it works
@subsection Remote file distribution

This section describes how you can set up @code{cfd} as a remote file
server which can result in the distrubution of files to client hosts in
a more democratic way than with programs like rdist.

An important difference between cfengine and other systems has to do
with the way files are distributed.  Cfengine uses a `pull' rather than a
`push' model for distributing network files.  The @code{rdist} command,
for instance, works by forcing an image of the files on one server
machine onto all clients.  Files get changed when the server wishes it
and the clients have no choice but to live with the consequences.
Cfengine cannot force its will onto other hosts in this way, it can only
signal them and ask them to collect files if they want to. In other
words, cfengine simulates a `push' model by polling each client and
running the local cfengine configuration script giving the host the
chance to `pull' any updated files from the remote server, but
leaving it up to the client machine to decide whether or not it
wants to update.

Also, in contrast to programs like @code{rdist} which distribute files
over many hosts, cfengine does not require any general @code{root}
access to a system using the @file{.rhosts} file or the
@file{/etc/hosts.equiv} file. It is sufficient to run the daemon as
root.  You can not run it by adding it to the @file{/etc/inetd.conf}
file on your system however.
@cindex @file{/etc/inetd.conf} file and cfengine
The restricted functionality of the daemon protects your system from
attempts to execute general commands as the root user using @code{rsh}.

To remotely access files on a server, you add the keywork @code{server=@var{host}}
@cindex @code{server=} 
to a copy command. Consider the following example
which illustrates how you might distribute a password file from a masterhost
to some clients.

@smallexample

copy:

  PasswdClients::

    /etc/passwd  dest=/etc/passwd owner=root group=0 server=@var{server-host}

@end smallexample
@noindent
Given that the @code{cfd} daemon is running on @var{server-host}, cfengine
will make contact with the daemon and attempt to obtain information
about the file. During this process, cfengine verifies that the system
clocks of the two hosts are reasonably synchronized. If they are not,
it will not permit remote copying.
@cindex Clock synchronization during copying
If cfengine determines that a file needs to be updated from a remote
server it begins copying the remote file to a new file on the same
filesystem as the destination-file. This file has the suffix @file{.cfnew}.
@cindex @file{.cfnew} files
Only when the file has been successfully collected will cfengine make
a copy of the old file, @xref{repository} and rename the new file
into place. This behaviour is designed to avoid race-conditions which
can occur during network connections and indeed any operations which
take some time. If files were simply copied directly to their new
destinations it is conceivable that a network error could interrupt
the transfer leaving a corrupted file in place.

Cfengine places a timeout of a few seconds on network connections to
avoid hanging processes.

Normally the daemon sleeps, waiting for connections from the network.
Such a connection may be initiated by a request for remote files from a
running cfengine program on another host, or it might be initiated by
the program @code{cfrun} which simply asks the
@cindex @code{cfrun} program
host running the daemon to run the cfengine program locally.

@emph{Make sure that you are running cfengine from a shell which
has sensible limits set. The error `too many open files'
can occur in long recursions if you only have a small number
of valid descriptors per shell. It is probably a good idea to
set the number of descriptors to 1024.}

@c ...........................................
@c SUBSECTION
@c ...........................................

@node Remote execution of cfengine, cfrun, Emulating rdist, How it works
@subsection Remote execution of cfengine

@cindex Remote execution of cfengine
It is a good idea to execute cfengine by getting @code{cron} to
run it regularly.  This ensures that cfengine will be run even if you are
unable to log onto a host to run it yourself. Sometimes however you
will want to run cfengine immediately in order to implement a change in
configuration as quickly as possible. It would then be inconvenient
to have to log onto every host in order to do this manually. A better
way would be to issue a simple command which contacted a remote host and
ran cfengine, printing the output on your own screen:

@smallexample

myhost% cfrun @var{remote-host} -v

 @var{output....}

@end smallexample

@noindent
A simple user interface is provided to accomplish this. @code{cfrun}
makes a connection to a remote cfd-daemon
@cindex cfd dameon
@cindex cfrun program
@cindex Running cfengine remotely
and executes cfengine on that system with the privileges of the
cfd-daemon (usually @code{root}). This has a two advantages:

@itemize @bullet

@item
You avoid having to log in on a remote host in order to reconfigure
it.

@item
Users other than root can run cfengine to fix any problems with
the system.

@end itemize

A potential disadvantage with such a system is that malicious users
might be able to run cfengine on remote hosts. The fact
that non-root users can execute cfengine is not a problem in itself,
after all the most malicious thing they would be able to do would
be to check the system configuration and repair any problems.
No one can tell cfengine what to do using the cfrun program, it
is only  possible to run an existing configuration.
But a more serious concern is that malicious users might try to run cfengine
repeatedly (so-called `spamming') so that a system became burdened
with running cfengine constantly, @xref{Spamming and security}.

@c ...........................................
@c SUBSECTION
@c ...........................................

@node cfrun, Spamming and security, Remote execution of cfengine, How it works
@subsection @code{cfrun}

The syntax of the @code{cfrun} command is

@cartouche
@smallexample

  cfrun -@var{option} --@var{longoption} @var{class1} @var{class2 ...}

@end smallexample
@end cartouche

@noindent
With the exception of the @samp{-d} and @samp{-S} options, all options are passed
@cindex -d option in cfrun
@cindex -S option in cfrun
on to the remote hosts and are ignored locally. The @samp{-q} option is
always assumed when executing cfengine remotely, so that SplayTime is
effectively zero when polling hosts serially.  If an option includes a
name such as @samp{-Dnewclass}, there should not be a space between the
option letter and the name string. The remaining options are treated as
classes to be sent to all the hosts on the network.
@cindex SplayTime in cfrun

Each host evaluates the classes sent by @code{cfrun}
and decides whether cfengine should be invoked.
@cindex Running @code{cfrun}
Only hosts which belong to the classes defined on the @code{cfrun}
command line are executed. This allows you to single out groups of hosts
which should execute cfengine, based on the very classes which you have
defined for your configuration.  If no classes are sent on the command
line, then all hosts are run.

@code{cfrun} uses a configuration file which is located under the
@code{CFINPUTS} directory in order to determine which hosts and in
which order it should try to connect. Because cfengine always uses a
reliable TCP protocol for connections, it verifies each connection
rather than simply broadcasting openly. Using this file you can even
simulate broadcasting to hosts outside your subnet.
@cindex Broadcasts to the cfengine service.

This file should contain every host name you ever want to
configure remotely, because you can still select subsets of
the file by specifying classes which the remote host will understand.
If the remote host is not in one of the classes you specify when you
run @code{cfrun}, then it will simply ignore the request. Conversely,
if you do not place a host in this file, it will never be contacted
when you use the @code{cfrun} command. The format of the file
is as follows

@cartouche
@smallexample

 #
 # Comment ..
 #
 domain=@var{my.domain}

 @var{hostname1} @var{options}
 @var{hostname2} @var{options}
 ...

@end smallexample
@end cartouche

@noindent
It is important to add the domain-name to this file.
The options you specifiy in this file, per host, are added to those
you might specify on the command line when invoking cfengine remotely.
For instance, you might know of a bug on one host and decide not to
perform interface configuration on that one machine. You would write
a line like this:

@smallexample

  funny.domain -i  # problem host

@end smallexample

@cindex Running cfengine from a single master host
@cindex Running cfengine from a single master host
You could use @code{cfrun} inside one of your cfengine configuration
files in order to remotely execute cfengine on all of the other
network machines, by setting up a host list. Be careful not to
include the name of the master host in the list. The locks should
prevent cfengine from being run on the masterhost, avoiding an
infinite loop. This way you do not have to rely on cron running
on every system. The disadvantage however is that cfengine
has to poll the systems on the network, which means that cfengine
cannot be working in parallel on all hosts. This could be
inefficient in the long run.

@c ...........................................
@c SUBSECTION
@c ...........................................

@node Spamming and security, cfd protocol, cfrun, How it works
@subsection Spamming and security

The term `spamming' refers to the senseless repetition of something in a
malicious way intended to drive someone crazy@footnote{Recall the `spam'
song from Monty Python's flying circus?}. In the computer world some
malicious users, a bit like `flashers' in the park@footnote{Recall the
`spam' song from Monty Python's flying circus?} like to run around the
net a reveal themselves ad nauseum by sending multiple mail messages or
making network connections repeatedly to try to overload systems and
people@footnote{Recall the `spam' song ... get the idea?}.

Whenever we open a system to the network, this problem becomes a concern.
Cfengine is a tool for making peace with networked systems, not a tool
to be manipulated into acts of senseless aggression. The cfengine daemon
does make it possible for anyone to connect and run a cfengine process
however, so clearly some protection is required from such attacks.

Cfengine's solution to this problem is a locking mechanism. Rather than
providing user-based control, cfengine uses a time based locking
mechanism which prevents actions from being executed unless a certain
minimum time has elapsed since the last time they were executed.
By using a lock which is not based on user identity, we protect
several interests in one go:

@itemize @bullet

@item
Restricting cfengine access to root would prevent regular users,
in trouble, from being able to fix problems when the system
administrator was unavailable. A time-based lock does not
prevent this kind of freedom.

@item
Accidents with cron or shell scripts could start cfengine
more often than desirable. We also need to protect against
such accidents.

@item
We can prevent malicious attacks regardless of whom they may
come from.

@end itemize

Cfengine is controlled by a series of locks which prevent it from
being run too often, and which prevent it from spending too long trying
to do its job. The locks work in such a way that you can start several
cfengine processes simultaneously without them crashing into each
other. Coexisting cfengine processes are also prevented from trying to
do the same thing at the same time (we call this `spamming').
You can control two things about each kind of action in the action
sequence:

@itemize @bullet

@item
The minimum time which should have passed since the last time
that action was executed. It will not be executed again until
this amount of time has elapsed. (Default time is 0 minutes so
that users un-aware of this feature will not be confused by it.)

@item
The maximum amount of time cfengine should wait for an old
instantiation of cfengine to finish before killing it
and starting again. (Default time is 120 minutes.)

@end itemize

@noindent
You can set these values either globally (for all
actions) or for each action separately. If you
set global and local values, the local values override
the global ones. All times are written in units
of @emph{minutes}.

@cartouche
@smallexample

   actionsequence
     (
     action.IfElapsed@var{time-in-mins}
     action.ExpireAfter@var{time-in-mins}
     )

@end smallexample
@end cartouche

@noindent
or globally,

@cartouche
@smallexample

  control:

     IfElapsed   = ( @var{time-in-mins} )

     ExpireAfter = ( @var{time-in-mins} )

@end smallexample
@end cartouche

@noindent
For example:

@smallexample

 control:

   actionsequence = 
     (
     files.IfElapsed240.ExpireAfter180
     copy
     tidy
     )

   IfElapsed = ( 30 )

@end smallexample

In this example, we treat the files action differently to the others.
For all the other actions, cfengine will only execute the files part of
the program if 30 minutes have elapsed since it was last run. Since no
value is set, the expiry time for actions is 60 minutes, which means
that any cfengine process which is still trying to finish up after 60
minutes will be killed automatically by the next cfengine which gets
started.

As for the files action: this will only be run if 240 minutes
(4 hours) have elapsed since the last run. Similarly, it will
not be killed while processing `files' until after 180 minutes
(3 hours) have passed.

These locks do not prevent the whole of cfengine from running,
only so-called `atoms'. Several different atoms can be
run concurrently by different cfengines.
@cindex Atoms in cfengine
@cindex Atomic operations in cfengine
Assuming that the time conditions set above allow you to start
cfengine, the locks ensure that atoms will never
be started by two cfengines at the same time, causing
contention and wasting CPU cycles.
Atoms are defined to maximize the security of your system
and to be efficient. If cfengine were to lock each file
it looked at seperately, it would use a large amount of
time processing the locks, so it doesn't do that. Instead,
it groups things together like this:

@table @code

@item copy, editfiles, shellcommands
Each separate command has its own lock. This means that several
such actions can be processed concurrently by several cfengine
processes. Multiple or recursive copies and edits are
treated as a single object.

@item netconfig, resolve, umount, mailcheck, addmounts, disable, processes
All commands of this action-type are locked simultaneously,
since they can lead to contention.

@item mountall, mountinfo, required, checktimezone
These are not locked at all.

@end table


@cindex Lock files for ordinary users
@cindex Ordinary users, lock files
Cfengine creates a directory @file{~/.cfengine} for writing lock files
for ordinary users.

The option @samp{-K} or @samp{--no-lock} can be used to switch off the
locking checks, but note that when running cfengine remotely via @code{cfd},
this is not possible.

@c ...........................................
@c SUBSECTION
@c ...........................................

@node cfd protocol, Deadlocks and runaway loops, Spamming and security, How it works
@subsection Some points on the cfd protocol

Cfd uses a form for host-based authorization. Each atomic operation ,
such as statting, getting files, reading directories etc, requires a new
connection and each connection is verified by a double reverse lookup in
the server's DNS records.  Single stat structures are cached during the
processing of a file.

MD5 checksums are transferred from client to server to avoid loading the
server.  Even if a user could corrupt the MD5 checksum, he or she would have to
get past access control with TCP wrappers and the worst that could
happen would be to get the right version of the file.  Again this is in
keeping with the idea that users can only harm themselves and not others
with cfengine.

@c ...........................................
@c SUBSECTION
@c ...........................................

@node Deadlocks and runaway loops,  , cfd protocol, How it works
@subsection Deadlocks and runaway loops

Whenever we allow concurrent processes to share a resource, we open
ourselves up the possibilty of deadlock. This is a situation where two
or more processes are locked in a vicious stalemate from which none can
escape. Another problem is that it might be possible to start an infinite loop:
cfengine starts itself. 
@cindex Deadlock protection
@cindex Infinite loops

Cfengine protects you from such loops to a large
degree. It should not be possible to make such a loop by accident.
The reason for this is the locking mechanism which prevents tasks
being repeated too often. If you start a cfengine process which
contains a shell-command to start cfengine again, this shell
command will be locked, so it will not be possible to run it
a second time. So while you might be able to start a second
cfengine process, further processes will not be started and
you will simply have wasted a little CPU time. When the first
cfengine returns, the tasks which the second cfengine completed
will not be repeated unless you have set the @code{IfElapsed} time
or the @code{ExpireAfter} time to zero.
@cindex IfElapsed, caution setting to zero!
@cindex ExpireAfter, caution setting to zero!
In general, if you wish to avoid problems like this, you
should not disable the locking mechanism by setting these two
times to zero.

The possibility of deadlock arises in network connection. Cfengine will
not attempt to use the network to copy a file which can be copied
internally from some machine to itself. It will always replace the
@code{server=} directive in a copy with `localhost' to avoid unnecessary
network connections.
@cindex server= when copying to localhost
@cindex localhost and remote copying
The prevents one kind of deadlock which could occur: namely cfrun
executes cfengine on host A (cfd on host A is then blocked until this
completes), but the host A configuration file contains a remote copy
from itself to itself.  This remote copy would then have to wait for cfd
to unblock, but this would be impossible since cfd cannot unblock until
it has the file. By avoiding remote copies to localhost, this possibility
is avoided.


@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Configuring cfd,  , How it works, Cfengine network services
@section Configuring @code{cfd}

@c ...........................................
@c SUBSECTION
@c ...........................................

@menu
* Installation of cfd::         
* Configuration file cfd.conf::  
* TCP wrappers::                
@end menu

@node Installation of cfd, Configuration file cfd.conf, Configuring cfd, Configuring cfd
@subsection Installation of @code{cfd}

To install the cfengine daemon component, you will need to register a
port for cfengine by adding the following line to the system file
@file{/etc/services file}
@smallexample

   cfengine        5308/tcp

@end smallexample
@noindent
You could do this for all hosts by adding the following to your
cfengine configuration
@smallexample

editfiles:

  @{ /etc/services

   AppendIfNoSuchLine "cfengine        5308/tcp"
  @}

@end smallexample
@noindent
To start cfengine at boot time, you need to place a line
of the following type in your system startup files:

@smallexample

# Start cfengine server
cfd

@end smallexample

@noindent
Note that @code{cfd} will reread its configuration file whenever
it detects that it has been changed, so you should not have to restart
the daemon, not send it the HUP signal as with other daemons.
@cindex HUP and cfd, don't need to
@cindex Restarting cfd
@cindex Rereading @file{cfd.conf}

@c ...........................................
@c SUBSECTION
@c ...........................................

@node Configuration file cfd.conf, TCP wrappers, Installation of cfd, Configuring cfd
@subsection Configuration file @file{cfd.conf}


The server daemon is controlled by a file called
@file{cfd.conf}.
@cindex @file{cfd.conf} file
The syntax of this configuration file is deliberately modelled on
cfengine's own configuration file, but despite the similarities, you cannot
mix the contents of the two files.

Though they are not compatible, @file{cfengine.conf} and @file{cfd.conf}
are similar in several ways:

@itemize @bullet

@item
Both files use classes to label entries, so that you may use
the same configuration file to control all hosts on your network. This
is a convenience which saves you the trouble of maintaining many
different files.

@item
Both files are searched for using the contents of the variable
@code{CFINPUTS}.
@cindex @code{CFINPUTS} variable

@item
You can use @code{groups} and @code{import} in both files
to break up files into convenient modules and to import
common resources, such as lists of groups.

@end itemize
    
Note that the classes in the @file{cfd.conf} file do not tell you the
classes of host which have access to files and directories, but rather
which classes of host pay attention to the access and deny commands when
the file is parsed.

Host name authentication is not by class or group but by hostname, like
the @file{/etc/exports} file on most unix systems. The syntax for the
file is as follows:

@cartouche
@smallexample

 control:

   @var{classes}::

       domain = ( @var{DNS-domain-name} )

       cfrunCommand = ( "@var{script/filename}" )  # Quoted

       MaxConnections = ( @var{maximum number of forked daemons} )

       ChecksumDatabase = ( @var{filename} )

       IfElapsed = ( @var{time-in-minutes} )

 groups:

   @var{Group definitions}

 import:

   @var{Files to import}

 admit: | grant:

   @var{classes}::

      /@var{file-or-directory}

        @var{wildcards/hostnames}

 deny:

   @var{classes}::

      /@var{file-or-directory}

        @var{wildcards/hostnames}

@end smallexample

@end cartouche


@noindent
The file consists of a control section and access information.
You may use the control section to define any variables which
you want to use in the remainder of your file. Two variables
are special here, they are reserved.

@table @code

@item cfrunCommand
This string is the command which you would like to be executed
remotely by the @code{cfrun} command.
@cindex @code{cfrunCommand} variable


@item MaxConnections
This integer value sets a limit on the maximum number of
child daemon processes which cfengine will fork in order
to handle remote requests. The default value is ten daemons.

@item IfElapsed
The @code{IfElapsed} anti-spamming filter is also built into
@code{cfd} so that a remote user cannot even get as far as
causing cfengine to parse its input files (which could
be used for spamming in itself). The time is in minutes,
the default is one hour.

@cindex @code{MaxConnections} variable

@item ChecksumDatabase
This is the path and filename to a database which will cache
MD5 checksum values server-side. This optimization is only available
if you have the Berkeley database library @samp{libdb} on your
system. If this variable is not defined, no database caching
will be used and checksum values will be computed directly on
request. The utility of this solution is a trade-off between
the time it takes to compute the checksum versus the time
for a disk-based lookup.

@cindex @code{ChecksumDatabase} variable
@mbindex MD5 checksums take a long time to compute.
@mbindex Checksums take too long to compute.

@end table

Following the control section comes a list of files or directories and
hosts which may access these. If permissions are granted to a directory
then all sub directories are automatically granted also. Note that
symbolic links are not checked for, so you may need to specifically deny
access to links if they are plain files, but cfd does not follow
symbolic links and give access to files in other directories.

Fully qualified hostnames should be given in this file. Do not forget to
define the domain name. Authentication calls the unix function
@code{gethostbyname()} and so on to identify and verify connecting
hosts, so the names in the file must reflect the type on names returned
by this function. You may use wildcards in names to match, for instance,
all hosts from a particular domain.

Here is an example file
@smallexample
#####################################################
#
# This is a cfd config file
#
#####################################################
 
groups:

  PasswdHost = ( nexus )

#####################################################
  
control:
  
  #
  # Assuming CFINPUTS is defined
  #

  cfrunCommand = ( "/usr/local/bin/cfengine" )  

  variable = ( /usr/local/publicfiles )

#####################################################
  
admit:   # Can also call this grant:
 
   PasswdHost::
 
     /etc/passwd
 
        *.iu.hioslo.no
 
    FtpHost::

    # An alternative to ftp, grant anyone 

       /local/ftp/pub
 
         *

    any::

       $CFINPUTS/cfrun.sh

         *.iu.hioslo.no

#####################################################
 
deny:
 
   /etc/services
 
       borg.iu.hioslo.no

  /local/ftp

       *.pain-in-the-ass.com


@end smallexample

@emph{NOTE I: cfd is not @code{rpc.mountd}, access control is by filename,
not by device name. Do not assume that files lying in subdirectories are
not open for access simply because they lie on a different device. You should
give the real path name to file and avoid symbolic links.} 

@b{NOTE II: access control is per host, not per user. If you open a file
for a host you open it for every user on that host.}

If you still have problems with lack of access, it could be that you
have forgotten to define the domain name for your network, or that
you do not understand the TCP wrappers files @file{/etc/hosts.access} and
@file{/etc/hosts.deny}.
@cindex Access control by directory
@cindex Device boundaries and remote copy access
@mbindex Why does cfd give access to files on a different filesystem?
@mbindex Why do I get network access denied to files I have granted access to?

@cindex Access control in cfd

@c ...........................................
@c SUBSECTION
@c ...........................................

@node TCP wrappers,  , Configuration file cfd.conf, Configuring cfd
@subsection TCP wrappers

Cfengine tries to incorporate the TCP wrappers package if you have it on
your system.  If you do, then the files @file{/etc/hosts.allow} and
@file{/etc/hosts.deny} allow you to give the cfengine/cfd service an extra
level of protection from `clever' spoofing attempts.


@c **********************************************************************
@c CHAPTER
@c **********************************************************************

@node Security and cfengine, Command reference, Cfengine network services, Top
@chapter Security and cfengine


@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@menu
* Hints for implementing security::  
* Who do you trust?::           
* Firewalls::                   
@end menu

@node Hints for implementing security, Who do you trust?, Security and cfengine, Security and cfengine
@section Security hints

Cfengine is not specifically a tool for implementing high security
solutions for system administration, but it has many features which can
be used to monitor the state of your systems and warn about potential
breaches in security. Here are some suggestions as to how you can be more
security conscious with cfengine's help.

@table @emph

@item CERT advisories
The CERT coordination centre (Computer Emergency Response Team) publishes
warnings about known bugs and security risks in computer systems
which can lead to compromised security. Their recommendations often
involve disabling certain programs, changing permissions to remove
setuid root flags and editing configuration files. These are things
which you can deal with using cfengine.
@cindex CERT advisories
@cindex Computer emergency response team 

@item disabling binaries
When to elect to disable a file, cfengine renames it, moves it to a
file repository (if you have defined one) and changes the mode
of the file to read only for its owner. This is sufficient to
disable binary programs and plain files.

@item The setuid log
Cfengine is always on the lookout for files which are setuid or setgid root.
It doesn't go actively looking for them, but whenever you get cfengine
to check a file or directory with the @code{files} feature, it will make
a note of setuid programs it finds there. These are recorded in the
file @file{cfengine.@var{host}.log} which is stored under @file{/etc/cfengine} or
@file{/var/log/cfengine}.
@cindex @file{/etc/cfengine}
@cindex @file{/var/log/cfengine}
@cindex setuid log
When new setuid programs are discovered, a warning is printed, but only
if you are @emph{root}. If you ever want a complete list, delete the log
file and cfengine will think that all of the setuid programs it finds
are new. The log file is not readable by normal users.
@cindex setuid root programs

@item Suspicious filenames
Whenever cfengine opens a directory and scans through files
(@code{files}, @code{tidy}, @code{copy}), it is on the lookout for for
suspicious filenames, i.e. files like @file{..  .} containing only space
and/or dots. Such files are never created by sensible people, but are
often used by hackers to try to hide dangerous programs. Cfengine
prints warnings about such files.
@cindex Suspicious filenames

@item Spoofing
Spoofing refers to attempts to masquerade as another host when sending
network transmissions. The @code{cfd} program attempts to unmask such
attempts by performing double reverse lookups in the name service. This
verifies by a trusted server that the socket address and the host name
are really who they claim to be. If you have the TCP wrappers package
on your system (libwrap)
@cindex TCP wrappers
@cindex Spoofing
then cfd will attempt to use it to detect other spoofs too, @xref{TCP
wrappers}. If you don't have TCP wrappers, then the only line of
defense is the double reverse lookup.

@item Race conditions in file copying
When copying files from a source, it is possible that something
might go wrong during the operation and leave a corrupt file in
place. For example, the disk might become full while copying
a file. This could lead to problems. Cfengine deals with this
by always copying to a new file on the destination filesystem
(prefix @file{.cfnew}) and then renaming it into place, only
if the transfer was successful. This ensures that there is
space on the filesystem and that nothing went wrong with
the network connection or the disk during copying.
@cindex .cfnew
@cindex Race conditions during copying
@cindex Disk full, problems during copying


@item @code{size=} in copy
As a further check on copying, cfengine allows you to define acceptable
limits on the size of files. After all, sometimes errors might occur
quite independently of anything you are doing with cfengine. Perhaps the
master password file got emptied somehow, or got replaced by a binary,
through some silly mistake. By checking making an estimate of the
expected size of the file and adding it to the copy command, you can
avoid installing a corrupt file and making a localized problem into a
global one.

@item @code{useshell=} in shellcommands
There are dangers in starting scripts from programs which run with root
privileges. Normally, shell commands are started by executing them with
the help of a @samp{/bin/sh -c} command. The trouble with this is that
it leaves one open to a variety of attacks. One example is fooling the
shell into starting foreign programs by manipulating the @code{IFS}
variable to treat '/' sa a separator. You can ask cfengine to start
programs directly, without involving an intermediary shell, by setting
the @code{useshell} variable to false. The disadvantage is that you will
not be able to use shell directives such as @samp{|} and @code{>} in
your commands.
@cindex Starting commands without a shell
@cindex Shell, starting programs
@cindex @code{/bin/sh -c} problem.
@cindex @code{useshell=}

@end table

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Who do you trust?, Firewalls, Hints for implementing security, Security and cfengine
@section Who do you trust?

All the developments of the last few years point to the unpleasant
fact that we need to be extra security conscious on the net.
In order to have any meaningful discussion about security, you need to
determine who you trust and who you don't trust.  No one from outside
your network can force cfengine to do anything you don't want it to do
(unless root access to your system has been compromised by another
route), but you might decide to collect a file from a remote server
which could sabotage your system a treat. Cfengine does not implement
more exacting security than normal host validation. If you are
collecting files from remote servers, you should make sure that they
come from a machine that you trust, particularly if they are files which
could lead to privileged access to your system. Cfengine places the
responsibility on you. You can make cfengine destroy your system, but
no one else can, so make sure you think about what you are doing.
@cindex Trust model

For example, it would be an extremely foolish idea to copy a binary
program such as @file{/bin/ps} from a host you know nothing about.
This program runs as root. If someone were to replace that version
of @file{ps} with a trojan horse command, you would have effectively
opened your system to attack.

Cfengine performs no cryptographic coding of messages at present, so if
you are sending sensitive data via cfengine, it should be coded in
advance. 

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Firewalls,  , Who do you trust?, Security and cfengine
@section Firewalls

Cfengine is a useful tool for implementing, monitoring and maintaining
firewalls. You can control what programs are supposed to be on the
firewall and what programs are not supposed to be there. You can control
file permissions, processes and a dozen other things which make up the
configuration of a bastion host. At some point in the future this
space might expand into a discussion about how you set up a bastion
host using cfengine.


@unnumbered @sc{Part II}

@sp 18

@center @titlefont{Reference section}

@c **********************************************************************
@c CHAPTER
@c **********************************************************************

@node Command reference, Writing scripts for cfengine, Security and cfengine, Top
@chapter Command reference


In this section you will find each facet of a cfengine program listed
together with an appropriate explanation.  The commands are presented in
alphabetical order for ease of lookup. Use this section in conjunction
with the example program @xref{Example configuration file}.


@menu
* acl::                         
* binservers::                  
* broadcast::                   
* control::                     
* classes::                     
* copy::                        
* defaultroute::                
* disks::                       
* directories::                 
* disable::                     
* editfiles::                   
* files::                       
* groups::                      
* homeservers::                 
* ignore::                      
* import::                      
* links::                       
* mailserver::                  
* miscmounts::                  
* mountables::                  
* processes::                   
* required::                    
* resolve::                     
* shellcommands::               
* tidy::                        
* unmount::                     
@end menu

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node acl, binservers, Command reference, Command reference
@section acl
@cindex Access control lists
@cindex ACLs

@cartouche
@smallexample

   acl:

      @var{class}::

         @{ @var{acl-alias}

         @var{action}
         @}

@end smallexample 
@end cartouche

@noindent

Cfengine's @code{ACL} feature is a common interface for managing
filesystem access control lists (ACLs). An access control list is an
extended file permission. It allows you to open or close a file to a
named list of users (without having to create a group for those users);
similarly, it allows you to open or close a file for a list of groups.
Several operating systems have access control lists, but each typically
has a different syntax and different user interface to this facility,
making it very awkward to use.  This part of a cfengine configuration
simplifies the management of ACLs by providing a more convenient user
interface for controlling them and---as far as possible---a common
syntax.

An ACL may, by its very nature, contain a lot of information. Normally
you would set ACLs in a @code{files} command, @xref{files}, or a
@code{copy} command, @xref{copy}. It would be too cumbersome to repeat
all of the information in every command in your configuration, so
cfengine simplifies this by first associating an alias together with a
complex list of ACL information. This alias is then used to represent
the whole bundle of ACL entries in a @code{files} or @code{copy}
command.  The form of an ACL is similar to the form of an
@code{editfiles} command.  It is a bundle of information concerning a
file's permissions.

@smallexample

 @{ @var{acl-alias}

  method:@b{overwrite}@var{/append}
  fstype:@var{posix/solaris/dfs/afs/hpux/nt}

  @var{acl_type}:@var{user/group}:@var{permissions}
  @var{acl_type}:@var{user/group}:@var{permissions}
  ...
 @}

@end smallexample

@noindent
The name @var{acl-alias} can be any identifier containing alphanumeric
characters and underscores. This is what you will use to refer to the
ACL entries in practice. The method entry tells cfengine how to
interpret the entries: should a file's ACLs be overwritten or only
adjusted?  Since the filesystems from different developers all use
different models for ACLs, you must also tell cfengine what kind of
filesystem the file resides on. Currently only solaris and DCE/DFS ACLs
are implemented.

@c .....................................................
@c SUBSECTION
@c .....................................................

@menu
* ACEs::                        
* Solaris ACLs::                
* DFS ACLs::                    
* ACL Example::                 
@end menu

@node ACEs, Solaris ACLs, acl, acl
@subsection Access control entries

An access control list is build of any number of individual access
control entries (ACEs). The ACEs has the following general syntax:

@smallexample
    @var{acl_type}:@var{user/group}:@var{permissions}
@end smallexample

@noindent
The user or group is sometimes referred to as a @emph{key}.
@cindex ACL key

For an explanation of ACL types and their use, refer to your local
manual page.  However, note that for each type of filesystem, there are
certain entries which must exist in an ACL. If you are creating a new
ACL from scratch, you must specify these.  For example, in solaris ACLs
you must have entries for @code{user}, @code{group} and @code{other}.
Under DFS you need what DFS calls a @code{user_obj}, @code{group_obj}
and an @code{other_obj}, and in some cases @code{mask_obj}. In cfengine
syntax these are called @code{user:*:}, @code{other:*:} and
@code{mask:*:}, as described below.  If you are appending to an existing
entry, you do not have to re-specify these unless you want to change
them.

Cfengine can overwrite (replace) or append to one or more ACL
entries.

@table @code

@item overwrite
@code{method:overwrite} is the default. This sets the ACL according to
the specified entries which follow.  The existing ACL will be
overwritten completely.

@item append
@code{method:append} adds or modifies one or more specified ACL entries.
If an entry already exists for the specified type and user/group, the
specified permission bits will be added to the old permissions. If there
is no ACL entry for the given type and user/group, a new entry will be
appended.

@end table
@noindent
If the new ACL exactly matches the existing ACL, the ACL is not
replaced.

The individual bits in an ACE may be either added subtracted or
set equal to a specified mask. The @samp{+} symbol means add,
the @samp{-} symbol subtract and @samp{=} means set equal to.
Here are some examples:
@smallexample

  @var{acltype}:@var{id/*}:@var{mask}

  user:mark:+rx,-w
  user:ds:=r
  user:jacobs:noaccess
  user:forgiven:default

  user:*:rw
  group:*:r
  other:*:r

@end smallexample

@noindent
The keyword @code{noaccess} means set all access bits to zero for that
user, i.e. remove all permissions. The keyword @code{default} means
remove the named user from the access crontrol list altogether, so that
the default permissions apply. A star/asterisk in the centre field
indicates that the user or group ID is implicitly specified as of the
owner of the file, or that no ID is applicable at all (as is the case for `other').

@node Solaris ACLs, DFS ACLs, ACEs, acl
@subsection Solaris ACLs

Under Solaris, the ACL type can be one of the following:

@smallexample
        user
        group
        mask
        other
        default_user
        default_group
        default_mask
        default_other
@end smallexample
@noindent
A user or group can be specified to the user, group, default_user and
default_group types.
Solaris ACL permissions are the normal UNIX permissions bits @samp{rwx},
where:

@smallexample
    @var{
        @b{r} - Grants read privileges.
        @b{w} - Grants write privileges.
        @b{x} - Grants execute privileges.}
@end smallexample
@noindent



@c .....................................................
@c SUBSECTION
@c .....................................................

@node DFS ACLs, ACL Example, Solaris ACLs, acl
@subsection DFS ACLs

@cindex DCE key
@cindex Key, ACL


In DCE, the ACL type can be one of the following:

@smallexample
        other
        mask
        any
        unauthenticated
        user
        group
        foreign_other
        foreign_user
        foreign_group
@end smallexample
@noindent
The @code{user}, @code{group}, @code{foreign_user} and @code{foreign_group}
 types require that you specify a user or group. The DCE documentation
refers to types @code{user_obj}, @code{group_obj} and so on. In the
cfengine implementation, the ugly @samp{_obj} suffix has been dropped to
make these more in keeping with the POSIX names. @code{user_obj::}, is
equivalent to @code{user:*:} is cfengine. The star/asterisk implies that
the ACL applies to the owner of the file object.

DFS permissions are comprised of the bits
@samp{crwxid}, where:
@smallexample
    @var{
        @b{c} - Grants control privileges, to modify an acl.
        @b{r} - Grants read  privileges.
        @b{w} - Grants write privileges.
        @b{x} - Grants execute privileges.
        @b{i} - Grants insert privileges.
        @b{d} - Grants delete privileges.}
@end smallexample
@noindent
See the DCE/DFS documentation for more information about this.

It is not possible to set ACLs in foreign cells currently using
cfengine, but you can still have all of your ACL definitions in the same
file. You must however arrange for the file to be executed on the server
for the cell concerned.  Note also that you must perform a DCE login
(normally as user @samp{cell_admin}) in order to set ACLs on files
which are not owned by the owner of the cfengine-process.  This is
because you must have a valid security ticket.


@c .....................................................
@c SUBSECTION
@c .....................................................

@node ACL Example,  , DFS ACLs, acl
@subsection ACL Example

Here is an example of a configuration file for one Solaris ACL and one DCE/DFS ACL:

@smallexample
control:
        actionsequence = ( files )
        domain = ( iu.hioslo.no )

files:
        $(HOME)/tt    acl=acl_alias1    action=fixall
        /:/bigfile    acl=acl_alias2    action=fixall

acl:
        @{ acl_alias1

        method:overwrite
        fstype:posix

        user:*:rwx
        user:mark:=rwx
        user:sowille:=rx
        user:toreo:=rx
        user:torej:default
        user:ds2:+rwx
        group:*:rx
        group:iu:r
        group:root:x
        mask:*:rx
        other:*:rx

        default_user:*:=rw
        default_user:mark:+rwx
        default_user:ds:=rwx
        default_group::=r
        default_group:iu:+r
        default_mask::w
        default_other::rwx
        @}
 
        @{ acl_alias2

        method:overwrite
        fstype:dfs

        user:*:rwxcid
        group:*:rxd
        other:*:wxir
        mask:*:rxw
        user:/.../iu.hioslo.no/cell_admin:rc
        group:/.../iu.hioslo.no/acct-admin:rwxcid
        user:/.../iu.hioslo.no/root:rx
        @}
@end smallexample



@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node binservers, broadcast, acl, Command reference
@section binservers
@cindex Binary servers, defining
@cindex Defining a binary server
@vindex binservers

The @code{binservers} declaration need only be used if you are using
cfengine's model for mounting NFS filesystems.  This declaration informs
hosts of which other hosts on the network possess filesystems containing
software (binary files) which client hosts should mount.  This includes
resources like programs in @code{/usr/local} and so on.  A host may have
several binary servers, since there may be several machines to which
disks are physically attached.  In most cases, on a well organized
network, there will be only one @emph{architecture server} per UNIX
platform type, for instance a SunOS server, an ULTRIX server and so on.

Binary servers are defined as follows:

@smallexample

binservers:

   physics.sun4::   sunserver sunserver2
   physics.linux::  linuxserver 

@end smallexample 

@noindent
The meaning of this declaration is the following.  All hosts of type
@code{sun4} which are members of the group @code{physics} should mount
any binaries declared in the @code{mountables} resource list which
belong to hosts @code{sunserver} or @code{sunserver2}.  Similarly all
@code{linux} machines should mount binary filesystems in the mountables
list from @code{linuxserver}.

Cfengine knows the difference between binaries and home directories in
the @code{mountables} list, because home directories match the pattern
given by @code{homepattern}.  @xref{homepattern}.  @xref{homeservers}.

Note that every host is a binary server for itself, so that the first
binary server (and that with highest priority) is always the current
host.  This ensures that local filesystems are always used in preference
to NFS mounted filesystems.  This is only relevant in connection with
the variable @code{$(binserver)}.
@cindex Binary servers, priority

@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node broadcast, control, binservers, Command reference
@section broadcast

@cindex Broadcast address
@vindex broadcast

This information is used to configure the network interface for each host.

Every local area network has a convention for determining which internet
address is used for broadcast requests.  Normally this is an address of
the form @code{aaa.bbb.ccc.255} or @code{aaa.bbb.ccc.0}.  The difference
between these two forms is whether all of the bits in the last number
are ones or zeroes respectively.  You must find out which convention is
used at your establishment and tell cfengine using a declaration of the
form:

@smallexample
broadcast:

  any::

     ones     # or zeros, or zeroes

@end smallexample 
@vindex ones
@vindex zeroes
@vindex zeros
@cindex ones
@cindex zeros

@noindent
In most cases you can use the generic class @code{any}, since all of the
hosts on the same subnet have to use the same convention.  If your
configuration file encompasses several different subnets with different
conventions then you will need to use a more specific.

Cfengine computes the actual value of the broadcast address using the
value specified above and the netmask @xref{netmask}.

@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node control, classes, broadcast, Command reference
@section control
@cindex control section
@vindex control

The fundamental piece of any cfengine script or configuration file is
the control section.  If you omit this part of a cfengine script, it
will not do anything! The control section is used to define certain
variables, set default values and define the order in which the various
actions you have defined will be carried out.  Because cfengine is a
declarative or descriptive language, the order in which actions appear
in the file does not necessarily reflect the order in which they are
executed. The syntax of declarations here is:

@cartouche
@smallexample
  control:

     @var{classes}::

        @var{variable} = ( @var{list or value} )

@end smallexample
@end cartouche

The control section is a sequence of declarations which looks something
like the following example:

@smallexample

control:

  site     = ( univ )
  domain   = ( univ.edu )
  sysadm   = ( admin@@computing.univ.edu )
  netmask  = ( 255.255.252.0 )
  timezone = ( EDT )
  nfstype  = ( nfs )

  sensiblesize  = ( 1000 )
  sensiblecount = ( 2 )
  editfilesize  = ( 4000 )

  actionsequence =
     (
     links.some
     mountall
     links.others
     files
     )

  myvariable = ( something )
  mymacro    = ( somethingelse )

@end smallexample 

@noindent
Parentheses are required when making a declaring information in cfengine.
@vindex site
@vindex domain
@vindex sysadm
@vindex netmask
@vindex timezone
@vindex nfstype
@vindex sensiblecount
@vindex sensiblesize
@vindex editfilesize
@vindex actionsequence

The meaning of each of these lines is described below.

@menu
* access::                      
* actionsequence::              
* addclasses::                  
* copylinks::                   
* domain::                      
* dryrun::                      
* editfilesize::                
* excludecopy::                 
* excludelinks::                
* ExpireAfter::                 
* homepattern::                 
* IfElapsed::                   
* Inform::                      
* interfacename::               
* linkcopies::                  
* mountpattern::                
* netmask::                     
* nfstype::                     
* repchar::                     
* repository::                  
* sensiblecount::               
* sensiblesize::                
* SplayTime::                   
* site::                        
* split::                       
* sysadm::                      
* Syslog::                      
* timezone::                    
* Verbose::                     
* Warnings::                    
@end menu

@c .....................................................
@c SUBSECTION
@c .....................................................

@node access, actionsequence, control, control
@subsection access
@cindex Access control
@vindex Restricting access

The @code{access} list is a list of users who are to be allowed to
execute a cfengine program.  If the list does not exist then all users
are allowed to run a program.

@smallexample
   access = ( @var{user1} @var{user2} ...  )
@end smallexample

@noindent
The list may consist of either numerical user identifiers or valid
usernames from the password database.  For example:

@smallexample
   access = ( mark aurora 22 456 )
@end smallexample

@noindent
would restrict a script to users mark, aurora and user id
22 and 456.


@c .....................................................
@c SUBSECTION
@c .....................................................

@node actionsequence, addclasses, access, control
@subsection actionsequence
@cindex action sequence
@vindex actionsequence

The action sequence determines the order in which collective actions are
carried out.  Here is an example containing the full list of
possibilities:

@smallexample
   actionsequence = 
      (
      mountall               # mount filesystems in fstab
      mountinfo              # scan mounted filesystems
      checktimezone          # check timezone
      netconfig              # check net interface config
      resolve                # check resolver setup
      unmount                # unmount any filesystems
      shellcommands          # execute shell commands
      editfiles              # edit files
      addmounts              # add new filesystems to system
      directories            # make any directories
      links                  # check and maintain links (single and child)
      simplelinks            # check only single links (separate from childlinks)
      childlinks             # check only childlinks (separate from singlelinks)
      mailcheck              # check mailserver
      mountall               # (again)
      required               # check required filesystems
      tidy                   # tidy files
      disable                # disable files
      files                  # check file permissions 
      copy                   # make a copy/image of a master file
      processes              # signal / check processes
      )

@end smallexample 

@vindex mountall
@vindex mountinfo
@vindex checktimezone
@vindex netconfig
@vindex childlinks
@vindex singlelinks
@vindex resolve
@vindex unmount
@vindex shellcommands
@vindex editfiles
@vindex addmounts
@vindex directories
@vindex links
@vindex mailcheck
@vindex required
@vindex tidy
@vindex disable
@vindex files 
@vindex processes

@noindent
Here is a more complete description of the meaning of these
keywords.

@table @code

@item addmounts
causes cfengine to compute which NFS filesystems are missing from the
current host and add them. This includes editing the filesystem table,
creating the mount-directory, if required.  This command relies on
information provided by @code{mountinfo}, so it should normally only be
called after @code{mountinfo}. If the filesystem already appears
to be in the filesystem table, a warning is issued.

@item checktimezone
runs a check on the timezone defined for the shell running
cfengine.

@item directories
executes all the commands defined under the @code{directories}
section of the program. It builds new directories.

@item disable
executes all the commands defined under the @code{disable}
section of the program.

@item editfiles
executes all the commands defined under the @code{editfiles}
section of the program.

@item files
executes all the commands defined under the @code{files}
section of the program.

@item links
executes all the commands defined under the @code{links}
section of the program. Here one can also write @code{singlelinks}
which checks only single (not multiply linked) objects, or
@code{childlinks} which checks the remainder (multiply linked)
objects. In this way one can separate these two actions if
required, though normally this is not necessary.

@item mailcheck
tests for the presence of the NFS-mounted mail spooling directory on the
current host. The name of the mail spool directory is defined in the
@code{mailserver} section of the cfengine program. If the current host
is the same as the mailserver (the host which has the physical spool
directory disk) nothing is done. Otherwise the filesystem table is
edited so as to include the mail directory.
  
@item mountall
mounts all filesystems defined in the hosts filesystem table.  This
causes new NFS filesystems added by @code{addmounts} and
@code{mailcheck} to be actually mounted. This should probably be called
both before @code{mountinfo} and after @code{addmounts} etc.  A short
timeout is placed on this operation to avoid hanging RPC connections
when parsing NFS mounted file systems.

@item mountinfo  
builds internal information about which filesystems are presently
mounted on the current host.  Cfengine assumes that required-filesystems
which are not found need to be mounted. A short timeout is
placed on this operation to avoid hanging RPC connections
when parsing NFS mounted file systems. If this times out,
no further mount operations are considered reliable and are
summarily cancelled.

@item netconfig
checks the netmask, hostname, IP address and broadcast
address for the current host. The correct values for
the netmask and broadcast address are set if there is
an error. The defaultroute is also added to the static
routing table.

@item required
executes all the commands defined under the @code{required}
section of the program. It checks for the absence of
important NFS resources.

@item resolve
checks and corrects the DNS domain name and the order
of nameservers in the file @file{/etc/resolv.conf}.

@item shellcommands
executes all the commands defined under the @code{shellcommands}
section of the program.

@item tidy
executes all the commands defined under the @code{tidy}
section of the program.

@item unmount
executes all the commands defined under the @code{unmount}
section of the program. The filesystem table is edited
so as to remove the unwanted filesystems and the unmount
operation is executed.

@item processes
executes commands defined under the @code{processes} section
of the program.

@end table

Under normal circumstances this coarse ordering is enough to suit most
purposes.  In some cases you might want to, say, only perform half the
link operations before mounting filesystems and then, say, perform the
remainder.  You can do this (and similar things) by using the idea of
defining and undefining classes @xref{Defining classes}.

The syntax

@smallexample

actionsequence =
   (
   links.firstpass.include
   ...
   links.secondpass
   )
@end smallexample 

@noindent
means that cfengine first executes @code{links} with the classes
@code{firstpass} and @code{include} @emph{defined}.  Later it executes
@code{links} with @code{secondpass} defined.  You can use this method of
adding classes to distinguish more finely the flow of control in
programs.
@cindex Negating classes


A note about style: if you define and undefine lots of classes to do
what you want to do, you might stop and ask yourself if your
@code{groups} are defined as well as they should be.  @xref{groups}.
Programming in cfengine is about doing a lot for only a little
writing.  If you find yourself writing a lot, you are probably not going
about things in the right way.



@c .....................................................
@c SUBSECTION
@c .....................................................

@node addclasses, copylinks, actionsequence, control
@subsection AddClasses
@cindex Defining classes
@cindex Adding defined classes
@cindex Classes, adding and defining
@vindex AddClasses

@example
   AddClasses  = ( @var{list of identifiers} ) 
@end example

The @code{AddClasses} directive is used to define a list of class
attributes for the current host.  Normally only the hard classes defined
by the system are `true' for a given host.  It is convenient though to
be able to define classes of your own to label certain actions, mainly
so that they can later be excluded so as to cut short or filter out
certain actions.  This can be done in two ways.  @xref{actionsequence}.

To define a list of classes for the current session, you write:

@smallexample
AddClasses = ( exclude shortversion )
@end smallexample 

@noindent
This is equivalent to (though more permanent than) defining
classes on the command line with the @code{-D} option.  
@vindex -D option
@cindex -D option
@cindex Defining classes
You can now use these to qualify actions.  For example

@smallexample

  any.exclude::
      ...
@end smallexample 

Under normal circumstances @code{exclude} is always true --- because you
have defined it to be so, but you can @emph{undefine} it in two ways so
as to prevent the action from being carried out.  One way is to undefine
a class on the command line when you invoke cfengine:
@vindex -N option
@cindex Excluding classes

@example
@cartouche
host#  cfengine -N exclude
@end cartouche
@end example

@noindent
or

@example
@cartouche
host#  cfengine -N exclude.shortversion

host#  cfengine -N a.b.c.d
@end cartouche
@end example

@noindent
These commands run cfengine with the named classes @emph{undefined}.
That means that actions labelled with these classes are excluded during
that run.

Another way to restrict classes is to add a list of classes to be
undefined in the actionsequence.  See next section.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node copylinks, domain, addclasses, control
@subsection CopyLinks
This list is used to define a global list of names or patterns
which are to be copied rather than linked symbolically. For example

@smallexample
CopyLinks = ( *.config )
@end smallexample
The same facility can be specified for each individual
link operation using the @code{copy} option @xref{links}.
Copying is performed using a file age comparison.

Note that all entries defined under a specified class
are valid only as long as that class is defined. For instance
@smallexample
  @var{class}::

      CopyLinks = ( @var{pattern} )
@end smallexample
@noindent
would define a pattern which was only valid when
@var{class} is defined.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node domain, dryrun, copylinks, control
@subsection domain
@cindex domain
@vindex domain

@example
  domain = ( @var{domain name} )
@end example

This variable defines the domainname for your site.  You must define it
here, because your system might not know its domainname when you run
cfengine for the first time.  The domainname can be used as a cfengine
variable subsequently by referring to $(domain).  The domainname
variable is used by the action @code{resolve}.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node dryrun, editfilesize, domain, control
@subsection DryRun
@cindex DryRun
@vindex DryRun
@smallexample

  DryRun = ( @var{on/}@b{off} )

@end smallexample

This variable has the same effect as the command line options
@kbd{--dry-run} or @kbd{-n}. It tells cfengine to only report
what it should do without actually doing it.
@smallexample

 @var{classes}::

   DryRun = ( on )

@end smallexample



@c .....................................................
@c SUBSECTION
@c .....................................................

@node editfilesize, excludecopy, dryrun, control
@subsection editfilesize
@cindex Restricting the size of files to be edited
@vindex editfilesize

@example
   EditfileSize  = ( @var{size} ) 
@end example

This variable is used by cfengine every time it becomes necessary to
edit a file.  Since file editing applies only to text files, the files
are probably going to be relatively small in most cases.  Asking to edit
a very large (perhaps binary) file could therefore be the result of an
error.

A check is therefore made as a security feature.  Cfengine will refuse
to edit a file which is larger than the value of @code{editfilesize} in
bytes.  This is to prevent possible accidents from occurring.  The
default value for this variable is 1000 bytes.  If you don't like this
feature, simply set the value to be a very large number or to zero.
If the value is zero, cfengine will ignore it.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node excludecopy, excludelinks, editfilesize, control
@subsection ExcludeCopy
This list is used to define a global list of names or patterns
which are to be excluded from copy operations. For example

@smallexample
 ExcludeCopy = ( *~ *% core )
@end smallexample
The same facility can be specified for each individual
link operation using the @code{exclude} option @xref{copy}.

Note that all entries defined under a specified class
are valid only as long as that class is defined. For instance
@smallexample
  @var{class}::

      ExcludeCopy = ( @var{pattern} )
@end smallexample
@noindent
would define a pattern which was only valid when
@var{class} is defined.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node excludelinks, ExpireAfter, excludecopy, control
@subsection ExcludeLinks
This list is used to define a global list of names or patterns
which are to be excluded from linking operations. For example

@smallexample
 ExcludeLinks = ( *~ *% core )
@end smallexample
The same facility can be specified for each individual
link operation using the @code{exclude} option @xref{links}.

Note that all entries defined under a specified class
are valid only as long as that class is defined. For instance
@smallexample
  @var{class}::

      ExcludeLinks = ( @var{pattern} )
@end smallexample
@noindent
would define a pattern which was only valid when
@var{class} is defined.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node ExpireAfter, homepattern, excludelinks, control
@subsection ExpireAfter

This parameter controls the global value of the ExpireAfter parameter,
@xref{Spamming and security}. This parameter controls the maximum time
in minutes which a cfengine action is allowed to live. After this time
cfengine will try to kill the cfengine which seems to have hung and
attempt to restart the action.

@cartouche
@smallexample
 
 ExpireAfter = ( @var{time-in-minutes} )

@end smallexample
@end cartouche

@noindent
This parameter may also be set per action in the action
sequence by appending a pseudo-class called @code{ExpireAfter@var{time}}.
For instance,

@smallexample
 
 actionsequence = ( copy.ExpireAfter15 )

@end smallexample

@noindent
sets the expiry time parameter to 15 minutes for this copy command.


@c .....................................................
@c SUBSECTION
@c .....................................................

@node homepattern, IfElapsed, ExpireAfter, control
@subsection HomePattern
@cindex Home path
@cindex Path to home directories
@vindex HomePattern

@example
   HomePattern  = ( @var{list of wildcards} ) 
@end example


The @code{homepattern} variable is used by the cfengine model for
mounting nfs filesystems.  @xref{NFS resources}.  
It is also used in the evaluation of the pseudo variable
@code{home}, See @ref{files}, @ref{tidy}.

@code{homepattern} is in fact a list and is used like a wildcard or
@emph{pattern} to determine which filesystems in the list of mountables
are home directories.  @xref{mountables}.  This relies on your sticking
to a rigid naming convention as described in the first reference above.

For example, you might wish to mount (or locate directly if you are not
using a separate partition for home directories) your home directories
under @code{mountpattern} in directories @code{u1}, @code{u2} and so on.
In this case you would define @code{homepattern} to match these numbers:

@cindex Wildcards in homepattern
@cindex Searching for home directories
@smallexample
homepattern = ( u? )
@end smallexample 

@noindent
Cfengine now regards any directory matching
@code{$(mountpattern)/u?} as being a user login directory.

Here is another example in which you split up a single partition into
subdirectories.  Suppose you want to create mount home directories under
@code{$(mountpattern)/home} and make subdirectories for staff and
students.  Then you would write:

@smallexample
 HomePattern = ( home/staff home/students )
@end smallexample 

@noindent
Or you could combine the two:

@smallexample
 HomePattern = ( u?/staff u?/students )
@end smallexample 

@c .....................................................
@c SUBSECTION
@c .....................................................

@node IfElapsed, Inform, homepattern, control
@subsection IfElapsed

This parameter controls the global value of the IfElapsed
parameter, @xref{Spamming and security}. This parameter
controls the minimum time which must have elapsed for
an action in the action sequence before which it will be
executed again.

@cartouche
@smallexample
 
 IfElapsed = ( @var{time-in-minutes} )

@end smallexample
@end cartouche

@noindent
This parameter may also be set per action in the action
sequence by appending a pseudo-class called @code{IfElapsed@var{time}}.
For instance,

@smallexample
 
 ActionSequence = ( copy.IfElapsed15 )

@end smallexample

@noindent
sets the elapsed time parameter to 15 minutes for this copy command.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Inform, interfacename, IfElapsed, control
@subsection Inform

@smallexample

  Inform = ( @var{on/}@b{off} )

@end smallexample

This variable switches on the output level whereby cfengine
reports changes it makes during a run. Normally only
urgent messages or clear errors are printed. Setting
@code{Inform} to @code{on} makes cfengine report on
all actions not explicitly cancelled with a `silent' option.
To set this output level one writes:

@smallexample

 @var{classes}::

   Inform = ( on )

@end smallexample

@c .....................................................
@c SUBSECTION
@c .....................................................

@node interfacename, linkcopies, Inform, control
@subsection InterfaceName
@cindex InterfaceName
@vindex InterfaceName
@cindex Interface name, redefining by class

If you have an operating system which is installed on some
non-standard hardware, you might have to specifically set the
name of the network interface. For example:

@smallexample

  control:

    nextstep.some::

       InterfaceName = ( en0 )

    nextstep.others::

       InterfaceName = ( ec0 ) 

@end smallexample
@noindent
It is only necessary to set the interface name in this fashion
if you have an operating system which is running on special
hardware. Most users will not need this.
The choice set here overrides the system defaults and the
choices made in the @file{cfrc} file, @xref{cfrc resource file}.




@c .....................................................
@c SUBSECTION
@c .....................................................

@node linkcopies, mountpattern, interfacename, control
@subsection LinkCopies

This list is used to define a global list of names or patterns
which are to be linked symbolically rather than copied. For example

@smallexample
excludelinks = ( *.gif *.jpg )
@end smallexample
The same facility can be specified for each individual
link operation using the @code{symlink} option @xref{copy}.

Note that all entries defined under a specified class
are valid only as long as that class is defined. For instance
@smallexample
  @var{class}::

      LinkCopies = ( @var{pattern} )
@end smallexample
@noindent
would define a pattern which was only valid when
@var{class} is defined.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node mountpattern, netmask, linkcopies, control
@subsection mountpattern
@cindex Mount paths
@cindex Path to mounted filesystems
@vindex mountpattern

@example
   mountpattern  = ( @var{mount-point} ) 
@end example


The @code{mountpattern} list is used by the cfengine model for
mounting nfs filesystems.  @xref{NFS resources}.  
It is also used in the evaluation of the pseudo variable
@code{home}, See @ref{files}, @ref{tidy}.

It is used together with the value of @code{homepattern} to locate and
identify what filesystems are local to a given host and which are
mounted over the network.  For this list to make sense you need to
stick to a rigid convention for mounting your filesystems under a single
naming scheme as described in the section mentioned above.  If you
follow the recommended naming scheme then you will want to set the value
of mountpattern to

@smallexample
mountpattern = ( /$(site)/$(host) )
@end smallexample 

@noindent
which implies that cfengine will look for local disk partitions under a
unique directory given by the name of the host and site.  Any
filesystems which are physically located on the current host lie in this
directory.  All mounted filesystems should lie elsewhere. If you
insist on keeping mounted file systems in more than one location, you
can make a list like this:

@smallexample
mountpattern = ( /$(site)/users /$(site)/projects )
@end smallexample 

@c .....................................................
@c SUBSECTION
@c .....................................................

@node netmask, nfstype, mountpattern, control
@subsection netmask
@cindex netmask
@vindex netmask

@example
   netmask = ( @var{aaa.bbb.ccc.ddd} )
@end example

The netmask variable defines the partitioning of the subnet addresses on
your network.  Its value is defined by your network administrator.  On
most systems it is likely to be @code{255.255.255.0}.  This is used to
configure the network interface in @code{netconfig}.
@xref{actionsequence}.


@cindex Domain name
@cindex IP address
@cindex Internet address
@cindex Netmask
@cindex Subnet mask
Every host on the internet has its own unique address.  The addresses
are assigned hierarchically.  Each network gets a @emph{domain name} and
can attach something like 65,000 hosts to that network.  Since this is
usually too many to handle in one go, every such network may be divided
up into subnets.  The administrator of the network can decide how the
division into subnets is made.  The decision is a trade-off between
having many subnets with few hosts, or many hosts on few subnets.  This
choice is made by setting the value of a variable called @code{netmask}.
The netmask looks like an internet address.  It takes the form:

@example

   aaa.bbb.ccc.mmm

@end example

@noindent
The first two numbers @samp{aaa.bbb} are the address of the domain.  The
remainder @samp{ccc.mmm} specifies both the subnet and the hostname.
The value of @code{netmask} tells all hosts on the network: how many of
the bits in the second half label different subnets and how many label
different hosts on each of the subnets?

The most common value for the netmask is @samp{255.255.255.0}.  It is
most helpful to think of the netmask in terms of bits.  Each base-10
number between 0-255 represents 8 bits which are either set or not set.
Every bit which is set is a network address and every bit which is zero
is part of a host address.  The first two parts of the address
@samp{255.255} always takes these values.  If the third number is
@samp{255}, it means that the domain is divided up into 256 sub networks
and then the remaining bits which are zero can be used to give 255
different host addresses on each of the subnets.

If the value had been @samp{255.255.255.254}, the network would be
divided up into @math{2^15} subnets, since fifteen of the sixteen bits
are one.  The remaining bit leaves enough room for two addresses 0 and
1.  One of those is reserved for @emph{broadcasts} to all hosts, the
other can be an actual host --- there would only be room for one host
per subnet.  This is a stupid example of course, the main point with the
subnet mask is that it can be used to trade subnets for hosts per
subnet.  A value of @samp{255.255.254.0} would allow 128 different
subnets with @math{2*256-1 = 511} hosts on each.

We needn't be concerned with the details of the netmask here.  Suffice
it to say that its value is determined for your entire domain by the
network administrator and each host has to be told what the value is.

Each host must also know what convention is used for the @emph{broadcast
address}.  This is an address which hosts can send to if they wish to
send a message to every other host on their subnet simultaneously.  It is
used a lot by services like NIS to ask if any hosts are willing to
perform a particular service.  There are two main conventions for the
broadcast address: address zero (all host bits are zero) and the highest
address on the subnet (all host bits are ones).  The convention can be
different on every subnet and it is decided by the network
administrator.  When you write a cfengine program you just specify the
convention used on your subnet and cfengine works out the value of the
broadcast address from the netmask and the host address
@xref{broadcast}.  Cfengine works out the value of the broadcast address
using the value of the netmask.


@c .....................................................
@c SUBSECTION
@c .....................................................

@node nfstype, repchar, netmask, control
@subsection nfstype
@cindex nfs
@cindex nfstype
@vindex nfstype

@example
   nfstype = ( @var{nfs-type} ) 
@end example

This variable is included only for future expansion.  If you do not
define this variable, its value defaults to ``nfs''.

At present cfengine operates only with NFS (the network file system).
When cfengine looks for network file systems to mount, it adds lines in
the filesystem table (@samp{/etc/fstab},@samp{/etc/checklist} etc.)  to
try to mount filesystems of type ``nfs''.  In principle you might want
to use a completely different system for mounting filesystems over the
network, in which case the `mount type' would not be ``nfs'' but
something else.

At the time of writing certain institutions are replacing NFS with AFS
(the Andrew filesystem) and DFS (from the distributed computing
environment).  The use of these filesystems really excludes the need to
use the mount protocol at all.  In other words if you are using AFS or
DFS, you don't need to use cfengine's mounting commands at all.
@cindex AFS
@cindex Andrew filesystem
@cindex DFS

@c .....................................................
@c SUBSECTION
@c .....................................................

@node repchar, repository, nfstype, control
@subsection RepChar

@example
   RepChar  = ( @var{character} ) 
@end example

The value of this variable determines the characters which is used by
cfengine in creating the unique filenames in the file
repository. Normally, its value is set to @samp{_} and each @samp{/} in
the path name of the file is changed to @samp{_} and stored in the
repository. If you prefer a different character, define it here. Note
that the character can be quoted with either single or double quotes in
order to encompass spaces etc.
@vindex RepChar
@cindex Repository filenames, changing
@mbindex Changing repository name conventions

@c .....................................................
@c SUBSECTION
@c .....................................................

@node repository, sensiblecount, repchar, control
@subsection Repository


@example
   Repository  = ( @var{directory} ) 
@end example

Defines a special directory where all backup and junk
files are collected. Files are assigned a unique filename
which identifies the path from which they originate.
This affects files saved using @code{disable}, @code{copy},
@code{links} and @code{editfiles} @xref{Disabling and the file repository}.


@c .....................................................
@c SUBSECTION
@c .....................................................

@node sensiblecount, sensiblesize, repository, control
@subsection SensibleCount
@cindex Sensible limits on files in a directory
@vindex SensibleCount

@example
   SensibleCount  = ( @var{count} ) 
@end example

This variable is used by the action @code{required}.  It defines for
cfengine what you consider to be the minimum number of files in a
`required' directory.  If you declare a directory as being required,
cfengine will check to see if it exists.  Then, if the directory
contains fewer than the value of @code{sensiblecount} files, a warning
is issued.  The default value for this variable is 2.


@c .....................................................
@c SUBSECTION
@c .....................................................

@node sensiblesize, SplayTime, sensiblecount, control
@subsection SensibleSize
@cindex Sensible file sizes
@vindex SensibleSize

@example
   SensibleSize  = ( @var{size} ) 
@end example

This variable is used by the action @code{required}.  It defines for
cfengine what you consider to be the minimum size for a `required' file.
If you declare a file as being required, cfengine will check to see if
the file exists.  Of course, the file may exist but be empty, so the
size of the file is also checked against this constant.  If the file is
smaller than the value of @code{sensiblesize} a warning is issued.  The
default value for this variable is 1000 bytes. 


@c .....................................................
@c SUBSECTION
@c .....................................................

@node SplayTime, site, sensiblesize, control
@subsection SplayTime

@example
  SplayTime = ( @var{time-in-minutes} )
@end example

This variable is used to set the maximum time over
which cfengine will share its load on a server,
@xref{Splaying host times}.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node site, split, SplayTime, control
@subsection site/faculty
@cindex site
@vindex site

@example
  site    = ( @var{sitename} )
  faculty = ( @var{facultyname} )
@end example

This variable defines a convenient name for your site configuration.  It
is useful for making generic rules later on, because it means for
instance that you can define the name of a directory to be

@smallexample
/$(site)/$(host)/local
@end smallexample 

@noindent
without having to redefine the rule for a specific site.  This is a
handy trick for making generic rules in your files which can be imported
into a configuration for any site.

@code{faculty} is a synonym for @code{site}.  The two names
may be used interchangeably.


@c .....................................................
@c SUBSECTION
@c .....................................................

@node split, sysadm, site, control
@subsection Split

@example
   Split  = ( @var{character} ) 
@end example

The value of this variable is used to define the list separator in
variables which are expected to be treated as lists. The default value
of this variable is the colon @samp{:}.  Cfengine treats variables
containing this character as lists to be broken up and iterated over in
the following cases:

@itemize @bullet

@item
in the `to' field of a multiple link action,

@item
in the `from' field of a copy action,

@item
in the directory field of a tidy action,

@item
in the directory field of the files action,

@item
in the ignore action.

@end itemize

This typically allows communication with PATH-like 
environment variables in the shell.
@cindex split
@cindex Iteration over lists
@mbindex Iterating over lists
@vindex split

@c .....................................................
@c SUBSECTION
@c .....................................................

@node sysadm, Syslog, split, control
@subsection sysadm
@cindex sysadm
@vindex sysadm

@example
   sysadm = ( @var{mail address} )
@end example

The mail address of your system administrator should be placed here.
This is used in two instances.  If cfengine is invoked with the option
@code{-a}, then it simply prints out this value.  This is a handy
feature for making scripts.  @xref{Using the help scripts}.

The administrators mail address is also written into the personal log
files which cfengine creates for each user after tidying files, so you
should make this an address which users can mail if they have troubles.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Syslog, timezone, sysadm, control
@subsection Syslog

@smallexample

  Syslog = ( @var{on/}@b{off} )

@end smallexample

This variable activates syslog logging of cfengine output at
the `inform' level.

To set this output level one writes:

@smallexample

 @var{classes}::

   Syslog = ( on )

@end smallexample


@c .....................................................
@c SUBSECTION
@c .....................................................

@node timezone, Verbose, Syslog, control
@subsection timezone

@example
   timezone = ( @var{3-character timezone} )
@end example

The timezone variable is a character string which defines your local
timezone.  Currently only the first three characters of this string are
checked against the timezone which cfengine manages to glean from the
system.  If a mismatch is detected a warning message is printed.
cfengine does not attempt to configure the timezone.  This feature works
only as a reminder, since the timezone should really be set once and for
all at the time the system is installed.  On some systems you can set
the timezone by editing a file, a procedure which you can automate with
cfengine @xref{editfiles}.

The value of the @code{timezone} can be accessed by variable substitution
in the usual way:

@smallexample
shellcommands:

       "echo $@{timezone@} | mail $@{sysadm@}"

@end smallexample

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Verbose, Warnings, timezone, control
@subsection Verbose

@smallexample

  Verbose = ( @var{on/}@b{off} )

@end smallexample

This variable switches on the output level whereby cfengine
reports everything it does during a run in great detail. Normally only
urgent messages or clear errors are printed, @xref{Inform}.
This option is almost equivalent to using the @kbd{--verbose} of @kbd{-v}
command-line options. The only difference is that system environment reporting
information, which is printed prior to parsing, is not shown.
To set this output level on selected hosts one writes:

@smallexample

 @var{classes}::

   Verbose = ( on )

@end smallexample

For related more limited output, @xref{Inform}.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Warnings,  , Verbose, control
@subsection Warnings


@smallexample

  Warnings = ( @var{on/}@b{off} )

@end smallexample

This variable switches on the parser-output level whereby cfengine
reports non-fatal warnings.  This is equivalent to setting the command
line switch @kbd{--no-warn}, or @kbd{-w}.  To set this output level on
selected hosts one writes:

@smallexample

 @var{classes}::

   Warnings = ( on )

@end smallexample

@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node classes, copy, control, Command reference
@section classes
@cindex @code{classes}
@cindex Defining classes
@cindex groups

The @code{classes} keyword is an alias for @code{groups} as of
version 1.4.0 of cfengine.

@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node copy, defaultroute, classes, Command reference
@section copy
@cindex copy
@cindex Copying files
@cindex File images (copy)

Cfengine copies files between locally mounted filesystems and via the
network from registered servers.  The copy algorithm avoids
race-conditions which can occur due to network and system latencies by
copying first to a file called @file{@var{file}.cfnew} on the local
filesystem, and then renaming this quickly into place.  The aim of this
roundabout procedure is to avoid situations where the direct rewriting
of a file is interrupted midway, leaving a partially written file to be
read by other processes.  Cfengine attempts to preserve hard links to
non-directory file-objects, but see the caution below.
@cindex @file{.cfnew} files
The syntax summary is:

@cartouche
@smallexample

copy:

   @var{class}::

      @var{master-file} 
                        dest=@var{destination-file} 
                        mode=@var{mode}
                        owner=@var{owner} 
                        group=@var{group} 
                        action=@var{silent/fix}
                        backup=@b{true}@var{/false}
                        symlink=@var{pattern}
                        include=@var{pattern}
                        exclude=@var{pattern} 
                        recurse=@var{number/inf/}@var{0}
                        type=@b{ctime}@var{/checksum/sum/byte/binary}
                        linktype=@b{absolute/symbolic}@var{/relative/hard}
                        define=@var{class-list(,:.)} 
                        force=@var{true/on}/@b{false/off}
                        size=@var{size limits}
                        server=@var{server-host}
                        purge=@var{true/}@b{false}

@end smallexample
@end cartouche

@noindent

@table @code

@item dest
The destination file is the only obligatory item. This must be the name
of an object which matches the type of the master object i.e. if the
master is a plain file, the destination must also be the explicit name
of a plain file. An implicit `copy file to directory' syntax is not
allowed.  Symbolic links are copied as symbolic links, plain files are
copied as plain files and special files are copied as special files. If
the master and image are directories then all of the child files
@emph{which are not directories} are copied from source to destination.

@item mode, owner, group
The file mode, owner
and group of the images are specified as in the @code{files} function
@xref{files}. 

@item action
The action may take the values @code{warn} or
@code{silent}. The default action is @code{fix}, i.e.  copy files. If @code{warn}
is specified, only a warning is issued about files which require
updating. If @code{silent} is given, then cfengine will copy the files
but not report the fact. 

@item force
If set to `true', this option causes cfengine to copy files regardless
of whether it is up to date.

@item backup
If the @code{backup} option is set to "false", cfengine
will not make a backup copy of the file before copying.
@cindex Backup of files in copy
@vindex backup=
@cindex Switching off backup in copy

Copy makes a literal image of the master file at the destination,
checking whether the master is newer than the image. If the image needs
updating it is copied. Existing files are saved by appending
@code{.cfsaved} to the filename.

@item recurse
Specifies the depth of recursion when copying whole file-trees
recursively. The value may be a number or the keyword @code{inf}.
Cfengine crosses device boundaries or mounted filesystems when
descending recursively through file trees. To prevent
this it is simplest to specify a maximum level of recursion.
@cindex Device boundaries
@cindex Mounted filesystems

@item symlink
This option may be repeated a number of times to specify the
names of files, or wildcards which match files which are to
be symbolically linked instead of copied. A global list of
patterns can also be defined in the control section of the program
@xref{linkcopies}.

@item include
This option may be repeated a number of times to specify the names of
files, or wildcards which match files which are to be included in a copy
operation. Specifying one of these automatically excludes everything
else except further include patterns.  A global list of patterns can
also be defined in the control section of the program.

@item exclude
This option may be repeated a number of times to specify the
names of files, or wildcards which match files which are to
be excluded from a copy operation. A global list of
patterns can also be defined in the control section of the program
`excludes' override `includes'.
@xref{excludelinks}.

@item type
Normally cfengine uses the ctime date-stamps on files to determine
whether a file needs to be copied: a file is only copied if the master
is newer than the copy or if the copy doesn't exist. If the type is set
to @samp{checksum} or @samp{sum}, then a secure MD5 checksum is used to
determine whether the source and destination files are identical. If
@samp{byte} or @samp{binary} is specified, a byte by byte comparison is
initiated. 

@item server
If you want to copy a file remotely from a server, you specify the
name of the server here. This must be the name of a host which is
running the @code{cfd} daemon, and you must make sure that you
have defined the variable @code{domain} in the control section
of the @file{cfengine.conf} file. If you don't define a domain
you will probably receive an error of the form `cfengine: Hey! cannot
stat file'.
@mbindex Hey! Cannot stat file error
@mbindex Remote copy problems, can't stat

@item size
With this option you can specify that a file is only to be copied if the
source file meets a size critereon. This could be used to avoid
installing a corrupted file (the copying of an empty password file, for
instance). Sizes are in bytes by default, but may also be quoted in
kilobytes or megabytes using the notation:
@smallexample

@var{number}bytes
@var{number}kbytes
@var{number}mbytes

@end smallexample
@noindent
Only the first characters of these strings are significant, so they may
be written however is convenient: e.g. @kbd{14kB}, @kbd{14k},
@kbd{14kilobytes} etc.
 Examples are:

@smallexample

   size=<400  # copy if file size is < 400 bytes
   size=400   # copy if file size is equal to 400 bytes
   size=>400  # copy if file size > 400 bytes

@end smallexample
@noindent

@item linktype
This option determines the type of link used to make links. This only
applies if the file is linked rather than copied because it matches
a pattern set by @code{symlink}. The default type is a direct symbolic
link. The values @samp{relative} or @samp{absolute} may be used, but
hard links may not be created in place of copied files, since hard links
must normally reside on the same filesystem as their files, and it
is assumed that most links will be between filesystems.

@item define
This option is followed by a list of classes which are to be `switched on'
if and only if the named file was copied.  In multiple (recursive) copy
operations the classes become defined if any of the files in the file
tree were copied. This feature is useful for switching on other actions
which are to be performed after the installation of key files (e.g.
package installation scripts etc).

@item purge
If this option is set to true, cfengine will remove files in the
destination directory which are not also in the source directory.
This allows exact images of filesystems to be mantained.
@vindex purge=
@cindex Copy, exact filetree images
@cindex File tree images
@cindex Tree copying, exact

@end table

Example:

@smallexample

copy:

      /local/etc/aliases dest=/etc/aliases m=644 o=root g=other
      /local/backup-etc  dest=/etc

   solaris::

      /local/etc/nsswitch.conf dest=/etc/nsswitch.conf

@end smallexample

@noindent
In the first example, a global aliases file is copied from the master
site file @file{/local/etc/aliases} to @file{/etc/aliases}, setting the
owner and protection as specified. The file gets installed if
@file{/etc/aliases} doesn't exist and updated if @file{/local/etc/aliases}
is newer than @file{/etc/aliases}. In the second example, @file{backup-etc}
is a directory containing master configuration files (for instance, @file{services},
@file{aliases}, @file{passwd}...). Each of the files in @file{backup-etc}
is installed or updated under @file{/etc}. Finally, a global
@file{nsswitch.conf} file is kept up to date for solaris systems.

The @code{home} directive can be used as a destination, in which
case cfengine will copy files to every user on the system. This is
handy for distributing setup files and keeping them updated:

@smallexample

copy:

   /local/masterfiles/.cshrc  dest=home/.cshrc mode=0600

@end smallexample

@noindent
You can force the copying of files, regardless of the date stamps
by setting the option @code{force=true} or @code{force=on}. The default
is @code{force=false} or @code{force=off}.
@cindex Force copying
@vindex force=

@menu
* hard links in copy::          
* Too many open files::         
@end menu

@node hard links in copy, Too many open files, copy, copy
@subsection Hard links in copying

Hard links are not like symbolic links, they are not merely pointers to
other files, but alternative names for the same file. The name of every
file is a hard link, the first so to speak. You can add additional names
which @emph{really are} the file, they are not just pointers. For the
technically minded, they are not separate inodes, they are additional
directory references to the same inode.  When you perform a copy
operation on multiple files, cfengine attempts to preserve hard links
but this is a difficult task. 

Because a hard link just looks like an ordinary file (it cannot be
distingiushed from the original, the way a symbolic link can)
there is a danger that any copy operation will copy two hard links to
the same file as two separate copies of the same file. The difference
is that changes a hard-linked file propagate to the links, whereas
two copies of a file are completely independent thereafter.
In order to faithfully reproduce all hardlinks to all files, cfengine
needs to examine every file on the same filesystem and check whether
they have the same inode-number. This would be an enourmous overhead, so it
is not done. Instead what happens is that cfengine keeps track of only
the files which it is asked to examine, for each atomic copy-command,
and makes a note of any repeated inodes within this restricted set.
It does not try to go off, wandering around file systems looking to
other files which might be hardlinks.

To summarize, cfengine preserves hardlinks during copying, only
within the scope of the present search. No backups are made of
hard links, only of the first link or name of the file is backed
up. This is a necessary precaution to avoid dangling references
in the inode table. As a general rule, hard links are to be avoided
because they are difficult to keep track of.

@node Too many open files,  , hard links in copy, copy
@subsection Too many open files

@cindex Too many open files error
@mbindex Too many open files error
In long recursive copies, where you descend into many levels of diretories,
you can quickly run out of file descriptors. The number of file descriptors
is a resource which you can often set in the shell. It is a good idea
to set this limit to a large number on a host which will be copying
a lot of files. For instance, in the C shell you would write,

@smallexample

limit descriptors 1024

@end smallexample

@noindent Most systems should have adequate defaults for this parameter, but
on some systems it appears to be set to a low value such as 64, which is
not sufficient for large recursive tree searches.

@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node defaultroute, disks, copy, Command reference
@section defaultroute

Dynamical routing is not configurable in cfengine, but for machines with
static routing tables it is useful to check that a default route is
configured to point to the nearest gateway or router.  The syntax for
this statement is simply:

@smallexample

defaultroute:

   @var{class}::

      my_gateway

@end smallexample 

@noindent
For example:

@smallexample

defaultroute:

  most::

     129.240.22.1


  rest::
 
     small_gw

@end smallexample 

@noindent
Gateways and routers usually have internet address @code{aaa.bbb.ccc.1}
--- i.e.  the first address on the subnet.  You may use the numerical
form or a hostname for the gateway.


@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node disks, directories, defaultroute, Command reference
@section disks

This is a synonyn for @code{required}, @xref{required}.
@cindex disks actions
This action tests for the existence of a file or filesystem.  It should
be called after all NFS filesystems have been mounted.  You may use the
special variable @code{$(binserver)} here.

@cartouche
@smallexample

  disks:

    /@var{filesystem} freespace=@var{size-limit} define=@var{class-list(,:.)} 

@end smallexample
@end cartouche

Files or filesystems which you consider to be essential to the operation
of the system can be declared as `required'.  Cfengine will warn
if such files are not found, or if they look funny.

Suppose you mount your filesystem @code{/usr/local} via NFS from some
binary server.  You might want to check that this filesystem is not
empty! This might occur if the filesystem was actually @emph{not}
mounted as expected, but failed for some reason.  It is therefore not
enough to check whether the directory @code{/usr/local} exists, one must
also check whether it contains anything sensible.

Cfengine uses two variables: @code{sensiblesize} and
@code{sensiblecount} to figure out whether a file or filesystem is
sensible or not.  You can change the default values of these variables
(which are 1000 and 2 respectively) in the @code{control} section.
@xref{control}.

If a file is smaller than @code{sensiblesize} or does not exist, it
fails the `required' test.  If a directory does not exist, or contains
fewer than @code{sensiblecount} files, then it also fails the test and a
warning is issued.

@smallexample

disks:

   any::
      
      /$(site)/$(binserver)/local

@end smallexample

If you set the @code{freespace} variable to a value (the default units are kilobytes,
but you may specify bytes or megabytes), e.g.
@vindex freespace=
@cindex freespace=
@cindex Warning about full disks
@cindex Full disk warnings


@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node directories, disable, disks, Command reference
@section directories

@cindex Directories, making
@cindex Paths, making
@cindex Making directories
@cindex Making paths

Directories declarations consist of a number of directories to be
created.  Directories and files may also be checked and created using
the @code{touch} option in the @code{files} actions.  @xref{files}.

The form of a declaration is:

@cartouche
@smallexample

  directories:

     @var{classes}::

         /@var{directory} 
                         mode=@var{mode} 
                         owner=@var{uid}
                         group=@var{gid}
                         define=@var{classlist}
@end smallexample
@end cartouche

@noindent
For example

@smallexample

directories:

  @var{class}::

     /usr/local/bin  mode=755 owner=root group=wheel

@end smallexample 

@noindent
The form of the command is similar to that of @code{files} but this
command is only used to create new directories.  Valid options are
@code{mode}, @code{owner}, @code{group} and are described under
@code{files} @xref{files}. This interface is only for convenience.
It is strictly a part of the `files' functionality and is performed
together with other `files' actions at run time.

The creation of a path will fail if one of the links in the path is a
plain file or device node.  A list of classes may optionally be defined
here if a directory is created.

@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node disable, editfiles, directories, Command reference
@section disable
@cindex Disabling files
@cindex Renaming files
@vindex disable

Disabling a file means renaming it so that it becomes harmless.  This
feature is useful if you want to prevent certain dangerous files from
being around, but you don't want to delete them--- a deleted file cannot
be examined later.  The syntax is

@cartouche
@smallexample

 disable:

   @var{class}::

      /@var{filename}
                      type=@var{plain/file/link/links}
                      rotate=@var{empty/truncate/numerical-value}
                      size=@var{numerical-value}
                      define=@var{classlist}

@end smallexample
@end cartouche

@noindent
Cfengine renames a given file by appending the name of the file with the
suffix @file{.cfdisabled}.  A typical example of a file you would
probably want to disable would be the @code{/etc/hosts.equiv} file which
is often found with the @samp{+} symbol written in it, opening the
system concerned to the entire NIS universe without password protection!
@cindex @file{/etc/hosts.equiv}
@cindex @code{.cfdisabled}
Here is an example:

@smallexample

disable:

      /etc/hosts.equiv
      /etc/nologin
      /usr/lib/sendmail.fc

   sun4::

      /var/spool/cron/at.allow

@end smallexample 

@noindent
Hint: The last example disables a file which restricts access to the
@code{at} utility.  Such a command could be followed by a file action:

@smallexample
files:

   some::

      /var/spool/cron/at.allow =0644 N [root] [wheel] touch

@end smallexample 

@noindent
@xref{files} which would create an empty security file @file{at.allow}.
See also your system manual pages for the @code{at} command if you don't
understand why this could be useful.

Disabling a link deletes the link. If you wish you may use the
optional syntax

@smallexample

disable:

    /directory/name type=file

@end smallexample

@noindent
to specify that a file object should only be disabled if it is a plain
file. The optional element @code{type=} can take the values
@code{plain}, @code{file}, @code{link} or @code{links}. If one of
these is specified, cfengine checks the type and only disables
the object if there is a match. This allows you to disable a file
and replace it by a link to another file for instance.
@cindex Replacing file by link
@vindex type=
@cindex Disabling file types

NOTE that if you regularly disable a file which then gets recreated by
some process, the disabled file @file{@var{filename}.cfdisabled} will
be overwritten each time cfengine disables the file and therefore the
contents of the original are lost each time. The @code{rotate} facility
was created for just this contingency.
@cindex Truncating log files
@cindex Controlling the size of log files
@cindex Log files, controlling the size of
@cindex Rotating log files

The disable feature can be used to control the size of system log files,
such as @file{/var/adm/messages} using a further option @code{rotate}.
@vindex rotate=
@vindex empty
@vindex truncate
If the value rotate is set to 4, say, 

@smallexample

 disable:

    @var{filename}  rotate=4

@end smallexample

@noindent
then cfengine renames
the file concerned by appending `.1' to it and a new, empty file is
created in its place with the same owner and permissions. The next time
disable is executed `.1' is renamed to `.2' and the file
is renamed `.1' and a new empty file is created with the same
permissions. Cfengine continues to rotate the files like this
keeping a maximum of four files. This is similar to the behaviour
of syslog.

If you simply want to empty the contents of a log file, without
retaining a copy then you can use @code{rotate=empty} or
@code{rotate=truncate}. For instance,
to keep control of your World Wide Web server logs:

@smallexample
disable:

   Sunday|Wednesday::

       /usr/local/httpd/logs/access_log  rotate=empty
@end smallexample

@noindent
This keeps a running log which is emptied each Sunday and Wednesday.
@cindex WWW server logs

The @code{size=} option in disable allows you to carry out a disable
operation only if the size of the file is less than, equal to or greater
than some specified size. Sizes are in bytes by default, but
may also be quoted in kilobytes or megabytes using the notation:
@smallexample

@var{number}bytes
@var{number}kbytes
@var{number}mbytes

@end smallexample
@noindent
Only the first characters of these strings are significant, so they may
be written however is convenient: e.g. @kbd{14kB}, @kbd{14k},
@kbd{14kilobytes} etc.
 Examples are:

@smallexample

   size=<400  # disable if file size is < 400 bytes
   size=400   # disable if file size is equal to 400 bytes
   size=>400  # disable if file size > 400 bytes

@end smallexample
@noindent
This options works with @code{rotate} or normal disabling; it is just
an extra condition which must be satisfied.
@cindex size field in disable

If a disable command results in action being taken by cfengine, an optional
list of classes becomes can be switched on with the aid of a statement
@code{define=@var{classlist}} in order to trigger knock-on actions.

@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node editfiles, files, disable, Command reference
@section editfiles

You can perform simple control or editing on textfiles using a number of
commands.  These are fairly limited but are sufficient for many
purposes and are definitely superior to using @code{awk} or @code{sed}
@footnote{If you are editing a file which has hard links to it, be aware that
editing the file will destroy the hard link references. This is also the
case with shell commands. You should avoid hard links whenever possible.}.
@cindex awk, editing
@cindex sed, editing
The form of an editing command is

@cartouche
@smallexample

editfiles:

   @var{class}::

      @{ @var{file-to-be-edited}

      @var{action} "@var{quoted-string...}"
      @}

@end smallexample 
@end cartouche

@noindent
Here are some examples:

@smallexample
editfiles:

   sun4::

      @{ /etc/netmasks

      DeleteLinesContaining "255.255.254.0"
      AppendIfNoSuchLine "128.39  255.255.255.0"
      @}

   PrintServers::
      @{ /etc/hosts.lpd

      AppendIfNoSuchLine "tor"
      AppendIfNoSuchLine "odin"
      AppendIfNoSuchLine "borg"
      @}

@end smallexample 

@noindent
The first of these affects the file @file{/etc/netmasks} on all SunOS 4
systems, deleting any lines containing the string ``255.255.254.0'' and
Appending a single line to the file containing ``128.39 255.255.255.0''
if none exists already.  The second affects only hosts in the class
`PrintServers' and adds the names of three hosts: tor, odin and borg to
the file @file{/etc/hosts.lpd} which specifies that they are allowed to
connect to the printer services on any host in the class `PrintServers'.

@cindex Quoted strings
@cindex Single quotes
@cindex Double quotes
@noindent
Note that single or double quotes may be used to enclose strings
in cfengine. If you use single quotes, your strings may contain
double quotes and vice-versa. Otherwise a double quoted string
may not currently contain double quotes and likewise for
single quoted strings.


As of version 1.3.0, you can use the @samp{home} directive in
edit filenames, enabling you to edit files for every user
on the system, provided they exist. For example, to edit
every user's login files, you would write

@smallexample

  @{ home/.cshrc

   AppendIfNoSuchLine "setenv PRINTER default-printer"
   AppendIfNoSuchLine "set path = ( $path /new/directory )"
  @}

@end smallexample

@noindent
If a user does not possess the named file, cfengine just skips
that user. A new file is not created.

@noindent
The meanings of the file-editing actions should be self-explanatory.
Commands containing the word 'comment' are used to `comment out' certain
lines in a file rather than deleting them.  @code{Hash} implies a shell
comment of the type

@smallexample
# comment
@end smallexample 

@noindent
@code{Slash} implies a comment of the C++ type:

@smallexample
// comment
@end smallexample 

@noindent
@code{Percent} implies a comment of the type:

@smallexample
% comment
@end smallexample

More general comment types may be defined using the
@code{SetCommentStart}, @code{SetCommentEnd} and
@code{CommentLinesMatching}, @code{CommentLinesStarting}
functions.

A special group of editing commands is based on the GNU Regular
Expression package. These use GNU regular expressions to search line by
line through text and perform various editing functions.  Some of these
commands are based on the concept of a file pointer. The pointer starts
at line one of the file and can be reset by 'locating' a certain line,
or by using the reset-pointer commands. The current position of the
pointer is used by commands such as @code{InsertLine} to allow a
flexible way of editing the middle of files.

A simple decision mechanism is incorporated to allow certain editing
actions to be excluded. For instance, to insert a number of lines
in a file once only, you could write:

@smallexample

   @{ @var{file}

    LocateLineMatching "@var{insert point...}"
    IncrementPointer   "1"

    BeginGroupIfNoMatch "# cfengine - 2/Jan/95"

      InsertLine "# cfengine - 2/Jan/95"
      InsertLine "/local/bin/start-xdm"

    EndGroup
   @}

@end smallexample

@noindent
Since the first inserted line matches the predicate on subsequent calls,
the grouped lines will only be carried out once.  


The full list of editing actions is given below in alphabetical order.
Note that some commands refer to regular expressions and some refer to
'literal strings' (i.e. any string which is not a regular
expression). Variable substitution is performed on all strings.  Be
aware that symbols such as @samp{.}, @samp{*} and so on are
meta-characters in regular expressions and a backslash must be used to
make them literal.  The regular expression matching functions are the
GNU regular expressions, as defined by the @code{regex-0.12}
package @xref{Regular expressions}. Readers are referred to the manual for this package for details
of the extended special features of GNU regular expressions. If you are
not familiar with regular expressions, then be aware that you may always
supply an exact string to be matched (this is the simplest regular
expression), but be careful about backslashing meta-characters!

@table @code

@item AbortAtLineMatching @var{quoted-regex}
This command sets the value of a regular expression. In all editing
operations (except @code{FixEndOfLine} and @code{GotoLastLine}) which involve multiple
replacements and searches, this expression marks a boundary
beyond which cfengine will cease to look any further. In other
words, if cfengine encounters a line matching this regular
expression, it aborts the current action. BE CAREFUL with this
feature: once set, the string remains set for the remainder of
the current file. It might therefore interact in unsuspected ways
with other search parameters. Editing actions are always aborted
as soon as the abort expression is matched.
Use @code{UnsetAbort} to unset the feature.

@item Append @var{quoted-string}
Add a line containing the quoted string to the end of the file.
This should be used in conjunction with the
decision structures @code{BeginGroupIfNoLineMatching} and
@code{BreakIfLineMatches}.

@item   AppendIfNoSuchLine @var{quoted-string}
Add a line containing the quoted string to the end of the file
if the file doesn't contain the exact line already.

@item AppendIfNoLineMatching  @var{quoted-regex}
A new version of the older @code{AppendIfNoSuchLine}
which uses a regular expression instead of a literal
string. The line which gets appended must be set
previously using @code{SetLine}.

@item AppendToLineIfNotContains @var{quoted-string}
This commands looks for an exact match of the quoted string
in the current line. If the quoted string is not contained
in the line, it is appended. This may be used for adding
entries to a list, @xref{FAQS and Tips}.

@item AutoCreate
If this command is listed anywhere in the file action list, cfengine
will create the named file if it doesn't exist. Normally cfengine
issues an error if the named file does not exist. New files are
created with mode 644, read access for everyone and write access
for the cfengine user (normally root). Note that if you set this,
BeginGroupIfFileIsNewer will always be true.
@cindex @code{AutoCreate}
@mbindex How to create files while editing

@item AutomountDirectResources @var{quoted-string}
This command is designed to assist with automounter configuration for
users wishing to use the automounter for NFS filesystems, but still use
the cfengine mount model.
@cindex NFS mount model and automounter
@cindex automounter
Applied to the current file, it is equivalent to saying: for each of the
mountable resources in the list @xref{mountables}, append if not found a
line for a direct automount map command, to the current file.  The
string which follows can be used to specify any special mount options
e.g. @code{"-nosuid"} for non setuid mounting (of all the
mountables). Note that this is added to the current file and not to a
file named @file{/etc/auto_direct}.

@item BeginGroupIfFileExists @var{quoted-string}
The lines following, up to the first @code{EndGroup}
are executed if the quoted filename exists (can be statted).
Files which are not readable by the running process are
for all intents and purposes non-existent.
@cindex @code{BeginGroupIfFileExists}

@item BeginGroupIfFileIsNewer @var{quoted-string}
The lines following, up to the first @code{EndGroup}
are executed if the quoted filename is newer than the file being
edited.
@cindex @code{BeginGroupIfFileIsNewer}

@item BeginGroupIfNoLineContaining @var{quoted-string}
The lines following, up to the first @code{EndGroup}
are executed if the quoted string does not appear in
any line in the file.

@item BeginGroupIfNoLineMatching @var{quoted-regex}
The lines following, up to the first @code{EndGroup}
are executed if the quoted regular expression
does not match any line in the file.

@item BeginGroupIfNoMatch @var{quoted-regex}
The lines following, up to the first @code{EndGroup}
are executed if the quoted regular expression does
not match the current line.

@item BeginGroupIfNoSuchLine @var{quoted-string}
The lines following, up to the first @code{EndGroup}
are executed if the quoted literal string
does not match any line in the file.

@item BreakIfLineMatches  @var{quoted-regex}
Terminates further editing of the current
file if the current line matches the quoted
regular expression.

@item CommentLinesMatching  @var{quoted-regex}
Use the current value of the comment delimiters
set using @code{SetCommentStart} and @code{SetCommentEnd} to comment
out lines matching the given regular expression in quotes.

@item CommentLinesStarting  @var{quoted-string} 
Use the current value of the comment delimiters
set using @code{SetCommentStart} and @code{SetCommentEnd} to comment
out lines starting with the quoted literal string.

@item CommentNLines @var{quoted-string}
Comments up to @math{N} lines from the current file, starting from the
location of the current line pointer. If the end of the file is reached
and less than @math{N} lines are deleted, a warning is issued, but
editing continues. The current value of the comment delimiters is
used to determine the method of commenting, (see @code{SetCommentStart}).
After the operation the pointer points to the line after the
commented lines.

@item CommentToLineMatching  @var{quoted-regex}
Use the current value of the comment delimiters set using
@code{SetCommentStart} and @code{SetCommentEnd} to comment out lines
from the current position in a file to a line matching the given regular
expression in quotes.

@item DefineClasses "@var{class1}:@var{class2}:..."
Activate the following colon, comma or dot-separated list of classes if
and only if the file is edited.

@item DeleteLinesAfterThisMatching @var{quoted-regex}

@item   DeleteLinesContaining @var{quoted-string}
Delete all lines containing the exact string quoted.

@item   DeleteLinesMatching @var{quoted-regex}
Delete all lines matching the quoted regular expression.

@item   DeleteLinesStarting @var{quoted-string}
Delete all lines beginning with the exact string quoted.

@item DeleteNLines @var{quoted-string}
Deletes up to @math{N} lines from the current file, starting from the
location of the current line pointer. If the end of the file is reached
and less than @math{N} lines are deleted, a warning is issued, but
editing continues.

@item DeleteToLineMatching @var{quoted-regex}
Delete lines from the current position, up to
but not including a line matching the regular expression
in the quoted string. If no line matches the
given expression, a warning is only printed in
verbose mode, but all edits are immediately
abandoned.

@item EmptyEntireFilePlease
Deletes all lines from the current file.

@item EndGroup
Terminates a begin-end conditional structure.

@item EndLoop
Terminates a loop. See @code{ForEachLineIn}

@item FixEndOfLine
The quoted string which follows may be either @samp{dos}
or @samp{unix} to fix the end of line character conventions
to match these systems. This command should be executed
last of all, since cfengine appends new lines with the conventions
of the system on which is was complied during edit operations.

@item ForEachLineIn @var{quoted-filename}
This marks the beginning of a for-loop which reads successive
lines from a named file. The result is like using @code{SetLine}
for each line in the file. Nested loops are not permitted.

@item GotoLastLine
Moves the file pointer to the last line in
the current file.

@item   HashCommentLinesContaining @var{quoted-string}
Add a @samp{#} to the start of any line containing the quoted string.

@item   HashCommentLinesMatching @var{quoted-regex}
Add a @samp{#} to the start of any line exactly matching the quoted regular expression.

@item   HashCommentLinesStarting @var{quoted-string}
Add a @samp{#} to the start of any line starting with the quoted string.

@item IncrementPointer @var{quoted-number}
Increments the value (in lines) of the file pointer
by the number of lines specified in the quoted
string (as a denary number). e.g. @samp{"4"}.
Negative values are equivalent to decrementing the
pointer. If a request is made to increment/decrement
outside of the file boundaries the pointer `bumps'
into the boundary and remains there, i.e. either at
start of file or end of file.
@cindex Incrementing line pointer in editfiles
@cindex Decrementing line pointer in editfiles

@item InsertFile @var{quoted-string}
Inserts the named file after the current line position
in the file. This should be used in conjunction
with a begin-end construction in order to avoid
including the file every time cfengine is run.
If the file does not exist, or cannot be opened,
there is only a warning issued in verbose mode.
Note if the file is empty, or if the current line
pointer is not set, the file is inserted at the start
of the file.

@item InsertLine @var{quoted-string}
Inserts the quoted string as a line at the current
position in the file. After the insert, the file
pointer is incremented by one so that subsequent
inserted lines are placed after the first.
This should probably be used in conjunction with the
conditional begin-end tests to avoid lines being
inserted on every run.


@item LocateLineMatching @var{quoted-string}
Moves the current-position pointer to the start
of the line matching the quoted regular expression.
If there is no match, a warning is only issued in
verbose mode, but all editing is immediately
aborted. See also @code{WarnIfNoLineMatching}
so that you can get an explicit warning, even
out of verbose mode.

@item   PercentCommentLinesContaining @var{quoted-string}
Add a @samp{%} to the start of any line containing the quoted string.

@item   PercentCommentLinesMatching @var{quoted-regex}
Add a @samp{%} to the start of any line exactly matching the quoted regular.

@item   PercentCommentLinesStarting @var{quoted-string}
Add a @samp{%} to the start of any line starting with the quoted string.


@item Prepend @var{quoted-string}
Add a line containing the quoted string to the start of the file.
This should be used in conjunction with the
decision structures @code{BeginGroupIfNoLineMatching} and
@code{BreakIfLineMatches}.

@item PrependIfNoLineMatching @var{quoted-regex}
A new version of the older @code{PrependIfNoSuchLine}
with uses a regular expression instead of a literal string.
The string prepended is the one set using @code{SetLine}.

@item   PrependIfNoSuchLine @var{quoted-string}
Add a line containing the quoted string to the start of the file
if the file doesn't contain the exact line already.

@item ReplaceLineWith @var{quoted-string}
Replace the line at the current position with the
text in the quoted string. The file pointer remains
pointing to this line after the change.

@item ReplaceAll @var{quoted-regex} With @var{quoted-string}
Replace all instances of strings matching the regular expression in the
first quotes with the exact string in the second set of quotes,
throughout the current file. Note that cfengine matches on a left to
right basis, with the first match taking precedence, so if your regular
expression matches text ambiguously it is the first occurrence which is
replaced. For example, if you replace @samp{cf.*} with @samp{CFENGINE}
and cfengine encounters a line @samp{hello cfengine cfengine}, then this
will be replaced with @samp{hello CFENGINE} even though two possible
strings match the regular expression. On the other hand if the
expression is not ambiguous, say replacing @samp{cfengine} with
@samp{CFENGINE}, then the result would be @samp{hello CFENGINE CFENGINE}.

@item ReplaceLinesMatchingField @var{quoted-number}
This command replaces any lines in the current file with the current line
set by @code{SetLine} or @code{ForEachLineIn}, if the lines
are split into fields (e.g. the password file) separated by the
@code{SplitOn} character (':' by default), and the corresponding
fields match.

The idea behind this command was to be able to override global
passwords (from a file which gets distributed) by new passwords 
in a local file. Rather than maintaining the files separately,
this simply overrides the entries with the new ones @xref{FAQS and Tips}.

@item ResetSearch @var{quoted-string}
Sets the current-position pointer to the line number
in the quoted string. @samp{EOF} indicates the end of
the file.


@item RunScript @var{quoted-string}
Executes the named script command. Before executing the script any edits
are saved to disk. After the script has executed,
cfengine reloads the file for any further editing
operations. The script (which may be any executable
program) is appended with two arguments: the name of the
file which is being edited and the system hard class
(e.g. sun4, ultrix etc.) of the system executing
the script.

CAUTION: cfengine knows nothing about
the success or failure of anything that is done during the
execution of user scripts. This feature is to be
used at the users own peril!

@item RunScriptIfLineMatching @var{quoted-string}
Executes the script named with the @code{SetScript}
command only if the current file contains a line matching
the quoted regular expression.

CAUTION: cfengine knows nothing about
the success or failure of anything that is done during the
execution of user scripts. This feature is to be
used at the users own peril!

@item RunScriptIfNoLineMatching @var{quoted-regex}
Executes the script named with the @code{SetScript}
command if the current file contains no line matching
the quoted regular expression.

CAUTION: cfengine knows nothing about
the success or failure of anything that is done during the
execution of user scripts. This feature is to be
used at the users own peril!

@item SetCommentStart @var{quoted-string}
Specify which string should be used for starting
a comment using the commands @code{CommentLineMatching}
and @code{CommentLineStarting}. The default is the hash
symbol @samp{#} followed by a single space.

@item SetCommentEnd  @var{quoted-string}
Specify which string should be used for ending
a comment using the commands @code{CommentLineMatching}
and @code{CommentLineStarting}. The default is the empty
string. For example, you could make C style comments
by setting CommentStart to @samp{/*} and comment
end to @samp{*/}.

@item SetLine @var{quoted-string}

Sets a current line value which can be appended using
@code{AppendIfNoLineMatching} using a regular expression.

@item SetScript @var{quoted-string}
Sets the name of a user-supplied script
for editing the current file.

@item   SlashCommentLinesContaining @var{quoted-string}
Add a @samp{//} to the start of any line containing the quoted string.

@item   SlashCommentLinesMatching @var{quoted-regex}
Add a @samp{//} to the start of any line exactly matching the quoted regular expression.

@item   SlashCommentLinesStarting @var{quoted-string}
Add a @samp{//} to the start of any line starting with the quoted string.

@item SplitOn @var{quoted-string}
This defines a single character which is to be interpreted as a
field separator for editing files with columns. The default value
for this is @samp{:}, as is used in the password and group files.
It is used in conjunction with @code{ReplaceLinesMatchingField}.
@cindex SplitOn
@cindex Password file, editing
@cindex Group field, editing
@cindex Field separator in editfiles

@item UnCommentLinesContaining  @var{quoted-string}
Uncomment all lines in file containing the quoted string as a
substring. The comment delimiters are assumed to be those
set using SetCommentStart and SetCommentEnd.

@item UnCommentLinesMatching  @var{quoted-regex}
Uncomment all lines in file matching the quoted regular expression.  The
comment delimiters are assumed to be those set using SetCommentStart and
SetCommentEnd.


@item UnCommentNLines @var{quoted-string}
Uncomments N lines starting from the current position, using
the currently defined method for commenting. Note that the
comment start and end symbols are removed independently, i.e.
they are not matched, so that a comment may be spread over
several lines. e.g. If using C style @samp{/*} and @samp{*/}
comments, the command @code{UnCommentNLines "3"} would
uncomment
@smallexample
 /* 1 */
 /* 2 */
 /* 3 */
@end smallexample
@noindent
and also
@smallexample
 /* 1 
    2
    3 */
@end smallexample

@item UnsetAbort  @var{quoted-string}
Switches off the feature @code{AbortAtLineMatching}.

@item   WarnIfLineContaining @var{quoted-string}
Issue a warning if the quoted string is found as a
substring of one or more lines in the file.

@item   WarnIfLineMatching @var{quoted-regex}
Issue a warning if the quoted regular expression
matches one or more lines in the file.


@item   WarnIfLineStarting @var{quoted-string}
Issue a warning if the quoted string matches the start
of one or more lines in the file.


@item   WarnIfNoLineContaining @var{quoted-string}
Issue a warning if the quoted string is not contained
in one or more lines in the file.


@item   WarnIfNoLineStarting @var{quoted-string}
Issue a warning if the quoted string is not found
at the start of one or more lines in the file.

@item   WarnIfNoSuchLine @var{quoted-string}
Issue a warning if the quoted regular expression does not
match one or more lines in the file.


@end table




@noindent
It is suggested that you use these editing functions with
caution. Although all possible safeguards have been incorporated into
them, it is still possible through carelessness to do damage to
important files on your system. Always test editing programs carefully
before committing them to your global site configuration.


@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node files, groups, editfiles, Command reference
@section files
@cindex File management
@cindex Files, checking permissions
@cindex Files, setting owner
@vindex files

The @code{files} facility allows you to touch (create), check for the
existence, owner and permissions of files, change the permissions and
test for setuid root programs.

@menu
* Syntax::                      summary
* Recursion::                   searching subdirectories
* Directory permissions::       file mode and ownership
* home directive::              a wildcard for user files
* Owner and group wildcards::   ignoring ownership
* Files linkchildren::          an `intelligent' feature
* touch::                       
* create::                      
@end menu

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Syntax, Recursion, files, files
@subsection Syntax
@cindex Files, syntax

A files-statement can have several options.  We can begin by examining
the form of the statement in pseudo-code:

@cartouche
@smallexample
  files:

     @var{classes}::

        /@var{file-object}
                          mode=@var{mode}
                          owner=@var{uid-list}
                          group=@var{gid-list}
                          action=@var{fixall/other-options}/@b{warnall} 
                          links=@b{false/stop}@var{/traverse/follow/tidy}
                          include=@var{pattern}
                          exclude=@var{pattern}
                          define=@var{classlist}

@end smallexample 
@end cartouche

@noindent
An example would be the following:

@smallexample
   any::

      /var/spool/printQ  mode=0775  r=0 o=daemon g=daemon  act=fixdirs

@end smallexample

@noindent
The meaning of these item is sketched out below and becomes clearer on
looking at a number of examples.  Note that, each of the options below
can be written in either upper or lower case and abbreviated by any
unique abbreviation.
@vindex m=
@vindex mode
@vindex l=
@vindex link
@vindex recurse
@vindex r=
@vindex a=
@vindex action
@vindex o=
@vindex owner
@vindex g=
@vindex group


@table @code

@item @var{/directory}
This is the only obligatory part of a file action.  This is a directory
at which a file search should begin.  This may be a single file or a
directory.  The recursion specifier may be used to force cfengine to
descend into subdirectories in a controlled fashion, starting from this
point, checking files there also.  The wildcard @code{home} may also be
used.  @xref{home directive}.
@cindex home wildcard
@cindex Wildcard home
@vindex home

@item mode=@var{modestring}
Specifies what the allowed permissions for files are.  If cfengine finds
that a file's mode is incorrect, the value of the @code{action}
option determines what will be done about it.  The modestring should
consist of either a three digit octal numbers with @samp{+}, @samp{-} or
@samp{=} symbols, or a text string like that used by the command
@code{chmod}.  For instance: @code{mode=u=rwx,og+rx} would mean set the
read/write and execute flags for the user (file owner) and add the
read/execute flags for others and group bits.  An example of the
numerical form might be @code{-002} which would mean that the
read-for-others flag should either not be set or should be unset,
depending on the action you choose.  @code{+2000} would mean that the
setuid flag should be present or set, depending on the action.
@code{+2000,-002} would be a combination of these.  The @samp{=} sign
sets to an absolute value, so @code{=755} would set the file mode to
mode 755.

@item recurse=@var{number/inf}
This specifier tells cfengine whether or not to recurse into
subdirectories.  If the value is zero, only the named file or directory
is affected.  If the value is 1, it will open at most one level of
subdirectory and affect the files within this scope.  If the value is
@code{inf} then cfengine opens all subdirectories and files beginning
from the specified filename.@xref{Recursion}.

@item owner=@var{owner list}
This is a list of allowed owners, or uids by number, separated by
commas.  For example @code{root,2,3,sysadm}.  In cases where you ask
cfengine to fix the ownership automatically, the owner will be set to
the first owner in the list if and only if it is not one of the named
uids in the list.

@item group=@var{group list}
This is a list of allowed groups, or gids by number, separated by
commas.  For example @code{wheel,2,3,sysadm}.  In cases where you ask
cfengine to fix the ownership automatically, the group will be set to
the first group in the list if and only if it is not one of the named
gids in the list.

@item action=@var{action}
The action is one of the following keywords.
@smallexample
warnall warndirs warnplain
 fixall fixdirs fixplain
touch linkchildren create
@end smallexample 

@noindent
The upper line results only in warnings being issued.  The actions
beginning `fix' prompt cfengine to fix encountered problems without
bothering the user.  No message is issued unless in verbose mode.  The
special features on the third line will be explained separately.

@item include=@var{wildcard/pattern}
You can include this option several times to specify specific patterns
which are to be included in the search. Once you specify one
pattern you exclude all files not matching at least one of the
patterns. The case be useful for restricting a search, or for
modifying the permissions of only certain files.
@cindex Search patterns in @code{files}
@vindex include=
@cindex Pattern matching in file sweeps

@item exclude=@var{wildcard/pattern}
You can include this option several times to specify specific patterns
which are to be excluded from the search. This overrides any patterns
given in the @code{include=} list.
@vindex exclude=
@cindex Excluding files from a file sweep

@item links=@var{stop/traverse/tidy}
Normally cfengine does not descend into subdirectories which are pointed
to by symbolic links.  If you wish to force it to do so (without using
the @code{-l} command line option) you may give this option the value
@code{true}, or @code{traverse}, or @code{follow}.  To specify no
recursion you set the value @code{false} or @code{stop}.
@cindex Links, traversing in searches
@vindex -l
@cindex -l option
Note that the value set here in the cfengine program @emph{always
overrides} the value set by the @code{-l} command line option, so you
can protect certain actions from this command line option by specifying
a negative value here.  If you specify no value here, the behaviour is
determined by what you specify on the command line.

The value @code{links=tidy} has the same effect as the @samp{-L} command
line option except that here it may be specified per item rather than
globally.  Setting this value causes links which point to non-existent
files to be deleted.
@cindex Deleting stale links
@cindex Links, deleting stale

@noindent
If the warn directive is used (for directories, plain files or both)
then only a warning message is issued if the file being tested does not
match the specification given.  If the fix directives are used then
cfengine does not issue a warning, it simply fixes the value silently.
Non-existent files are created by the @code{touch} command.  A
directory may be touched (created) by writing the filename
@code{/a/b/c/.} with a dot as the last character.  (This may also be
achieved with the @code{directories} directive.  @xref{directories}).

@item define=@var{classlist}
If a file operation results in action being taken to fix a file,
the colon, comma or dot separated list of classes becomes defined.
Warnings do not activate the classes.

@end table

The default values are @code{mode=+000}, @code{recurse=0},
@code{action=warnall} and any owner or group is acceptable.  The default
for @code{links} is to not traverse links unless the @code{-l} option is
set on the command line.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Recursion, Directory permissions, Syntax, files
@subsection Recursion
@cindex Recursion in files
@cindex Files, recursion

The recursion specifier tells cfengine what to do, starting from
@code{/directory name}.  A value of @code{r=0} means `no recursion' and
any checking is limited only to the named file or directory.  A value of
@code{r=inf} implies unlimited recursion.  Cfengine then descends into
all subdirectories checking or setting the permissions of files until it
`bottoms out' at a plain file.  A value such as @code{R=4} means descend
recursively into subdirectories, but no more than four levels.  This is
a useful safety net in preventing unforeseen accidents.  A recursive
search also bottoms out on device boundaries and symbolic links
(provided the @kbd{-l} option is not used).
@cindex Device boundaries and files
@cindex xdev (File system boundaries)

@c .....................................................
@c SUBSECTION
@c .....................................................
@node Directory permissions, home directive, Recursion, files
@subsection Directory permissions
@cindex Directory permissions
@cindex Permissions, directories

When you specify the permissions for a whole file tree, using the
recursion specifier it is awkward to have to remember that directories
must be executable.  cfengine will do this for you automatically.  If
you specify that a file tree is to have a read flag set, cfengine will
ensure that the corresponding execute flag is also set for directories
which live in the tree.  So the command

@smallexample
files:

  myclass::

      /dir  mode=a+rw r=inf fixall

@end smallexample 

@noindent
would set all plain files to mode 644 and all directories to 755, that
is read/write for everyone on plain files and read/write/execute for
everyone on directories.

@c .....................................................
@c SUBSECTION
@c .....................................................
@node home directive, Owner and group wildcards, Directory permissions, files
@subsection @code{home} directive
@cindex home directive
@cindex Files, home wildcard

If you want to check the files of all the users who have their login
areas on the current host, you can use a wildcard directive @code{home}
instead of a directory name.  In this case the file action iterates over
all home directories physically on the current host.  The home
directories are, of course, located by searching for files which match

@smallexample
$(mountpattern)/$(homepattern)
@end smallexample 

@noindent
i.e.  the values which are specified in the @code{control} part of the
program.  For example the following line is a very useful service to
ignorant users.

@smallexample
files:

  any::
 
    home mode=o-w r=inf act=fixall

@end smallexample 

@noindent
It ensures automatically that no user has files which can be written to
by other arbitrary users.

As a corollary to this, you may write something like
@smallexample

  any::

     home/www mode=a+r fixall

@end smallexample

@noindent
to specify a special subdirectory of every users' home directory.  This
statement would check that all of the files in users' world wide web
directories were readable for everyone.

@c .....................................................
@c SUBSECTION
@c .....................................................
@node Owner and group wildcards, Files linkchildren, home directive, files
@subsection Owner and group wildcards
@cindex Ownership of files
@cindex Files, ownership

If you do not want to explicitly state the owner or group of a file you
may simply omit the group or owner options.

@smallexample

  /@var{file-object} m=0664 r=inf

@end smallexample 
This example generate a warning if any files under the named directory
do not have permission read/write for all users.

@c .....................................................
@c SUBSECTION
@c .....................................................
@node Files linkchildren, touch, Owner and group wildcards, files
@subsection Files linkchildren
@vindex linkchildren
@cindex Linkchildren

The @code{linkchildren} facility is almost identical to that already
described under @code{links}.  @xref{Link Children}.  The only
difference here is that the ownership and permissions on the links are
set all in one operation.  For example:

@smallexample
@var{myclass}::

   /local/lib/emacs m=0770 o=me g=mygroup act=linkchildren

@end smallexample 

@c .....................................................
@c SUBSECTION
@c .....................................................
@node touch, create, Files linkchildren, files
@subsection touch
@vindex touch
@cindex Touching files

The @code{touch} facility creates a new file with the
specified permissions and ownership, or corrects the
permissions and ownership of an existing file, in addition
to updating the time stamps.

@smallexample
@var{myclass}::

   /@var{newfile} mode=0644 action=touch

@end smallexample 

@c .....................................................
@c SUBSECTION
@c .....................................................
@node create,  , touch, files
@subsection create
@vindex create
@cindex Creating files

This is like @code{touch} except that an existing
file's time stamps, permissions and ownership will not be modified
if the file already exists. If the file does not exist, the
attributes are set to the values specified, or to the default
values of @code{0644}.

@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node groups, homeservers, files, Command reference
@section groups
@vindex groups
@cindex  Defining groups
@cindex Groups, defining

The @code{groups} action (equivalently referred to as @code{classes} as
of version 1.4.0) is used to define classes which stand for groups of
hosts.  If you use the NIS (network information service) facility for
defining @emph{netgroups} then this idea will already be familiar to you
and you can probably use your already-defined netgroups in cfengine.
@cindex @code{groups}
@cindex @code{classes}

To define a group, you simply make a list and assign it a name.  Here is
an example of the syntax:

@smallexample

groups:
 
   science = ( saga tor odin )

   packages = ( saga ) 

   AllHomeServers   = ( saga )
   AllBinaryServers = ( saga )

   OIH_servers = ( saga )
   OIH_clients = ( tor odin )

@end smallexample 

@noindent
To include a list of hosts from a NIS netgroup, you use the @samp{+} symbol, or
the @samp{+@@} construction.  For example:

@cindex Netgroups
@cindex NIS, netgroup support
@vindex +

@smallexample

groups:
 
   science = ( +science-allhosts )

   physics = ( +physics-allhosts )

   physics_theory = ( +@@physics-theory-sun4 dirac feynman schwinger )

@end smallexample 

@noindent
Using an enormous netgroup does not use up any space.  A group
declaration results in the storage of only the class name regardless of
how many hosts are in the list.  The rule is that the left hand side of
the assignment becomes defined (true) if the list on the right hand side
includes the host which is parsing the file --- i.e.  @code{$(host)}.

In some cases your netgroups will not correspond exactly to the list you
want, but it might be more convenient to use a netgroup @emph{except}
for certain hosts.  You can `undefine' or remove hosts from the netgroup
list by using the minus `-' symbol.  For example:

@cindex Removing entries from netgroups
@cindex Negating entries from netgroups
@cindex Netgroups, negating entries
@smallexample

group = ( +mynetgroup -specialhost -otherhost )

@end smallexample 

@noindent
which means, of course, all hosts in netgroup @code{mynetgroup} except
for @code{specialhost} and @code{otherhost}.  Finally, you may also
subtract two netgroups in the following manner.

@smallexample
group = ( +bignetgroup -smallnetgroup )
@end smallexample 

@noindent
The `minus' command effectively eliminates its members from
@code{bignetgroup} if they exist within that group.  If none of the
hosts in @code{smallnetgroup} exist in @code{bignetgroup} then the
command has no effect.

@cindex Group dependencies
@cindex Class dependencies
@cindex Dependencies
Groups may now contain previously defined cfengine groups too. This
allows one class to inherit the attributes of another class, for instance:

@smallexample

  AllSun4Hosts   = ( sonny sunny solar stella )
  AllUltrixHosts = ( ully olly wally golly )

  AllBSD = ( AllSun4Hosts AllUltrixHosts )

@end smallexample

@noindent
The classes on the right hand side are effectively ORed together into
the left hand side.  This enables complex classes to be constructed from
several other basic classes, e.g.

@smallexample

  SpecialTimes = ( Hr00 Monday Day1 )

@end smallexample

@noindent
which evaluates to true every day when it between 00:00 hours and 00:59,
all day Monday and all day on the first day of every month.

@cindex Shell command to decide class
@cindex Class decided by shell command
Finally, you can define groups (strictly classes) by the result of a shell
command. A shell command or program is deemed to be `true' if it
exits with a status of zero, i.e. it calls @code{exit(0)}. Any other
value is taken to be false. You can include shell commands as the members
of groups in order to define classes based on the outcomes of your
own scripts by enclosing the script in single or double quotes:

@smallexample

   have_cc = ( '/bin/test -f /usr/ucb/cc' )

@end smallexample

@noindent
The class @code{have_cc} will then be defined if the shell command returns
true. Of course, you can put any script or program in the single quotes as
long as they adhere to the convention that zero exit status means true.
If you have several members which are shell commands, then the effect is
to make the class the logical OR of the scripts' results.

As of version 1.4.0, you may use the synonym @code{classes} for @code{groups}.
@cindex @code{classes}


@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node homeservers, ignore, groups, Command reference
@section homeservers

@cindex Home servers, defining
@cindex Defining a home server
@vindex homeservers

The @code{homeservers} declaration need only be used if you are using
cfengine's model for mounting NFS filesystems.  This declaration informs
hosts of which other hosts on the network possess filesystems containing
home directories (login areas) which client hosts should mount.

A sample homeserver declaration looks like this:

@smallexample

homeservers:

   Physics::  einstein 
   Math::     riemann euler

@end smallexample 

@noindent
The meaning of this declaration is the following.  Any host which finds
itself to be a member of the classes on the left hand side of the
assignment need to mount all home directory resources from the hosts on
the right hand side of the assignment.  The pattern variable
@code{homepattern} is used to determine which resources are home
directories in the list of @code{mountables}.  @xref{mountables}.

Let us consider an example in which @code{homepattern} is set to the
wildcard value @samp{home?} and the mountables list is given by

@smallexample
mountables:
   
   einstein:/mysite/einstein/home1
   einstein:/mysite/einstein/home2
   riemann:/mysite/riemann/local
   euler:/mysite/euler/home1
  
@end smallexample 
@vindex mountables
@cindex Mountable resources, defining

Any host in the group @code{Physics} would now want to mount all home
directories from the host @code{einstein}.  There are two of these.
Both the filesystems listed for @code{einstein} match the
@code{homepattern} variable since they end in @samp{home?}.  cfengine
would therefore take this to mean that all hosts in @code{Physics}
should mount both of these filesystems.

Hosts in @code{Math}, on the other hand, should mount only
homedirectories from the hosts @code{riemann} and @code{euler}.  There
is only a single filesystem on @code{riemann} and it does not match
@code{homepattern}, so it is not mounted.  On @code{euler} there is a
match, so this filesystem will be added to the appropriate hosts.

@emph{Cfengine picks out home directory resources from the
@code{mountables} list by trying to match the @code{homepattern}
variable, starting from the end of the directory name.  You do not
therefore have to use the designation @code{/site/host/home?}  but this
is a simple choice and is highly recommended.}


@page


@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node ignore, import, homeservers, Command reference
@section ignore

When you specify a recursive search as part of a @code{files},
@code{tidy} or @code{copy} action, you would sometimes like to exclude
certain directories from the list of sub directories.  In most cases you
will want to do this on a per-command basis (see the pages for these
actions separately), but you can also make a global ignore list.  This
can be accomplished by adding the directory to the ignore-list.  The syntax
is

@cartouche
@smallexample

  ignore:

     @var{wildcards/directories/filenames}

@end smallexample
@end cartouche

For example:
@cindex ignore command

@smallexample

ignore:

   any::

      #
      # Prevent tidying .X11 directories in /tmp where
      # window managers write semaphores
      #

      .X11

      #
      # Don't tidy emacs locks
      #

      !*
      /local/lib/gnu/emacs/lock/
      /local/tmp
      /local/bin/top
      /local/lib/tex/fonts
      /local/etc
      /local/www
      /local/mutils/etc/finger.log


@end smallexample 

@noindent
None of the above directories will be checked or entered during
recursive descents unless a specific command is initiated to search
those directories with their names as the top of the search tree.
@cindex .X11 directory

A handy tip if you are tidying @file{/tmp} recursively is to include the
directory @file{.X11} here.  This directory is used by the X-windows
system and deleting it while a window manager has an open session can
cause the user some trouble.

Ignore refers to all recursive searches in tidy, files, copy and links.

@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node import, links, ignore, Command reference
@section import
@cindex Importing files
@cindex Several files
@cindex Files, importing
@cindex Files, breaking up into several
@vindex import

To break up a large configuration file into smaller files you can use
the include directive.  This conditionally reads in files if the class
on the left hand side of the assignment matches the host parsing the
file.  This enables also a variety of cfengine configuration scripts to
read in a standard set of default settings.  The syntax of the statement
is:

@smallexample

import:       

   any::
      
      cf.global_classes
 

   linux::
    
      cf.linux_classes
     

@end smallexample 

Note that, if you define variables in an imported file they will not be
defined for operations in their parent files. This because cfengine reads in all the
import files after the main file has been parsed---not at the place where you
call import in your script. This means that variables or macros defined in
imported files are only defined after the main program. Variables from earlier
files are inherited by later includes, but not @emph{vice-versa}.

@cindex Variables in import files
@cindex Import files, variables in


@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node links, mailserver, import, Command reference
@section links

@cindex Making links
@cindex Links, making
@vindex links

@menu
* Single links::                with the -> directive
* Multiple Links::              with the +> directive
* Link Children::               an `intelligent' feature
* Relative and absolute links::  
* Hard links::                  
@end menu

The symbolic links function is one of the greatest plusses in cfengine
as a system administration tool.  It allows you to do two things: check
single links for correctness and consistency (or make them if they do
not exist), and check or make links to every file in a designated
directory.  This latter feature is called multiple linking or linking
children.  The @code{linkchildren} feature is also available from the
@code{files} action  @xref{files}. The syntax of a link item is:

@cartouche
@smallexample

  @var{from-link} ->[!] @var{to-object} 
 @var{or}
  @var{from-link} +>[!] @var{to-object} 

            type=@b{symbolic/absolute/abs}/@var{hard/relative/rel}
            copy=@var{pattern}
            recurse=@var{number/inf/}@b{0} 
            copytype=@var{checksum/}@b{ctime}
            include=@var{pattern}
            exclude=@var{pattern}
            action=@var{silent}
            deadlinks=@b{kill}/@var{force}
            define=@var{classlist}

@end smallexample
@end cartouche

@noindent
@emph{The special variable @code{$(binserver)} can be used in @code{links}.}

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Single links, Multiple Links, links, links
@subsection Single links
@cindex Single links
@cindex Links, single

To define a single link, you create an entry of the following
form:

@smallexample

links:

  @var{class}::

     @var{linkname} -> @var{object_to_link_to}
     @var{linkname} -> ./@var{relative_link}
     @var{linkname} -> ../@var{relative_link}

@end smallexample 

@noindent
If links exists and point to their intended destinations then no
action is taken.  If a link exists but points incorrectly then a
warning is issued, unless the pling operator @samp{!} is given, in
which case the correct value is forced.  
If the link exists and points to a file which does
not exist a warning is issued unless the command line option @code{-L}
is used, in which case the link is deleted.  @xref{Runtime Options}.
@cindex @code{-L} option
@vindex -L

Here is an example of some valid link statements.

@smallexample

links:

  Physics.sun4::
 
   /usr/local       -> /$(site)/$(host)/local
   /home            -> /$(site)/$(host)/u1
   /etc/sendmail.cf -> /usr/local/mail/etc/global-sendmail.cf

   /usr/lib/sendmail ->! /local/lib/sendmail 

@end smallexample 

@noindent
cfengine makes any directories which are required leading up to the link
name on the left hand side of the arrow automatically. In the last
example the `pling' forces cfengine to make the link even if a file for
link exists previously. Plain files are saved by appending
@file{.cfsaved} to the filename, or by moving to a repository, whereas
old links are removed.  The same effect can be enforced globally using
the @code{-E} option, but only if the program is run interactively. (In
this case a prompt is issued to make sure that you wish to use such a
big hammer on your system!)

The link operation accepts a number of parameters

@table @code

@item type=@var{hard/relative/absolute}
If the link type is hard, a hard link is created @xref{Hard links}.
Symbolic links may specify two special types. If @code{relative}
is selected, and the `to' object is an absolute path name,
the link name will be rewritten as a pathname relative
to the source file, using @samp{.} and @samp{..} to move relative
to the current directory. For instance, a link from @file{/usr/local/file}
to @file{/usr/file} would be linked as @file{./../file}.
If the `to' object is already relative,
this has no effect. 

If @code{absolute} is specified, cfengine
will try to resolve the true path location of the `to' object,
expanding any symbolic links or dots in the path name, up to
a maximum of four levels of symbolic links. 

@cindex Relative links
@cindex Symbolic links, relative
@cindex Links, absolute
@cindex Absolute links
@cindex Symbolic links, absolute
@cindex Links, absolute

@item copy=@var{pattern}
This option can be repeated any number of times to build up a list of
filenames or wildcards which are to be copied rather than linked
symbolically. The copy is made on an age-comparison basis. A global
variable may also be set to invoke this feature @xref{copylinks}.
Directories cannot be copied in this way.

@item copytype=@var{checksum/ctime}
This specifies the basis for deciding whether to update a file
which is to be copied instead of linked @xref{copy}.

@item nofile=@b{kill}/@var{force}
This decides what happens to links which point to non-existent
files. The default action is to remove such links, or refuse to
create them. By setting the @var{force} option you can force
cfengine to make symbolic links to files which do not exist.
This is useful for setting up links to filesystems which
are not permanently mounted.
@cindex Links, removing dead
@cindex Links, forcing for non-existent files

@item exclude=@var{pattern}
This option can be repeated any number of times to build up a list of
filenames or wildcards which are to be excluded from the linking
process. A global variable may also be set to invoke this feature 
@xref{excludelinks}.

@item recurse=@var{number/}inf
This option can only be used with multiple link operations @xref{Multiple Links}.
If this option is specified, cfengine links only non-directory
objects. Directories are instead created and links within those
directories are also created. The value of this option specifies the
maximum number of levels to which cfengine should recursively descend a
link tree. @code{inf} means infinite recursion. Cfengine also ignores
files and directories in the ignore list @xref{ignore}.

@item define=@var{classlist}
If a link is created or replaced, the colon, comma or dot separated
list of classes becomes defined.

@end table

@cindex Binary servers and links
@cindex Links and binary servers
@vindex binserver
The final feature of the links facility is connected to the use of the
cfengine model for mounting NFS filesystems.  In particular it concerns
the variable @code{$(binserver)}.  The easiest way to understand this
feature is to illustrate a couple of examples.  Consider the following:

@smallexample
links:

   any::

      /local -> /$@{site@}/$@{binserver@}/local

@end smallexample 

@noindent
The result of this command is quite different depending on which host is
executing it.  The variable @code{$(site)} clearly has a fixed value,
but the variable @code{$(binserver)} might expand to any valid binary
server for the host executing the program.  @xref{binservers}.  The
procedure cfengine adopts is to go through its list of mountables,
keeping only those mountable resources which belong to defined binary
servers for the current host.  It then attempts to match a filesystem by
substituting @code{$(binserver)} with each of its valid binservers in
turn and it matches the first one binary server which yields an existing
file.

@cindex Binary servers, priority
Note that every host is a binary server for itself, so that the value of
@code{$(binserver)} which has absolute priority is alway the same as the
value of @code{$(host)}.  This ensures that the link will always be made
to a local filesystem if the rules of the model are upheld.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Multiple Links, Link Children, Single links, links
@subsection Multiple Links
@cindex Multiple links
@cindex Links, multiple

With the link symbol @code{+>}, you opt to link all of the files in a
directory to corresponding files in another directory.  This procedure is
sometimes useful for installing software.  In the example

@smallexample

links:

  myclass::

     /usr/local/bin +>  /usr/local/lib/perl/bin
     /opt           +>! /local

@end smallexample 

@noindent
every file in the directory @code{/usr/local/lib/perl/bin} is linked
symbolically to a corresponding file in @code{/usr/local/bin}. The
`pling' character forces cfengine to replace old links or plain files
already existing. Old links are removed, whereas old files are saved
by appending @file{.cfsaved} to the filename @xref{repository}.
@cindex @file{.cfsaved} files

Each time cfengine runs it goes through all of the files in the
directory concerned and checks the appropriate link accordingly.  If new
files appear, new links will be added.  If a file disappears but the
link to it remains, a warning will be issued, unless the @code{-L}
command line option is used, in which case the link is deleted.
@xref{Runtime Options}.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Link Children, Relative and absolute links, Multiple Links, links
@subsection Link Children
@cindex Linkchildren
@vindex linkchildren

The linkchildren directive is a closely related to the cfengine model
for NFS filesystems.  It is a way of making links which embodies a
rudimentary kind of `intelligence'.

@cindex Binary servers and links
@cindex Links and binary servers
@vindex binserver
Consider the following:

@smallexample
links:

   any::

      /usr/local/lib/emacs +> linkchildren

@end smallexample 

@noindent
The word @code{linkchildren} automatically tells cfengine that it should
look for an appropriate file to link to on a binary server for the
current host.  The exact meaning of the above statement is as follows.
cfengine begins searching though the list of mountable resources,
discarding any filesystems which do not belong to valid binary servers.
It looks for a filesystem ending in `emacs' (the last link of the left
hand side).  If all is well, these file systems are already mounted and
they can be searched.  If no resource is found ending in `emacs', we go
to the next link @code{lib} and look for a filesystem ending in `lib'.
If this is not found we go to @code{local} and so on.  When a match is
made, cfengine then tries to locate the file by checking whether it
exists relative to the matched filesystem.  For example, suppose `local'
matched with @code{host:/site/host/local}.  It would then try to locate
@code{host:/site/host/local/lib/emacs} and link all of the children
therein to the local file directory @code{/usr/local/lib/emacs}.

@cindex Making use of local disk space
@cindex Local disk space, make use of
Here is another example which makes reference to the cfengine model for
mounting NFS filesystems.  Suppose you have a host with some spare disk
space.  You want to mount @code{/usr/local} from the binary architecture
server, but you also want to use the disk you have locally.  The
following lines

@smallexample
links:

   electron::

      /$(site)/electron/local +> linkchildren

   any::

      /usr/local              -> /$(site)/$(binserver)/local

@end smallexample 

@noindent
have the effect of creating a directory @code{/$(site)/electron/local}
and filling it with links to all of the files and directories on the
binary server's mounted filesystem.  It results in an exact copy (by
linkage) on the local disk, but does not use up your local disk space.
The space you have remaining could, for example, be used for software
with a special license for that host.  The second link links
@code{/usr/local} to the `nearest' binary server.  But the nearest
binary server is always @code{$(host)} which means this evaluates to a
file which now exists because of the first command, so on the host
`electron' the directory @code{/usr/local} ends up being a link to
@code{/$(site)/electron/local} which is full of links to the binary
server.

If you've caught your breath after that mouthful you probably have mixed
feelings about creating a bunch of links in this way.  What happens if
the files they point to are removed? Then you are left with a lot of
useless links.  Actually this is no problem for cfengine, since you can
ask cfengine to simply remove links which point to non-existent files
@xref{files}.  Nevertheless, this feature clearly requires some caution
and is mainly a spice for advanced users of the cfengine model.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Relative and absolute links, Hard links, Link Children, links
@subsection Relative and absolute links

When specifying symbolic linking, you can ask cfengine
to change the link type to be either relative to the
source or to be an absolute path. What this means is the
following. Consider the following link:
@smallexample

   /var/tmp/cfengine -> /local/cfengine

@end smallexample

@noindent
If we add the option @code{type=relative}, then instead
of creating a link which points to @file{/local/cfengine},
the link is created pointing to the location

@smallexample
  ./../../local/cfengine
@end smallexample

@noindent
In other words, the link is relative to the calling
directory @file{/var/tmp}.

If a link is specified as being absolute with the option
@code{type=absolute}, then cfengine attempts to resolve
to value of the link so as to be the true path of the
target. If the target name contains a symbolic link, then
this is expanded as far as possible to give the true
path to the file. For example, if @file{/local} is
really a link to @file{/site/myhost/local} then the link
would point to @file{/site/myhost/local/cfengine}.

@c .....................................................
@c SUBSECTION
@c .....................................................

@node Hard links,  , Relative and absolute links, links
@subsection Hard Links
@cindex Hardlinks
@vindex type=

Cfengine will also allow you to create hard links to regular files.  A
hard link is in every way identical to the original file, it merely has
a different name (technically, it is a duplicate inode). To create a
hard link you use the link-option @code{type=hard}. For example:

@smallexample

links:

   /@var{directory}/@var{newname} -> /@var{directory}/@var{othername} type=hard

@end smallexample

@noindent
Cfengine will not create hard links to directories or other special files.
This is always a slightly dubious practice and is best avoided anyway.
POSIX says that the hard link can be on a different device to the file
it points to, but both BSD and System 5 restrict hard links to be on
the same device as their predecessors. Cfengine has no policy on this,
but---in the theoretical case in which the hard link and the predecessor
were on different file systems---it becomes near impossible to determine
with certainly between a hard link and a very similar regular file, and thus
cfengine issues a warning in verbose mode about this eventuality.
Provided both link and predecessor are on the same filesystem cfengine
determines the status of hard links by comparing the device and inode
numbers of the file pointed to.

@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node mailserver, miscmounts, links, Command reference
@section mailserver
@cindex Mail server, defining
@cindex Defining a mail server
@vindex mailserver

The @code{mailserver} declaration need only be used if you are using
cfengine's model for mounting NFS filesystems.  This declaration informs
hosts of which NFS filesystem contains mail for its users.  All hosts
apart from the mail-host itself must then mount the mail spool directory
across the network.  The declaration looks like this:

@smallexample

mailserver:

   @var{class}::      mailhost:/var/spool/mail 

@end smallexample 

@noindent
The result of the @code{checkmail} command in the action-sequence is now
to mount the filesystem @code{/var/spool/mail} on the host
@code{mailhost}.  This action is carried out on any machine which does
not already have that filesystem mounted.
@vindex checkmail

The mail spool directory is mounted, by default, onto the official mail
spool directory for the system which is parsing the program.  In other
words, on an HPUX system, the spool directory is mounted on
@code{/usr/mail} by default, whereas on a Sun system it would be mounted
on @code{/var/spool/mail}.  The default location can be changed by using
the resource file.  @xref{cfrc resource file}.


@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node miscmounts, mountables, mailserver, Command reference
@section miscmounts
@cindex Mounting filesystems.
@cindex Miscellaneous mount operations
@vindex miscmounts

If you do not use the cfengine model for statically mounting NFS
filesystems (or if there are filesystems which do not naturally fall
into the bounds of that model) then you can still statically mount
miscellaneous filesystems using a statement of the form:

@cartouche
@smallexample

miscmounts:

   @var{class}::

      @var{infohost}:@var{source-directory} @var{destination} @var{mode}

@end smallexample 
@end cartouche

@noindent
For example
@smallexample

   physics::

      libraryserver:/$(site)/libraryserver/data 
                          /$(site)/libraryserver/data ro

@end smallexample

@noindent
This statement would mount the directory
@file{/$(site)/libraryserver/data} physically attached to host
libraryserver onto a directory of the same name on all hosts in the
group @code{physics}.  The modes @code{ro} and @code{rw} signify
read-only and read-write respectively.


@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node mountables, processes, miscmounts, Command reference
@section mountables
@cindex Mountable resources, defining
@cindex Defining a mountable
@vindex mountables

The @code{mountables} declaration need only be used if you are using
cfengine's model for mounting NFS filesystems.  This declaration informs
hosts of what filesystem resources are available for mounting.  This
list is used in conjunction with @code{binservers} and
@code{homeservers} to determine which filesystems a given host should
mount, according to the cfengine model.

The syntax of the list is:

@smallexample

mountables:

   @var{class}::

   server:/site/server/u1
   server:/site/server/local
   linuxhost:/site/linuxhost/local
   linuxhost:/site/linuxhost/u1


@end smallexample 

@noindent
Notice that binary and home-directory filesystems are mixed freely here.
Cfengine determines which of the entries are homedirectories using the
@code{homepattern} variable.
@vindex homepattern
@cindex Homepattern variable.

Every time you add a disk or a mountable partition to your network, you
should add the partition to the list of mountables.

@emph{NOTE: This list is read in order, top down.  Cfengine looks for
the first filesystem matching a given binary server when expanding the
variable @code{$(binserver)}, so sometimes the ordering of filesystems
matters.}

This list can be accessed in editfiles, to allow straightforward
configuration of the automounter, using the command @code{AutomountDirectResources}.


@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node processes, required, mountables, Command reference
@section processes
Using the processes facility, you can test for the existence of
processes, signal (kill) processes and optionally restart them
again. Cfengine opens a pipe from the system ps command and searches
through the output from this command using regular expressions to match
the lines of output from @samp{ps}.  The regular expression does not
have to be an exact match, only a substring of the process line.  The
form of a process command is

@cartouche
@smallexample
processes:

    @var{"quoted regular expression"} 
                        restart @var{"shell command"} 
                        useshell=@b{true}/@var{false}
                        signal=@var{signal name}
                        matches=@var{number}
                        define=@var{classlist}
                        action=@b{signal}@var{/do/warn}

    SetOptionString @var{"quoted option string"}

@end smallexample
@end cartouche

By default, the options sent to ps are "-aux" for BSD systems and "-ef"
for system 5.  You can use the @code{SetOptionString} command to redefine
the option string. Cfengine assumes only that the first identifiable number
on each line is the process identifier for the processes, so you must not
choose options for ps which change this basic requirement (this is not a
problem in practice). Cfengine reads the output of the ps-command normally only
once, and searches through it in memory. The process table is only
re-consulted if @code{SetOptionString} is called. The options have the
following meanings:

@table @code

@item signal=@var{signal name}
This option defines the name of a signal which is to be sent to all processes
matching the quoted regular expression. If this option is omitted, no signal
is sent. The signal names have the usual
meanings. The full list, with largely standardized meanings, is

@smallexample
   hup       1   hang-up
   int       2   interrupt
   quit      3   quit
   ill       4   illegal instruction
   trap      5   trace trap
   iot       6   iot instruction
   emt       7   emt instruction
   fpe       8   floating point exception
   kill      9   kill signal
   bus      10   bus error
   segv     11   segmentation fault
   sys      12   bad argument to system call
   pipe     13   write to non existent pipe
   alrm     14   alarm clock
   term     15   software termination signal
   urg      16   urgent condition on I/O channel
   stop     17   stop signal (not from tty)
   tstp     18   stop from tty
   cont     19   continue
   chld     20   to parent on child exit/stop
   gttin    21   to readers pgrp upon background tty read
   gttou    22   like TTIN for output if (tp->t_local&LTOSTOP)
   io       23   input/output possible signal
   xcpu     24   exceeded CPU time limit
   xfsz     25   exceeded file size limit
   vtalrm   26   virtual time alarm
   prof     27   profiling time alarm
   winch    28   window changed
   lost     29   resource lost (eg, record-lock lost) 
   usr1     30   user defined signal 1
   usr2     31   user defined signal 2

@end smallexample
@noindent
Note that cfengine will not attempt to signal or restart processes 0 to 3
on any system since such an attempt could bring down the system. The only
exception is that the hangup (hup) signal may be sent to process 1
(init) which normally forces init to reread its terminal configuration
files.
@cindex Processes, 0 to 3

@item restart @var{"shell command"}

Note the syntax: there is no equals sign here.  If the keyword `restart'
appears, then the next quoted string is interpreted as a shell command
which is to be executed after any signals have been sent.  This command
is only issued if the number of processes matching the specified regular
expression is zero.  This could be used to restart a daemon for
instance. Cfengine executes this command and @emph{waits} for its
completion so you should normally only use this feature to execute
non-blocking commands, such as daemons which dissociate themselves from
the I/O stream and place themselves in the background. Some unices leave
a hanging pipe on restart (they never manage to detect the end of file
condition). This occurs on POSIX.1 and SVR4 popen calls which use
wait4. For some reason they fail to find and end-of-file for an exiting
child process and go into a deadlock trying to read from an already dead
process. This leaves a zombie behind (the parent daemon process which
forked and was supposed to exit) though the child continues.  A way
around this is to use a wrapper script which prints the line
"cfengine-die" to STDOUT after restarting the process. This causes
cfengine to close the pipe forcibly and continue.  
@cindex Deadlock zombie bug in restart
@cindex Restart zombie deadlock bug
Cfengine places a timeout on the restart process and attempts to
clean up zombies, but you should be aware of this possibility.

@item useshell=@var{true/false}
When restarting processes, cfengine normally uses a shell to
interpret and execute the restart command. This has inherent
security problems associated with it. If you set this option to
true, cfengine executes restart commands without using a shell.
This is recommended, but it does mean that you cannot use any
shell operators or features in the restart command-line.

@item matches=@var{number}
This option may be used to set a maximum, minimum or exact number of
matches. If cfengine doesn't find a number of matches to the regular
expression which is in accordance with this value it signals a warning.
The @samp{<}, @samp{>} symbols are used  to specify upper and lower
limits. For example,

@smallexample
  matches=<6  # warn number of matches not less than 6
  matches=1   # warn if not exactly 1 matching process
  matches=>2  # warn if there are fewer than 2 matching processes
@end smallexample
@cindex Processes, counting
@cindex 

@item define=@var{classlist}
The colon, command or dot separated list of classes becomes activated if the
number of regular expression matches is non zero.

@item action=@var{signal/do/warn}
The default value of this option is to silently send a signal
(if one was defined using the @code{signal} option) to matching
processes. This is equivalent to setting the value of this
parameter to @samp{signal} or @samp{do}. If you set this option
to @samp{warn}, cfengine sends no signal, but prints a message
detailing the processes which match the regular expression.
@cindex Processes, checking existence of
@cindex Processes, signalling

@end table

Here is an example script which sends the hang-up signal to cron,
forcing it to reread its crontab files:

@smallexample

processes:

   "cron" signal=hup

@end smallexample

@noindent
Here is a second example which may be used to restart the nameservice
on a solaris system:

@smallexample

processes:

   solaris::

       "named" signal=kill restart "/usr/sbin/in.named"

@end smallexample

@noindent
A more complex match could be used to look for processes belonging to
a particular user. Here is a script which kills ftp related processes
belonging to a particular user who is known to spend the whole day
FTP-ing files:

@smallexample

control:

    actionsequence = ( processes )

  #
  # Set a kill signal here for convenience
  #

    sig = ( kill )

  #
  # Better not find that dumpster here!
  #

    matches = ( 1 )

processes:

   #
   #  Look for Johnny Mnemonic trying to dump his head, user = jmnemon
   #

   ".*jmnemon.*ftp.*" signal=$(sig) matches=<$(matches) action=$(do)

   # No mercy!

@end smallexample

@noindent
The regular expression @samp{.*} matches any number of characters, so this
command searches for a line containing both the username and something to
do with ftp and sends these processes the kill signal.
Further examples may be found in the FAQ section @xref{FAQS and Tips}.


@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node required, resolve, processes, Command reference
@section required

This is a synonym for disks, @xref{disks}.
This action tests for the existence of a file or filesystem.  It should
be called after all NFS filesystems have been mounted.  You may use the
special variable @code{$(binserver)} here.

@cartouche
@smallexample

  required:

    /@var{filesystem} freespace=@var{size-limit} define=@var{class-list(,:.)} 

@end smallexample
@end cartouche

Files or filesystems which you consider to be essential to the operation
of the system can be declared as `required'.  Cfengine will warn
if such files are not found, or if they look funny.

Suppose you mount your filesystem @code{/usr/local} via NFS from some
binary server.  You might want to check that this filesystem is not
empty! This might occur if the filesystem was actually @emph{not}
mounted as expected, but failed for some reason.  It is therefore not
enough to check whether the directory @code{/usr/local} exists, one must
also check whether it contains anything sensible.

Cfengine uses two variables: @code{sensiblesize} and
@code{sensiblecount} to figure out whether a file or filesystem is
sensible or not.  You can change the default values of these variables
(which are 1000 and 2 respectively) in the @code{control} section.
@xref{control}.

If a file is smaller than @code{sensiblesize} or does not exist, it
fails the `required' test.  If a directory does not exist, or contains
fewer than @code{sensiblecount} files, then it also fails the test and a
warning is issued.

@smallexample

required:

   any::
      
      /$(site)/$(binserver)/local

@end smallexample

If you set the @code{freespace} variable to a value (the default units are kilobytes,
but you may specify bytes or megabytes), e.g.
@vindex freespace=
@cindex freespace=
@cindex Warning about full disks
@cindex Full disk warnings

@smallexample

required:

  /site/host/home1 freespace=50mb define=dotidy

@end smallexample

@noindent
then cfengine will warn when the filesystem concerned has less than this
amount of free space. By adding a @code{define} tag, you can switch on
any number of classes if this happens. This allows you to activate special
measures for dealing with a filesystem which is in danger of becoming
full.

@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node resolve, shellcommands, required, Command reference
@section resolve

@cindex DNS
@cindex Resolver configuration
@cindex resolv.conf
@vindex resolve

The file @code{/etc/resolv.conf} specifies the default nameserver for
each host, as well as the local domain name.  This file can also contain
other information, but these are the only two things cfengine currently
cares about.  In specifying nameservers you should use the dotted
numerical form of the IP addresses since your system may not understand
the text form if it is not correctly configured.  You may list as many
nameservers as you wish, with the default server at the top of the list.
The resolver normally ignores entries if you add more than three.  The
statement:

@smallexample

resolve:

  mygroup::

     129.240.22.35
     129.240.22.222
     129.240.2.3

@end smallexample 

@noindent
declares a list of nameservers for hosts in the group or class
@code{mygroup}.  When you add the @code{resolve} command to the
@code{actionsequence}, this declaration together with the @code{domain}
variable (set here to @code{uio.no}) results in a
@code{/etc/resolv.conf} file of the form:

@smallexample

domain uio.no
nameserver 129.240.22.35
nameserver 129.240.22.222
nameserver 129.240.2.3

@end smallexample 

@noindent
Note that the @code{resolve} action does not delete anything from the
file @code{/etc/resolv.conf}.  It adds nameservers which do not
previously exist and reorders the lines of servers which do exist.

As of version 1.3.11, you may use a quoted string to add non-nameserver
lines to this file. For example:

@smallexample

resolve:

  mygroup::

     129.240.22.35
     129.240.22.222
     "# Comment line"
     "order bind, files"

@end smallexample
@noindent
If the line begins with a non-numeric character, the word `nameserver'
is not added to the line.

@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node shellcommands, tidy, resolve, Command reference
@section shellcommands

Cfengine focuses on fairly simple minded tasks in order to be as general
as possible.  In many cases you will therefore want to write a script to
do something special on your system.  You can still take advantage of
the classes you have defined by executing these scripts or shell
commands from this section.

The syntax is simply to quote the command you wish to be executed.

@cartouche
@smallexample
shellcommands:

  "@var{command-string}"  timeout=@var{seconds} useshell=@b{true}@var{/false}

@end smallexample
@end cartouche

@noindent
If you set the optional timeout string, then cfengine will abort the
shellcommand if it exceeds the specified time-limit in seconds. This can
be useful for avoiding situations caused by hung network connections
etc.
@cindex @code{timeout=} in shellcommands
@mbindex How can I set a timeout for a shell command?
@mbindex How can I avoid hanging shellcommands?
@mbindex Hanging commands, timeouts

Variable substitution works within the strings.  Here are some examples.

@smallexample

shellcommands:

   sun4::

       "/usr/lib/find/updatedb"

   AllHomeServers.Sunday::

       "/dir/noseyparker /$(site)/$(host)/u1 $(sysadm) nomail"

   AllBinaryServers.sun4.Saturday::

      "/usr/etc/catman -w -M /usr/local/man"
      "/usr/etc/catman -w -M /usr/local/X11R5/man"
      "/usr/etc/catman -w -M /usr/man"
      "/usr/etc/catman -w -M /usr/local/gnu/man"

@end smallexample 

@noindent
Some scripts, such as @code{noseyparker} and a
user-backup script, are included in the distribution to help you.
@xref{Using the help scripts}.

If you need to write more advanced scripts, which make detailed use of the
classes defined by cfengine, use the @code{$(allclasses)} variable to send
a complete list of classes to your script in the format

@smallexample

CFALLCLASSES=class1:class2:class3...

@end smallexample

@noindent
This variable is kept up-to-date at any given time with only the classes
which are defined.  The command line option @samp{-u} or
@samp{--use-env} can be used to define an environment variable which
will be inherited by all scripts and contains the same information.
This is not the standard approach, since some systems cannot
cope with this rapid change of environment and generate a Bus Error.
@cindex CFALLCLASSES
@cindex allclasses variable
@cindex Scripts and class information
@cindex Class information, passing to scripts

Commands can be iterated over variable lists, provided there is
at least one space between each variable. For example:

@smallexample

control: 

      actionsequence = 
         (
         shellcommands
         )

 var1 = ( a:b:c )
 var2 = ( x:y:z )

shellcommands:

   "/bin/echo $(var1) $(var2)"

@end smallexample
@noindent
This iterates over all values of the list variables @xref{Iterating over lists}.
@cindex Iterating over lists in shellcommands
If you are iterating over a list, the timeout applies to each separate
iteration, not to the sum of all the iterations.
@cindex Timeouts during iterations

@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node tidy, unmount, shellcommands, Command reference
@section tidy
@cindex Tidying files
@cindex Deleting files
@vindex tidy

The tidy function is used to delete (remove permanently) unwanted files
from a system.  It is useful for tidying up in @code{/tmp} or cleaning
out @code{core} files from users' home directories.  The form of an
entry is:

@cartouche
@smallexample
tidy:

  @var{class}::

      @var{/directory} 
                       pattern=@var{wildcard} 
                       recurse=@var{number/inf} 
                       age=@var{days} 
                       size=@var{number/empty}
                       type=@var{ctime/mtime/}@b{atime}
                       dirlinks=@var{keep/tidy/delete}
                       rmdirs=@var{true/false}
                       links=@b{stop/keep}@var{/traverse/tidy}
                       define=@var{classlist}

@end smallexample 
@end cartouche

@noindent
Note that, each of the options below
can be written in either upper or lower case and abbreviated by any
unique abbreviation.
@vindex p=
@vindex pattern
@vindex a=
@vindex age
@vindex r=
@vindex recurse

@table @code

@item @var{/directory}
This is the directory name to directories which mark the start of a
search for files matching certain wildcards.  The wildcard @code{home}
may be used instead of an explicit directory, in which case cfengine
iterates over all home directories.  It is compulsory to specify a
directory.

@item pattern=@var{wildcard}
A wildcard or filename to match the files you wish to be deleted.  The
pattern may contain the special symbols @samp{?} which matches a single
character and @samp{*} which matches any number of characters as in the
shell.
@vindex Wildcards

@item recurse=@var{number/inf}
This specifier tells cfengine whether or not to recurse into
subdirectories.  If the value is zero, only the named file or directory
is affected.  If the value is 1, it will open at most one level of
subdirectory and affect the files within this scope.  If the value is
@code{inf} then cfengine opens all subdirectories and files beginning
from the specified filename.@xref{Recursion}.

@item age=@var{days}
The age of a file in days represents a minimum @emph{access} time
elapsed before the file will be deleted.  In other word a file will be
deleted if it has not been accessed for @var{days} days.

@item links=@var{stop/traverse/tidy}
Normally cfengine does not descend into subdirectories which are pointed
to by symbolic links.  If you wish to force it to do so (without using
the @code{-l} command line option) you may give this option the value
@code{true}, or @code{traverse}, or @code{follow}.  To specify no
recursion you set the value @code{false} or @code{stop}.
@cindex Links, traversing in searches
@vindex -l
@cindex -l option
Note that the value set here in the cfengine program @emph{always
overrides} the value set by the @code{-l} command line option, so you
can protect certain actions from this command line option by specifying
a negative value here.  If you specify no value here, the behaviour is
determined by what you specify on the command line.

The value @code{links=tidy} has the same effect as the @samp{-L} command
line option except that here it may be specified per item rather than
globally.  Setting this value causes links which point to non-existent
files to be deleted. This feature will not work on commands with the
@samp{home} wildcard feature.  If you want to clean up old links you
should either user a @code{files} command or the command line option
which sets the tidy feature globally.
@cindex Deleting stale links
@cindex Links, deleting stale

@item size=@var{number/empty}
The value of this parameter decides the size of files to be deleted.
Files larger than this value will be deleted if they also are older than
the time specified in @code{age}. The default size is zero so that any
file which gets matched by another critereon is deleted. However, if you
want to single out only totally empty files, the @code{empty} may be used.
With this option only empty files, nevery files with anything in them,
 will be deleted, if older than @code{age}. By default, the filesizes
are in kilobytes, but kilobytes and megabytes may also be specified by
appending b,k,m to the numbers. Only the first character after the
number is significant so you may write the numbers however it might be
convenient, e.g. @kbd{14k}, @kbd{14kB}, @kbd{14kilobytes}, the same as
for @code{disable}.
@cindex Specifying file sizes
@cindex File sizes, specifying
@cindex Megabytes, filesize unit
@cindex Kilobyte, filesize unit
@cindex Empty files
@cindex Tidying empty files

@item type=@var{ctime/mtime/atime}
This value is used to set the type of time comparison made using
@code{age}. The default is to compare access times (atime) or
the last time the file was read. A comparison by modification 
time (mtime) uses the last time the contents of the file was
changed. The ctime parameter is the last time the contents, owner
or permissions of the file were changed.

@item dirlinks=@var{keep/tidy/delete}
This value is used to decide whether cfengine will delete
links which point to directories. The default value is to keep
the links. Note that, if the travlinks option is switched on,
cfengine will not tidy or delete links which point to directories,
instead it follows them into the subdirectory.

@cindex Tidy by ctime, mtime, atime
@cindex ctime tidies
@cindex mtime tidies
@cindex atime tidies

@item rmdirs=@var{true/false}
Normally cfengine will not delete directories. If this option is
set to `true' then cfengine will delete any directories which
are @emph{empty}. Non-empty directories will not be touched and no
message will be given unless in verbose mode. Note that this
option overrides the above option @code{dirlinks}, so that even
links which point to empty directories will be removed.

@cindex rmdirs
@cindex Removing directories
@cindex Deleting directories
@cindex Directories, deleting

@item define=@var{classlist}
The colon, comma or dot separated list of classes becomes defined
if any file matching the specified pattern is deleted.

@end table
Take a look at the following example:

@smallexample
tidy:

   AllHomeServers::

       home     pattern=core   R=inf age=0
       home     pattern=*~     R=inf age=7
       home     pattern=#*     R=inf age=30


   any::

       /tmp/    pat=*            R=inf   age=1
       /        pat=core         R=2     age=0
       /etc     pat=hosts.equiv  r=0     age=0

@end smallexample 

In the first example, all hosts in the group @code{AllHomeServers}
iterate a search over all user home directories looking for `core' files
(older than zero days) and @code{emacs} backup files @samp{*~},
@samp{#*} older than seven days.

The default values for these options are the empty string for the
wildcard pattern, zero for the recursion and a specification of the age
is compulsory.

@cindex .cfengine.rm
@vindex .cfengine.rm
When cfengine tidies users' home directories, it keeps a log of all the
files it deletes each time it is run.  This means that, in case of
accidents, the user can see that the file has been deleted and restore
it from backup.  The log file is called @code{.cfengine.rm} and it is
placed in the home directory of each user.  The file is owned by root,
but is readable to the user concerned.


@page

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node unmount,  , tidy, Command reference
@section unmount

@cindex Unmounting filesystems
@vindex unmount

The unmount function unmounts non-required filesystems and removes the
appropriate entry from the filesystem table (@code{/etc/fstab} or
equivalent).  The syntax is simply

@cartouche
@smallexample
unmount:

   @var{class}::
 
      @var{mounthost}:@var{filesystem}

@end smallexample 
@end cartouche

@noindent
For example:

@smallexample
unmount:

   physics::

      libraryserver:/$(site)/libraryserver/data

@end smallexample

@noindent
If the device is busy then the actual unmount will not take place until
it becomes free, or the machine is rebooted.  This feature should work
on AIX systems, in spite of these machines inherent peculiarities in the
form of the filesystem table.



@c **********************************************************************
@c CHAPTER
@c **********************************************************************

@node Writing scripts for cfengine, Problem solving, Command reference, Top
@chapter Cfengine script gallery

@cindex Scripts, writing
@cindex Scripts, examples

Here is a gallery of simple-minded scripts to give you ideas for making your
own.  The absence of explicit testing in cfengine programs also
makes these scripts transparent while offering a higher level of
checking for no cost to the programmer.  Similar shell scripts with this
property would be complex indeed.

@menu
* Old files::                   tidying up
* Sharing files::               opening files for other users
* Disk clearing::               emergency clean-up script
* Script for making links::     maintaining links
* Ftp server::                  setting up an anonymous ftp server
@end menu

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Old files, Sharing files, Writing scripts for cfengine, Writing scripts for cfengine
@section User scripts for tidying old files

Here is an example script for tidying old files in your own login area.
If you want a long diagnostic, add the option @code{-v} to the first
line of the script, before @code{-f}.

@smallexample
#!/usr/local/bin/cfengine -f
#
# Tidy
#

control:

   actionsequence =
      (
      tidy
      )


tidy:

      $(HOME)        pat=core   r=inf  age=0
      $(HOME)        pat=*~     r=inf  age=1
      $(HOME)        pat=#*     r=inf  age=7
      $(HOME)/code   pat=*.o    r=inf  age=7
      $(HOME)/tex    pat=*.dvi  r=inf  age=7
      $(HOME)/tex    pat=*.log  r=inf  age=7
      $(HOME)/tex    pat=*.aux  r=inf  age=7

      $(HOME)/ftp    pat=*.zip  r=inf  age=7

@end smallexample

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Sharing files, Disk clearing, Old files, Writing scripts for cfengine
@section Controlled opening of files for friends and colleagues

@smallexample
#!/local/gnu/bin/cfengine -f
#
# Open my shared directory for others in my group
#
#


control:

  actionsequence =
     (
     files
     )

  gr = ( myshare )


files:

      $(HOME)       mode=0755 action=fixdirs r=0               
      $(HOME)/share mode=0664 action=fixall  r=inf group=$(gr)

@end smallexample 

@noindent
In this example, first your home directory is opened for the world, then
all files in the subdirectory @code{share} and subdirectories are
opened to the group @code{myshare}.  This script could be made to run
from a login/logout script of some kind (either @code{.login} or
@code{.xsession}) so that any new files would automatically be
controlled.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Disk clearing, Script for making links, Sharing files, Writing scripts for cfengine
@section Root script for emergency disk clearing

A straightforward script could be used to clear space in cases where the
disk hits the overflow level.  This script tidies the whole system, not
just the affected disk.

@smallexample
#!/local/gnu/bin/cfengine -f
#
# Emergency tidyup!
#
# (Users read their cfengine.rm files to see what got deleted!)
#

control:

site = ( mysite )

mountpattern = ( $(site)/$(host) )
homepattern   = ( u? )

actionsequence =
   (
   tidy
   )


tidy:

      home            pattern=core   R=inf   age=0
      home            pattern=*~     R=inf   age=0
      home            pattern=*.dvi  R=inf   age=1
      home            pattern=*.o    R=inf   age=0
      /tmp            pattern=*      R=inf   age=0  # could be risky
      /usr/tmp        pattern=*      R=inf   age=0  #      "

ignore:

     .X11

@end smallexample

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Script for making links, Ftp server, Disk clearing, Writing scripts for cfengine
@section Script for making links

The following script could be used as part of a software installation procedure.
Note that the link types can be made relative to the from-link by using
@code{type=relative} @xref{links}.

@smallexample
#!/tmp/cfengine -v -f
#
# Simple example script to make links
#

control:

  actionsequence = ( links )

links:

 host::

   /usr/local/bin                  +> /usr/local/lib/soft/bin
   /usr/local/X11/lib/app-defaults +> /usr/local/lib/soft/app-defaults

@end smallexample 

@noindent
It makes links from every binary file in the packages `bin' directory to
the more standard binary directory @code{/usr/local/bin}.  This avoids
having to place another search directory into the users' @code{path}
variable.  The second statement links the package's application defaults
files (for the X-windows system) to a directory in the
@code{XAPPLRESDIR} search path.

This script provides only one way of making the necessary files available
to users.  It is not the only solution to the problem.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Ftp server,  , Script for making links, Writing scripts for cfengine
@section Ftp server

This script carries out the necessary for setting up a safe anonymous
ftp server on a sun workstation running SunOS4.1.

@smallexample
#!/local/gnu/bin/cfengine -f
##############################################################
#
# Cfengine script to set up an outgoing ftp server under
# SunOS 4.1.*.  Suitable for anonymous access.
#
###############################################################

control:

 addclasses = ( local global )

 actionsequence =
    (
    editfiles.global
    directories
    shellcommands
    files
    editfiles.local
    )

 ftp_root = ( /oih/saga/local/ftp )   # macro for convenience
 ftp_id   = ( 99 )                    # uid/gid for ftp

################################################################

editfiles:

 # Note the file /etc/ftpusers can contain a list of users
 # who can NOT use ftp to access files.

 global::

 @{ /etc/passwd

 AppendIfNoSuchLine "ftp:*:$(ftp_id):$(ftp_id): @emph{(line continues)}
Anonymous ftp:$(ftp_root):/usr/ucb/ftp"
 @}

 @{ /etc/group

 AppendIfNoSuchLine "ftp:*:$(ftp_id):"
 @}

################################################################

directories:

  $(ftp_root)           mode=0555 owner=ftp
  $(ftp_root)/pub       mode=0555 owner=ftp
  $(ftp_root)/bin       mode=0555 owner=root
  $(ftp_root)/usr       mode=0555 owner=root
  $(ftp_root)/dev       mode=0555 owner=root
  $(ftp_root)/etc       mode=0555 owner=root
  $(ftp_root)/dev       mode=0555 owner=root
  $(ftp_root)/usr/lib   mode=0555 owner=root

###############################################################

shellcommands:

  "/bin/cp /bin/ls $(ftp_root)/bin/ls"
  "/bin/cp /lib/libc.so.1.8* $(ftp_root)/usr/lib"
  "/bin/cp /usr/lib/ld.so  $(ftp_root)/usr/lib"
  "/bin/cp /usr/lib/libdl.so.1.0 $(ftp_root)/usr/lib/libdl.so.1.0"
  "/usr/etc/mknod $(ftp_root)/dev/zero c 3 12 > /dev/null 2>&1"

##########################################################################

files:

 $(ftp_root)/bin/ls     mode=111 owner=root action=fixall
 $(ftp_root)/usr/lib    mode=555 owner=root action=fixall r=1
 $(ftp_root)/etc/passwd mode=444 owner=root action=touch
 $(ftp_root)/etc/group  mode=444 owner=root action=touch
 $(ftp_root)/pub        mode=644 owner=root action=fixall

################################################################

editfiles:

 local::

 @{ $(ftp_root)/etc/passwd

 AppendIfNoSuchLine "ftp:*:$(ftp_id):$(ftp_id): @emph{(line continues)}
Anonymous ftp:$(ftp_root):/usr/ucb/ftp"
 @}

 @{ $(ftp_root)/etc/group

 AppendIfNoSuchLine "ftp:*:$(ftp_id):"
 @}

@end smallexample

@c **********************************************************************
@c CHAPTER
@c **********************************************************************

@node Problem solving, Using the help scripts, Writing scripts for cfengine, Top
@chapter Problem solving, bugs, FAQs and tips

@menu
* cf.preconf bootstrap file::   network bootstrapping
* cfrc resource file::          changing the internal defaults
* Problems with compilation and installation::  
* Bug reports and suggestions::  
* FAQS and Tips::               
@end menu

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node cf.preconf bootstrap file, cfrc resource file, Problem solving, Problem solving
@section @file{cf.preconf} bootstrap file
@cindex cf.preconf bootstrap file
@vindex cf.preconf
@cindex Bootstrap file
@cindex Deadlock
@cindex Hung machine

In some cases you will want to run cfengine on a system to configure it
from scratch.  If the system is in a very bad way, it might not even be
able to parse the cfengine configuration file, perhaps because the
network was not properly configured or the DNS (Domain Name Service) was
out of action.  To help prevent this situation, cfengine looks for a
script called @code{cf.preconf} which gets executed prior to parsing and
can be used to perform any emergency tests.  This file needs only
contain enough to get the system to parse the configuration files.

@code{cf.preconf} may be any script in any language.  It need not exist
at all! It is fed one argument by cfengine, namely the system hard-class
for the current system (e.g.  @code{ultrix}).  Here is an example:

@smallexample
#!/bin/sh 
#
# cf.preconf is an emergency/bootstrap file to get things going
# in case cfengine is unable to parse its config file
#

backupdir=/iu/nexus/local/iu/etc

 #
 # If these files don't exist, you might not be able to parse cfengine.conf
 #

if [ ! -s /etc/resolv.conf ]; then

 echo Patching basics resolv.conf file
 cat > /etc/resolv.conf << XX
domain iu.hioslo.no
nameserver 128.39.89.10
XX

fi

#
# SVR4
#

if [ "$1" = "solaris" ]; then

  if [ ! -s "/etc/passwd" ]; then
 
  echo Patching missing passwd file
    /bin/cp $backupdir/passwd /etc/passwd
  fi

  if [ ! -s "/etc/shadow" ]; then
    
   echo Patching missing passwd file
   /bin/cp $backupdir/shadow /etc/shadow
  fi 
fi

#
# BSD 4.3
#
 
if [ "$1" = "linux" ]; then

   if [ ! -s "/etc/passwd"  ]
   then
    
    echo Patching missing passwd file
    /bin/cp $backupdir/passwd.linux /etc/passwd
   fi
fi




@end smallexample 

@cindex /etc/host.conf
@vindex /etc/host.conf
@cindex -x option
@vindex -x option

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node cfrc resource file, Problems with compilation and installation, cf.preconf bootstrap file, Problem solving
@section @file{cfrc} resource file
@cindex cfrc resource file
@cindex Resource file
@vindex cfrc

If, for some reason you are not satisfied with the defaults which
cfengine uses, then you can change them by making an entry in the
resource file.  The default values are defined in the source code file
@code{classes.c} in the distribution.  The format of the resource file
is:

@smallexample
hardclass.variable: value
@end smallexample 

@noindent
For example, you might want to forget about where your HPUX system
mounts its mail directory and mount it under @code{/usr/spool/mail}.  In
this case you would add the line:

@smallexample
hpux.maildir: /usr/spool/mail
@end smallexample 

@noindent
To redefine the filesystem table for GNU/linux, you would write:
@smallexample
linux.fstab: /etc/linuxfstab
@end smallexample 

@noindent
The full list of re-definable resources is:

@smallexample
   mountcomm       # command used to mount filesystems
   unmountcomm     # command used to unmount filesystems
   ethernet        # name of the ethernet device
   mountopts       # options to above mount command
   fstab           # the name of the filesystemtable
   maildir         # the location of the mail directory
   netstat         # the full path to netstat and options
   pscomm          # the path to the system's ps command
   psopts          # the options used by ps (default aux/ef)
@end smallexample 

You should never need to redefine resources unless you decide to do something
non-standard.  Interested readers are referred to the values in @code{classes.c}.


@cindex Adding new classes
@cindex Support for new systems
@cindex New systems, support for

Cfengine is easily extensible so as to support a variety of
architectures.  You can even add your own.  To do so you need, first of
all, to define a new class for the operating system concerned.  The file
@emph{classes.c} has been separated off from the remainder of the source
code so that you can easily see which data structures need to be
extended.

To make life as straightforward as possible, three unused classes have
been defined.  They are called (unremarkably) @emph{unused1},
@emph{unused2} and @emph{unused3}.  If you add any further classes, it
will be necessary to increase the constant @emph{clssattr} defined in
@emph{cf.defs.h} by one for every new addition.  You do not need to
change @emph{clssattr} if you simple replace one of the unused classes
by a real class.

To see fully the impact of what you need to do, you should make a search
for the strings @emph{unused?} in all of the source files.  Certain
special cases need to be handled for each operating system.  For
example, the form of the filesystem table is quite radically different
on some systems such as AIX.  One thing you must do is to fill in the
default values for the new operating system in the file
@emph{classes.c}.

If you fill in the details for a new operating system before it finds
its way into a new release, you might consider sending the details to
the bug list in the next paragraph.


@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Problems with compilation and installation, Bug reports and suggestions, cfrc resource file, Problem solving
@section Problems with compilation and installation

@cindex Linux, installing
@cindex Netgroups and Linux
@cindex Flex and bison problem
@mbindex Action contains invalid statement problem

Although every effort has been made to make the compilation of cfengine
trouble free, you might still encounter some problems where non-standard
features are concerned. The differences between systems is still a major
headache.

Earlier versions of the GNU/Linux operating system do not have support
for some of the facilities which cfengine uses.  In particular, the
ability to use NIS netgroups is absent from earlier versions.  During
the installation procedure, the @code{configure} script tests for this
possibility and advises you if the facility cannot be used.  You can
still use cfengine in this case but netgroups will not be expanded.
Another problem with GNU/Linux concerns a special socket call to the
TCP/IP network interface.  This is a command which configures the static
routing table and appears to be absent from all versions of Linux and
newer IRIX versions.  There are also problems with NetBSD.  These
features are undocumented and will be fixed as soon as they have been
understood! If you are running in verbose mode a warning message is
printed, otherwise cfengine will ignore attempts to set a default route
on the system.
@cindex Default route, cannot set
@mbindex Why can't I set a default route?

A number of users have experienced a problem using flex and bison
in place of lex and yacc. There appears to be a bug in one of these
programs which causes cfengine to compile correctly but misinterpret
its configuration files, generating an error of the form

@smallexample
cfengine:10:action contains invalid statement
@end smallexample

@noindent
for every line! The cure is to collect the latest versions
of flex and bison from your nearest GNU site.

On really old systems, the configure program is not able to guess
what kind of system you are working on. This is true of SunOS 
versions 4.0.* and also of BSD 4.3 systems. In such cases, you might
be able to compile cfengine by using the autoconf option `host'
to specify the host-type.

@example

configure --host=sparc-sun-sunos4.0

@end example
@noindent
Some other systems which will compile if forced are:
@example
m68k-hp-bsd4.3
?-?-bsd4.3
romp-ibm-aos
?-?-aos
@end example

On some systems, problems arise when using flex. Flex might
generate a lexer file lex.yy.c which defines malloc or some other
function to be of a type which conflicts with the system definition.
If you obtain such a culture crash, edit the lexer file manually
and simply delete the offending definitions, then run make again.

As of version 1.4.0 cfengine tries to link in features based on
the Berkeley database library @file{libdb} and the TCP wrappers
library @file{libwrap}.
@cindex Berkeley database library
@cindex TCP wrappers
@cindex @code{db} library
If you want to use these facilities, you will have to collect them
and install them before compiling cfengine.
Some problems have been experienced with the linux version of
TCP wrappers. If you experience compilation problems, the
best thing to do is to edit @file{src/conf.h}
after configuration and remove the line beginning @samp{#define HAVE_LIBWRAP}.

Newer solaris systems have ACLs. The ACL features only matured in version
2.5 of solaris however, and there have been some problems with the
partial implementation in 2.4. If you obtain error messages about unknown
ACL functions, edit the @file{config.cache} file in the cfengine root
directory and set the value:
@smallexample
ac_cv_header_sys_acl_h=$@{ac_cv_header_sys_acl_h='no'@}
@end smallexample

If you use the DCE (Distributed computing environment) cfengine will try to
compile the ACL extension for DFS. This requires the DCE library to be present
on the system on which you are compiling. On some systems it also requires
thread libraries to be present. Unfortunately, the autoconf program
which generates the Makefiles cannot detect shared libraries, only archive
libraries. This means that you need to edit the @file{config.cache} file
to compile in this support. Set the following values:
@smallexample
ac_cv_lib_dce_main=$@{ac_cv_lib_dce_main='yes'@}
ac_cv_lib_dce_main=$@{ac_cv_lib_thread_main='yes'@}
@end smallexample

Finally, although the autoconfiguration program appends the same
libraries to each executable, the following libraries are required
only by the following programs.
@smallexample

 cfengine   -ldce -lthread -lm
  
 cfd        -ldb -lpthread

@end smallexample

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node Bug reports and suggestions, FAQS and Tips, Problems with compilation and installation, Problem solving
@section Bug reports and suggestions

@cindex Bugs, reporting
@cindex Reporting bugs

If you experience a problem with cfengine, find a bug or have another
suggestion which you wish to air, you can send your thoughts to the
special mail address @code{bug-cfengine@@prep.ai.mit.edu}.

Always think a bit before sending a message to the list. This helps
to keep down the traffic improves the signal to noise ratio of your
thoughts! Try to solve the problem yourself first and look particularly
to see whether your system is clean or whether you have installed
software or patches which might conflict with cfengine (I can't really
imagine how this would happen---but it might). Always be clear
about what type of operating system you are running and whether or not
it is a complete installation.

Some vendors have begun the practice of distributing systems without key
programs like the C compiler, lex and yacc. If you have this problem,
you can pick up GNU replacements gcc, flex and bison from any GNU site.


@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node FAQS and Tips,  , Bug reports and suggestions, Problem solving
@section FAQs and Tips

Here is a problem solver: an encyclopaedia of suggestions and uses for
cfengine as accumulated over the years. If you have a contribution
to make, please send it to @code{cfengine@@iu.hioslo.no}. Format
your submission like this:
@cindex FAQs
@cindex Frequently asked questions
@cindex Hints and Tips
@cindex Tips using cfengine

@table @emph

@item Q:
@emph{How do I do....}

@item A:
Very well thank-you....

@end table
The table below is updated as the tips occur to me, or as others
contribute their own. Please note that any focusing on particular
operating systems is purely a matter of personal usage/experience and
should not be interpreted as a reflection of how many `bugs' these
systems may or may not contain.

@menu
* General::                     
* AIX::                         
* HPUX::                        
* IRIX::                        
* LINUX::                       
* OSF::                         
* SUN (4.1.*)::                 
* SOLARIS 2::                   
* FreeBSD::                     
@end menu

@c .....................................................
@c SUBSECTION
@c .....................................................

@node General, AIX, FAQS and Tips, FAQS and Tips
@subsection General

@table @emph

@item Q:
How can I check to see what cfengine will do without
going through the whole program using @samp{-n}?

@item A:
Run cfengine with options:

@example

  cfengine -p -d3

@end example
@noindent
This just parses the file and dumps the contents of the
parser to the output.

@item Q:
@emph{Why doesn't cfengine have classes for each hour, instead
of just for days?}
@mbindex Why doesn't cfengine have classes for each hour..?
@cindex Time classes, hours
@cindex Hour classes

@item A:
It does from version 1.3.20 and upward. The hours are denoted in
24 hour clock notation by @code{Hr00}---@code{Hr23}. Other time
classes are also possible @xref{Using cfengine as a front-end for cron}.

@item Q: 
@emph{How can I replace the stupid version of sendmail
my vendor ships with my OS with, say, Berkeley sendmail?}
@mbindex Replace the stupid version of sendmail..?
@cindex sendmail
@cindex Berkeley sendmail

@item A: 
First of all, compile your new sendmail in a filesystem
which is held separate from the OS, for example
@file{/local/mail}. You can keep all the files
under this new file tree. Now you need to replace
@file{/usr/lib/sendmail} with the new version and
@file{/etc/sendmail.cf} or @file{/etc/mail/sendmail}
with the new files, so that the system can find them.

@smallexample

   links:
      /usr/lib/sendmail ->! /local/mail/bin/sendmail
      /etc/sendmail.cf  ->! /local/mail/etc/sendmail.cf

@end smallexample

@end table

@c ***********

@table @emph

@item Q: 
@emph{How can I prevent big log-files like @file{/var/adm/wtmpx}
and @file{httpd/access_log} from filling up my partitions?}
@cindex Log-files, preventing overflow
@cindex Controlling log-files
@mbindex Prevent big log-files

@item A: 
Add a line to disable the files once a week. That way
you still get a chance to look at them, but you keep the size
down:

@smallexample

   disable::

      Sunday::
@cindex wtmpx

         #
         # Do this to throw away old entries
         #

         /var/adm/wtmpx rotate=truncate

         #
         # Or this to keep the last lot
         #

         /var/adm/wtmpx rotate=1

@end smallexample

@noindent
An alternative to using @code{disable} would be to use @code{tidy},
but then you lose the file once and for all. Note though, that @file{wtmpx}
gets updated all the time, so an age @code{age=0} is necessary to have any
effect at all. Some daemons, like @file{httpd}, lose their ability to
write to a log file if you rename and create a new file. The @code{rotate}
feature in cfengine preserves the open file handle, fixing this problem.
@cindex disable, problems with logging afterwards
@cindex httpd problem with logging
@cindex disable, trimming log files

@end table

@c *************

@table @emph

@item Q: 
@emph{How can I fix exports in cfengine?}
@cindex exports, fixing
@cindex sharing filesystems
@mbindex Fix exports in cfengine

@item A: 
This is a complicated matter. There are lots of ways to
do it. The key is either to edit the file @file{/etc/exports}
(@file{/etc/dfs/dfstab} in solaris), or to execute an export
(share) command directly from @code{shellcommands}. Under Solaris
2 this is quite easy owing to the fact that the file @file{dfstab}
is just a script itself, rather than a configuration file
like the old @file{/etc/exports} file. Since
editing is limited and you need to specify a list of hosts
which might change in time, one of the following is probably
the best bet:

@smallexample

shellcommands:

   solaris::

      "/usr/sbin/share -F nfs -o rw=@var{netgroup} /var/mail"

@end smallexample
@noindent
On non-solaris systems:

@smallexample

editfiles:

   @{ /etc/exports

   AppendIfNoSuchLine "/@var{site}/@var{host}/@var{fs} -access=@var{netgroup}"
   @}

@end smallexample

@item Q:
@emph{How can I distribute key setup files to users and keep
them up to date?}
@cindex copy
@cindex Distributing files
@cindex Updating files from master source
@cindex Master files, updating from
@mbindex Distribute key set up files to users

@item A:
The copy facility will distribute to all users if you
use the @code{home} directive. For instance, to copy
a basic @file{.cshrc} file or @file{.xsession}, you could
write
@cindex @file{.cshrc}, distributing
@cindex @file{.xsession}, distributing
@cindex Distributing user files

@smallexample

copy:

   /local/masterfiles/.cshrc     dest=home/.cshrc
   /local/masterfiles/.xsession  dest=home/.xsession

@end smallexample

@item Q:
@emph{Some users set up their own IRC listen services called
"eggdrop" which fill up the disk with all kinds of garbage.
How can I kill all these processes?}
@cindex Killing processes
@cindex Processes, killing
@mbindex Killing "eggdrop"
@mbindex Kill user processes

@item A:

@smallexample

processes:

  #
  # Most users
  #

  "eggdrop"  signal=kill

  #
  # One wise-guy has renamed the daemon!
  #

  ".*wiseguy.*myegg.*"  signal=kill

@end smallexample

@item Q:
@emph{My license server keeps crashing!
How can I check that it's ok?}
@cindex Processes, check if running
@mbindex License server crashes
@item A:

@smallexample

processes:

  #
  # BSD - often need long descriptive lines
  #       to find this daemon
  #

  SetOptionString "-ax"

  # Exactly one should be running

  "lmgrd" matches=1

@end smallexample

@item Q:
@emph{I want to use cfengine to keep DNS tables up to date, using
editfiles. How can I make cfengine automatically restart
the name server after the edits?}
@mbindex Edit and restart DNS

@item A:
This can be done in two ways. Probably, you need to
update a serial number as well as restarting the daemon.
You might use a Makefile to simplify this.

@smallexample

control:

  actionsequence = ( editfiles control )

  solaris::
           named = ( /usr/sbin/in.named)
  linux:
  freebsd:
           named = ( /usr/sbin/named )
  sun4:
           named = ( /usr/etc/named )

editfiles:

 # edit files here

shellcommands:

   #
   # If you use make to sort out the details
   #

  "/local/gnu/bin/make -f /local/named/Makefile > /dev/null"

@end smallexample

@noindent
Or if you need to explicitly restart the name daemon, you could
supplement the above with an explicit restart command (this means
you lose the cache),

@smallexample

processes:

  "named" signal=kill restart "$(named)"

@end smallexample

@item Q:
@emph{How can I edit all users' login files?}
@mbindex Edit all users login files
@cindex Editing users login files
@cindex Login files, editing for all users

@item A:
You can use the 'home' pseudo-variable to iterate over all users'
homedirectories:

@smallexample

editfiles:

    @{ home/.cshrc

    # Local fixes

    AppendIfNoSuchLine "alias lp  special-print-command"

    # Security

    DeleteLinesMatching "xhost +"
    @}

@end smallexample

@item Q:
How can I kill all processes except for root processes?

@item A:
The following regular expression matches lines which do not
contain the string root:

@smallexample

processes:

 "\(root\)\@{0\@}"  signal=term # or kill

@end smallexample
@mbindex Kill all processes except root
@cindex Kill processes not owned by root


@item Q: 
How can I make cfengine distribute my @file{/etc/motd} file?
@mbindex How can I make cfengine distribute my @file{/etc/motd} file?
@cindex How can I make cfengine distribute my @file{/etc/motd} file?
@mbindex Message of the day files
@cindex Message of the day files

@item A:
You will need a master file which contains the text you want to put on
your servers. Let us define a variable `masterfile' which contains
this. This master file needs to be available on all hosts on a common
NFS filesystem, for instance.  (This will change when remote copying is
implemented in cfengine.) Now you can do something like the following
script. Note that we define a version number for motd which just
prevents cfengine from editing the file every single time.  You have to
change this version number yourself in the config file to force an
update. If you don't care about this, just leave out the Begin..End
parentheses.

@smallexample

control:

masterfile = ( /usr/local/admin/motd-master )

editfiles:

  any::

     @{ /etc/motd

     BeginGroupIfFileIsNewer "$(masterfile)"
       EmptyEntireFilePlease
       InsertFile "$(masterfile)"
       PrependIfNoSuchLine "This system is running $(class):$(arch)"
       AppendIfNoSuchLine "$(motd_version)"
     EndGroup
     @}

@end smallexample
@noindent
Note that, if you want special messages added just for, say, linux, then
you can single out linux using a special class, or add a special edit
after this one.

Note, if you want to keep the first kernel line in this file, you
can change this to:

@smallexample
editfiles:

   any::

   @{ /etc/motd

   BeginGroupIfFileIsNewer "$(masterfile)"
     IncrementPointer "1"
     DeleteLinesAfterThisMatching ".*"
     InsertFile "$(masterfile)"
     AppendIfNoSuchLine "$(motd_version)"
   EndGroup
   @}

@end smallexample

@mbindex Cfengine security worries
@cindex Cfengine security worries
@item bug-cfengine exchange: (Reply courtesy of David Masterson). 

@emph{I like cfengine a lot and it helps me very much, but I am a little
concerned about security. I'm using cfengine to keep some files like
/etc/hosts /etc/printcap /etc/mount etc. up to date. So cfengine is
started by root in a cron job and reads its cfengine.conf file and all
the other information from a filesystem which is common to all the
systems.  If now somebody manage to alter the cfengine.conf file he can
do everything he wants.  Wouldn't it be a good idea to make the
cfengine.conf file something like a pgp signed messages, so that
cfengine can test if this file was created by the right person? Or are
there other tips to make it more secure?}

I'm not sure, but I think you're over-reacting or you need to be more specific
about where you think the holes are in Cfengine's security.  If you follow the
tips of any standard systems administrator using cfengine or not, there should
be few issues concerning security (ie. if security broke, there would be
little chance that cfengine could do anything about it anyway).

Ask yourself some of the standard questions with respect to security on UNIX:

@itemize @bullet
@item Who owns your script files?
@item Who can update those script files?
@item If those script files are updated by the wrong person, has your security
  been purposely broken or does it just have a hole in it?
@end itemize

If you're still worried about the security of your script (be it a cfengine
script or not), you could always adjust your cron script to "decrypt" the
script file before executing it (see crypt(1)).

Personally, I think if you've set the permissions on your script files
properly, then, if someone breaks into those scripts, they've already broken
into your system to a point where they could do what they wanted anyway.

@item Q:
How can I distribute password files in cfengine, but keep certain passwords
different on some machines, like I can with NIS?

@item A:
If you keep a file with special local passwords, you can override the password
file using @code{editfiles}. First you use @code{copy} to get the distributed
file, then you edit the file like this:
@smallexample

  editfiles:

    @{ /etc/passwd

    SplitOn ":"


    ForEachLineIn "/usr/local/etc/passwd.local"

       ReplaceLinesMatchingField "1"

    EndLoop
    @}

@end smallexample
@noindent
This means, if the first field of each line in the files
matches in both files (and both files have the same column format)
then replace the line in @file{/etc/passwd} with the line from
@file{/usr/local/etc/passwd.local}.
@mbindex How can I override passwords locally?

@item Q:
How can I add entries to a list, like in the fiel @file{/etc/group}?

@item A:
Okay, suppose you wanted to make sure that a special user was in the
group @samp{adm}, you would use a construction like this:
@smallexample
  control:

      person = ( @var{new-user} )


  editfiles:

   @{ /etc/group

   BeginGroupIfNoLineMatching "adm.*$(person).*"
     LocateLineMatching "adm.*"
     AppendToLineIfNotContains ",$(person)"
   EndGroup
   @}

@end smallexample
@cindex @code{AppendToLineIfNotContains}, example
@mbindex How can I add users to the @file{/etc/group} file?

@item Q:
How can I take backups with cfengine?

@item A:
If you have a spare disk partition, you could make a mirror of the
most important files. You would use something like this:
@cindex Backups, with copy
@cindex Making backups

@smallexample

 control:

      excludecopy = ( *.mp3 *.o *.dvi *.ps *.zip *tar* 
                       core a.out *.au *.wav .* *.exe *.tgz )

 copy:

   BackupHost.Hr21::

     /site/host/home dest=/site/host/backup2/u1 r=inf size=<4mb backup=false action=silent

@end smallexample
@noindent
for each partition you want to back up.

@end table


@c .....................................................
@c SUBSECTION
@c .....................................................

@node AIX, HPUX, General, FAQS and Tips
@subsection AIX

@table @emph

@item Q: 
@emph{Hints about AIX?}

@item A:
Send then to @code{bug-cfengine@@prep.ai.mit.edu}.

@item Q:
One of our Sysadmins has noted a limitation with line length under
AIX. I'm not sure how easy it is to fix but it might be worth noting it
somewhere in the cfengine docs.  It appears that on the AIX machines the
maximum line length we can use for cfengine files is defined by the
constant YYLMAX which is set to be 200.  On the Suns this constant is
set to be the same as BUFSIZ which is currently set to be 1024.  This
manifested itself by very unusual behavior as cfengine variables began
to be overwritten when line lengths in the config file exceeded 200
bytes.  Peter can attest to this.  Be forewarned "keep line lengths in
cfengine less than 200 if you want them to work on AIX machines" Moral
of the story "AIX users beware" Do you think we could just recompile
cfengine and use larger buffer sizes all over, I don't know if this
constant is all that should be tweaked or if it is somehow tied into the
lexx implementation also, since lexx is used to create the parser for
the config files.
@cindex lex and yacc problems
@cindex yacc problems
@mbindex Line length bug in AIX/HPUX
@mbindex Lex and yacc in AIX/HPUX


@item A:
This is a problem with lex and yacc, not with cfengine. The variable
BUFSIZ is a system quantity, not related to cfengine's internal
variable bufsize. I would recommend getting bison and flex and
doing away with the old lex and yacc from the system.
Michael Lachowski reports that this is also a problem with HPUX 10's
lex/yacc.

@end table

@c .....................................................
@c SUBSECTION
@c .....................................................

@node HPUX, IRIX, AIX, FAQS and Tips
@subsection HPUX

@table @emph

@item Q: 
Problems with line length in lex/yacc.

@item A: 
See the FAQ for AIX.

@item Q:
@emph{What is the difference between the classes @samp{hpux}
and @samp{hpux10}?}
@mbindex Difference between hpux and hpux10

@item A:
In version 10 of HPUX, the file structure is reorganized
to look more like SVR4. If you have an HPUX-10 system,
the appropriate hardclass is @code{hpux10} rather than
@code{hpux}.

@item Q: 
@emph{I set up the new sendmail but the configuration
file doesn't work.}
@mbindex Frozen configuration files
@cindex sendmail
@cindex Frozen configuration files
@cindex @file{sendmail.fc}

@item A: 
There could be a frozen configuration file around.
Try:

@smallexample
disable:

   hpux::

      /usr/lib/sendmail.fc
      
@end smallexample

@item Q: 
@emph{Why don't groups work in HPUX?}
@mbindex Groups in hpux

@item A:
HPUX uses the file @file{/etc/logingroup} not @file{/etc/group}. Make
a link if you need to:

@smallexample
links:

  hpux::

     /etc/logingroup -> /etc/group

@end smallexample

@item
To encourage some cross-fertilization, here's a sanitized sendmail
configuration script that I created for HPUX and HPUX10.
(From David Masterson, posted to gnu.cfengine.help). David's script
is nice since sendmail was the inspiration for cfengine's name.

@cindex Sendmail configuration
@mbindex How do I configure sendmail?

@smallexample
#!/usr/local/bin/cfengine -f
####################################################
#
# File:		sendmail.conf
#
# Description: 	CFEngine script to setup the sendmail.cf.
#
####################################################

control:

	access = ( root )

#	Postmaster
	sysadm = ( myPostmaster )

#	NIS domain and group server
	site = ( myserver )

#	DNS domain
	domain = ( myDNSdomain )

#	our gateway host
	gtwyhost = ( mygateway )

#	sendmail.cf can be big
	editfilesize = ( 1000000 )

	actionsequence =
		(
		copy
		files
		editfiles
		shellcommands
		)

#	disable unwanted classes with "--undefine" option
	addclasses = ( maildom mailhst )

################
#	bindir - location of sendmail
#	libdir - location of current mail files
#	cfgdir - location of initial mail files
#	etcdir - location of hosts.smtp
#	own    - who should own result files
#	grp    - what group should result files be in
################
    hpux::
	bindir = ( /usr/lib )
	libdir = ( /usr/lib )
	cfgdir = ( /etc/newconfig )
	etcdir = ( /etc )
	own = ( root )
	grp = ( sys )

    hpux10::
	bindir = ( /usr/sbin )
	libdir = ( /etc/mail )
	cfgdir = ( /usr/newconfig/etc/mail )
	etcdir = ( /etc )
	own = ( root )
	grp = ( sys )

#	disable with "--no-copy" option
copy:

	$(cfgdir)/sendmail.cf dest=$(libdir)/sendmail.cf type=checksum
		mode=0644 owner=$(own) group=$(grp) force=true

#	checks for other important files
files:

	$(libdir)/aliases mode=444 owner=$(own) group=$(grp) action=touch
	$(libdir)/rev-aliases mode=444 owner=$(own) group=$(grp) action=touch
	$(etcdir)/hosts.smtp mode=444 owner=$(own) group=$(grp) action=touch

#	disable with "--no-edit" option
editfiles:

    any::

#	setup general part of sendmail.cf
	@{ $(libdir)/sendmail.cf

	SetCommentStart '#'
	SetCommentEnd ''
	ResetSearch "1"
	UnCommentLinesMatching "#OP.*"	# activate Postmaster
	ResetSearch "1"
	UnCommentLinesMatching "#DY.*"
	ResetSearch "1"
	LocateLineMatching "DY.*"
	ReplaceLineWith "DY$(site).$(domain)"	# set site hiding
	ResetSearch "1"
	UnCommentLinesMatching "#DS.*"
	ResetSearch "1"
	LocateLineMatching "DS.*"
	ReplaceLineWith "DS$(gtwyhost)"	# all-knowing SMTP host
	# Ruleset 0 setups
	ResetSearch "1"
	UnCommentLinesMatching "#R.*user@@domain to SMTP relay.*"
	ResetSearch "1"
	LocateLineMatching "# try to connect to any host for user@@domain"
	IncrementPointer "1"
	CommentNLines "1"
	@}

#	add Postmaster alias
	@{ $(libdir)/aliases

	SetLine "Postmaster: $(sysadm)"
	AppendIfNoLineMatching "Postmaster.*"
	@}

#	setup processing of local domain hosts
    maildom::

	@{ $(libdir)/sendmail.cf

	SetCommentStart '#'
	SetCommentEnd ''
	ResetSearch "1"
	LocateLineMatching "DL.*"
	ReplaceLineWith "DL$(domain)"
	# Ruleset 0 setups
	ResetSearch "1"
	LocateLineMatching "# connect to hosts in local domain"
	IncrementPointer "1"
	UnCommentNLines "1"
	@}

#	setup processing via class S
    mailhst::

	@{ $(libdir)/sendmail.cf

	SetCommentStart '#'
	SetCommentEnd ''
	ResetSearch "1"
	UnCommentLinesMatching "#FS.*"
	# Ruleset 0 setups
	ResetSearch "1"
	LocateLineMatching "# connect to hosts in class S"
	IncrementPointer "1"
	UnCommentNLines "1"
	@}

#	setup of list of hosts for class S
	@{ $(etcdir)/hosts.smtp

	EmptyEntireFilePlease
	Append "localhost1"
	Append "localhost2"
	@}

#	disable with "--no-commands" option
shellcommands:

	"$(bindir)/sendmail -bk"
	"$(bindir)/sendmail -bi"
	"$(bindir)/sendmail -bz"
	"$(bindir)/sendmail -bd"

################
# End of File
################
@end smallexample

@end table

@c .....................................................
@c SUBSECTION
@c .....................................................

@node IRIX, LINUX, HPUX, FAQS and Tips
@subsection IRIX

@table @emph

@item Q:
@emph{Hints about IRIX?}

@item A:
Send them to @code{bug-cfengine@@prep.ai.mit.edu}.

@end table

@c .....................................................
@c SUBSECTION
@c .....................................................

@node LINUX, OSF, IRIX, FAQS and Tips
@subsection LINUX

@table @emph


@item Q:
When I try to compile @code{cfd} I get this error
@smallexample
 /usr/lib/libwrap.a(options.o): In function `twist_option':
 options.o(.text+0x5f7): undefined reference to `deny_severity'
 /usr/lib/libwrap.a(options.o): In function `severity_option':
 options.o(.text+0x808): undefined reference to `deny_severity'
 options.o(.text+0x81c): undefined reference to `deny_severity'
 options.o(.text+0x821): undefined reference to `deny_severity'
 options.o(.text+0x826): undefined reference to `deny_severity'
 options.o(.text+0x82b): undefined reference to `allow_severity'
 make[1]: *** [cfd] Error 1

@end smallexample

@item A:
There seems to be a problem with the distributed version of
the TCP wrappers library. Edit the @file{src/conf.h} file
and comment out the @samp{#define HAVE_LIBWRAP 1} line.
This means that you will not be able to use TCP wrappers
security however. You might prefer to collect and compile
a new version of TCP wrappers.
@mbindex libwrap problem under compilation
@mbindex cfd fails to compile

@item Q:
I keep getting segmentation fault from my cfengine scripts when I install
a completely new machine.
@mbindex Segmentation fault in files and dirs
@cindex Segmentation fault in files and dirs
@mbindex Linux segmentation fault with groups
@mbindex @file{/etc/groups} in linux

@item A:
There is a bug (apparently in Linux) which means that undefined groups
cause a segmentation fault. If a group is not in @file{/etc/group} or
in the NIS database, you should only get an error message, but linux
generates a core dump. I don't know of any fix except to edit group file
manually before running cfengine, or place a fix in editfiles and have this
run before files, directories etc, which make reference to the group.

@item Q:
@emph{Linux insists on rebuilding the message of the day file
each time it boots, but that means I keep losing the
messages I leave there.}
@mbindex Message of the day in linux
@mbindex motd in linux

@item A:
Add the following to your configuration files to comment out the
offending lines in the startup scripts:

@smallexample
editfiles:

   linux::

    @{ /etc/rc.d/rc.S
 
    HashCommentLinesContaining "motd"
    @}

@end smallexample

@end table

@c .....................................................
@c SUBSECTION
@c .....................................................

@node OSF, SUN (4.1.*), LINUX, FAQS and Tips
@subsection OSF

@table @emph

@item Q:
Hints about OSF/1?

@item A:
Send them to @code{bug-cfengine@@prep.ai.mit.edu}.

@end table


@c .....................................................
@c SUBSECTION
@c .....................................................

@node SUN (4.1.*), SOLARIS 2, OSF, FAQS and Tips
@subsection SUNOS (4.1.*)

@table @emph

@item Q: 
@emph{How can I delete the @samp{+} sign from the @file{/etc/hosts.equiv}
file to improve security?}
@cindex @samp{+} symbol in @file{/etc/hosts.equiv}
@cindex Security with NIS
@cindex @file{hosts.equiv}

@item A: 
Use editfiles to delete it:

@smallexample
editfiles:

   sun4::

      @{ /etc/hosts.equiv

      DeleteLinesMatching "+"
      @}

@end smallexample

@end table

@c .....................................................
@c SUBSECTION
@c .....................................................

@node SOLARIS 2, FreeBSD, SUN (4.1.*), FAQS and Tips
@subsection SOLARIS 2

@table @emph

@item Q: 
@emph{I keep getting a `bad address' error when cfengine tries
to reset the netmask and broadcast address.}
@cindex Bad address error in solaris
@cindex Netmask with solaris 2.4
@cindex Broadcast with solaris 2.4
@mbindex Bad address error in solaris

@item A: 
This is a bug in the sockets library on solaris. It is
supposed to be fixed in solaris 2.5.

@end table

@c *********

@table @emph

@item Q: 
@emph{How can I add my own file `rc.local' to the startup bootfiles automatically?}
@cindex @file{rc.local} in solaris
@cindex Local startup file for solaris
@mbindex rc.local in solaris

@item A: 
For example, create a file called @file{/local/etc/rc.local} which
looks something like this:

@smallexample
#
# rc.local 
#
PATH=/local/gnu/bin:/bin:/usr/bin:/usr/sbin; export PATH

#!/bin/sh

if [ "`hostname`" = "net-server" ]; then

   echo Starting WWW server
   /local/httpd_1.4/httpd -d /local/httpd_1.4

   echo Starting GNU finger server
   /local/etc/fingerd

fi

echo Starting ypbind
/usr/lib/netsvc/yp/ypbind

echo Adding a default route and flushing table

route -f add default my-gateway 1

echo Starting xdm

/local/bin/start-xdm

@end smallexample

@noindent
Now add an entry to your @file{cfengine.conf} file like this

@smallexample

   solaris::
 
      @{ /etc/rc3.d/S99rc-local
 
      AutoCreate
      AppendIfNoSuchLine "exec sh /local/etc/rc.local"
      @}

@end smallexample
@noindent


@end table

@c ***************

@table @emph

@item Q: 
@emph{The solaris installation program creates @file{/tmp} without
the sticky bit set, so that any user can delete any files in @file{/tmp}.
It also means that a race condition can occur in the kernel which
can give away root access to any user!}
@cindex @file{/tmp} under solaris
@cindex Security under solaris
@cindex Solaris, security
@cindex Solaris, @file{/tmp}
@mbindex Fixing /tmp permissions in solaris
@mbindex Solaris /tmp sticky bit
@mbindex Sticky bit in solaris /tmp

@item A: 

Add the following line to the configuration immediately!

@smallexample

files:

   /tmp mode=1777 action=fixdirs

@end smallexample

@item Q:
@emph{The ftp program will not allow me to log in to my own account!}
@cindex ftp login problems
@cindex @file{/etc/shells}
@cindex ftp and alternative shells
@mbindex ftp, can't log in

@item A:
The problem is that your shell is not in the system file @file{/etc/shells}.
Add a line something like this:

@smallexample

editfiles:

   @{ /etc/shells

   AppendIfNoSuchLine "/local/bin/tcsh"
   @}

@end smallexample

@item Q:
@emph{@code{tcsh} prints an error message on startup and will not read my
@file{.cshrc} file.}
@cindex tcsh and solaris
@cindex Solaris and tcsh
@mbindex tcsh and solaris error

@item A:
The problem is the central login file distributed with solaris. @file{tcsh}
can't understand it. Add a line

@smallexample

disable:

    /etc/.login type=file

@end smallexample

@noindent
You might want to replace this with a link to your own file.

@item Q:
@emph{Why does solaris fill up the routing table with hundreds of addresses
under the loop-back interface? (see netstat -r)}
@cindex routed
@cindex Solaris routing bug
@cindex @file{/etc/defaultroute}
@cindex @file{defaultroute}
@mbindex Routing problem in solaris

@item A:
First of all, get the latest patches for solaris, there are bugs in
the kernel of solaris 2.4 which makes this worse. Second, make
sure you have a file @file{/etc/defaultrouter} with the IP
address of your local gateway, if you don't intend to run your
system as a router. For instance:

@smallexample
files:

  solaris::

     /etc/defaultrouter o=root g=other m=644 act=touch

editfiles:

   solaris::

      @{ /etc/defaultrouter

      AppendIfNoSuchLine "xxx.xxx.xxx.1"
      @}

@end smallexample


@noindent
where @code{xxx.xxx.xxx.1} is the IP address of your gateway.

@item Q:
When trying to boot the system, solaris fails with the
error message: @emph{fork: rescource temporarily unavailable/vfork failed}.
The system then claims that there is something wrong with one of
the file systems.
@cindex Fork error in solaris
@mbindex Fork: resource unavailable in solaris
@mbindex Mount filesystems fails in solaris
@mbindex @file{/etc/system} missing in solaris.

@item A:
The file @file{/etc/system} has probably been corrupted. If this
file does not exist, solaris establish the kernel properly
and will not fork any processes. Things usually die early
on in the boot process. This causes the side effect that the
first fork the system needs to perform (to check the disk file
systems) fails and misinterprets the reason for failure of the
command. This makes it look as though something is wrong with
the disks. Add a line:

@smallexample

files:

   /etc/system o=root g=root m=0644 action=touch

@end smallexample

@item Q:

I am currently involved with setting up machines with jumpstart.
Jumpstart as you may know allows handsfree installation of solaris.  One
of the things it allows you to do is specify a "finish" script.  I am
running cfengine from this script to do the bulk of the configuration.
During jumpstart, the root of the machine you are installing is actually
under "/a".  This leads to problems with cfengine with LOCKFILEDIR and
LOGFILEDIR at the very least. It would cause problems with all
assumptions cfengine makes about system files too.  What would be
execeedingly nice would be a command line option to redefine where root
is assumed to be.  I realize this would be pretty hairy with respect to
mounting through cfengine, but it would be very useful.  For file
editing and such a root prefix macro woudlprobably work ok.  Let me know
what you think.


@item A:

Define the filenames

@smallexample
 $(root)/filename
@end smallexample 

@noindent
and set @code{$(root)} to @code{""} or @code{"/a"} depending on context?
That way you could the above without screwing up other things which
might be needed. You can switch off the locks with @code{-K}. And you
could override the @file{vfstab} location for solaris in the resource file.


@end table

@c .....................................................
@c SUBSECTION
@c .....................................................

@node FreeBSD,  , SOLARIS 2, FAQS and Tips
@subsection FreeBSD

@table @emph

@item Q:
@emph{How can I stop my FreeBSD system from running the @file{/etc/daily} script
which mails me every single day, week and month?}
@mbindex Daily mail in FreeBSD
@mbindex FreeBSD daily mail

@item A:
Add an editfiles command

@smallexample


 freebsd::

   @{ /etc/crontab
 
   HashCommentLinesContaining "daily"
   HashCommentLinesContaining "weekly"
   HashCommentLinesContaining "monthly"
   @}
@end smallexample

@item Q:
Why don't filesystems get mounted in the freebsd version of cfengine?
@cindex FreeBSD mount problem
@mbindex FreeBSD mount doesn't work

@item A:
Cfengine fixes the @file{/etc/fstab} file, but has to choose between
one of two courses of action when mounting, owing to a bug in
the mount command on FreeBSD machines. Cfengine mounts filesystems
each time it runs. On all other supported systems this causes no
problems,: once a filesystem is mounted it will not be mounted again.
Under FreeBSD however, a filesystem gets mounted again each time
mount is run, leading to multiple mount information in the mount table.
This causes cfengine to warn the filesystem is mounted many times,
and could eventually result in a problem for the FreeBSD machine.
The policy is therefore to use mount options which do not cause this
behaviour, but an unfortunate side-effect is that newly defined
filesystems do not get mounted. You can override the mount options
if you want to force multiple mounting.

@end table


@c **********************************************************************
@c CHAPTER
@c **********************************************************************

@node Using the help scripts, Example configuration file, Problem solving, Top
@chapter Using the help scripts
@cindex Help scripts

The following Perl scripts are included as examples and helpful tools in
your system administration package.  If you do not have Perl, you should
get it --- it is a very useful language for system administration.

@menu
* cfwrap::                      a wrapper script
* cfmail::                      a simple mail agent
* noseyparker::                 software quotas
* backup ::                     
* cfbg::                        
@end menu

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node cfwrap, cfmail, Using the help scripts, Using the help scripts
@section cfwrap
@cindex cfwrap, wrapper script
@cindex Wrapper script

It is useful to run cfengine on a daily basis from a @code{cron}
script.
@cindex cron script to start cfengine
@cindex Starting cfengine, cron script
@cindex Running cfengine, cron script
Use a line like the following one to start cfengine each night.  (Note the
curiosities of older BSD cronfiles).
@smallexample
0 0 * * * /usr/local/lib/cfengine-3.0/bin/cfwrap cfdaily
@end smallexample 

@noindent
where @emph{cfdaily} is a script which looks something like

@smallexample
#!/bin/sh

CFINPUTS=/usr/lib/cfengine/inputs

/usr/local/bin/cfengine
@end smallexample 

@noindent
You will need to include full path names to the scripts in the cron file.
The syntax for using @code{cfwrap} is as follows.

@example
@cartouche
host% cfwrap mycommand

host% cfwrap cfengine

host% cfwrap script_which_sets_CFINPUTS_and_calls_cfengine
@end cartouche
@end example

When you run cfengine it normally only generates output if something is
wrong which needs your attention.  If you are running cfengine as a
@code{cron} job then the results of each job are normally mailed back to
you --- or to root.  But this causes problems in a networked
environment, since mail to root is usually redirected to some central
place which local system administrators cannot access.  Moreover, you
have no way of knowing which host sent the information.  The solution is
to use a script as a wrapper.  The script simply executes some command
and collects the output from that command into a file which then gets
mailed to some address.

@cindex -a option
@vindex -a option
The address to be mailed to is obtained directly from cfengine by
calling it with the @emph{-a} switch.  The name of the host running
cfengine is prepended to the file before it is sent making it easy to
see where each message originated.  This is also transferred to the
subject header of the mail message.  @code{cfwrap} calls @code{cfmail}
in order to mail the result of the command back to the system
administrator.




@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node cfmail, noseyparker, cfwrap, Using the help scripts
@section cfmail
@cindex Mail agent
@cindex Mail from scripts


Because there are no standard mail-agents except for @emph{sendmail},
the wrapper script @emph{cfwrap} calls its own simple mail agent
@emph{cfmail} to send the message.  Note that the @emph{flags} variable
in the script @emph{cfmail} arranges for the mail message to be sent
with a return address other than ``root''.  This means that if the
recipient of the mail should decide to hit `r' for `reply' to reply to
the message, you have a chance of getting to see the message before it
vanishes along with the rest of the mail to @emph{root} into the same
black hole that swallows up all those credit cards, house-keys and odd
socks that disappear on a daily basis.

You might have to tweak the scripts slightly to tailor them to your own needs.
They are used as follows:

@example
@cartouche
host% echo test ....  | cfmail -s "Test message" mark 
@end cartouche
@end example




@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node noseyparker, backup , cfmail, Using the help scripts
@section noseyparker and editquotas: software quotas
@cindex Software quotas
@cindex Quotas, soft

@emph{Noseyparker} is a script which must be run by @emph{root}.  It is used
to give a software warning about users who are hogging your disk.
It is run with the command:
@smallexample
noseyparker @var{homedir} $(sysadm) [nomail]
@end smallexample 

@noindent
The directory @emph{homedir} should be one of the directories in which
user's home directories reside.  This is searched for a list of
usernames.  @code{$(sysadm)} is the mail address of the system
administrator (which can be obtained from the cfengine variable of the
same name) and is used to send information about users who have exceeded
certain quotas.  The option @emph{nomail} prevents @emph{noseyparker}
from sending mail automatically to the users concerned.

Although many administrators use the quota checking facilities available
in UNIX, there are problems with these.  Many users need to generate
large temporary files (when generating postscript or TEX, or when
performing numerical calculations).  Using hard quotas prevents these
users from using their accounts effectively.  @emph{Noseyparker} takes
the view that most users will tidy up files if they receive a polite
reminder --- and the few who cannot be dealt with by other means.

@emph{Noseyparker} should be run once a week on each home directory on a
homeserver.  When you run @emph{noseyparker}, the program generates
statistics which it keeps from week to week in order to find out how
fast data are growing.  If the number of kilobytes for a given user
exceeds a limit, a warning is generated: either a @emph{pre-warning}, a
@emph{soft warning} or a @emph{hard warning.} If @emph{nomail} is set,
only the system administrator gets a list of these users.  If it is not
set, then each user gets an automatic message telling him or her to tidy
up.  The `degree' of the message depends on the extent of the crime.
Every user gets at least three `soft warnings' before putting in the
boot.  The system administrator can see from the mail report which type
of warning each user has received.

A default quota is defined in the variable @code{$softlimit}.  A
pre-margin determines how early a pre-warning will be sent.  Special
quotas for particular users are set using the @emph{editquotas} script

@smallexample
editquotas @var{homedir}
@end smallexample 

@noindent
For example, to change the quota of a user whose home directory is on
@file{/mysite/myhost/u2}, one writes:

@smallexample
editquotas /mysite/myhost/u2
@end smallexample
The file is edited so that it takes the form

@smallexample
@var{username} @var{quota}
@var{user2}    @var{quota2}
@end smallexample 

@noindent
You can modify @emph{noseyparker} to suit your own setup if necessary.

Here is a typical command to start @emph{noseyparker}:

@smallexample
shellcommands: 
 
   homeservers.Sunday::
   
      "$(cfbin)/noseyparker /home/$(host) $(sysadm) nomail"
 
   homeservers.cfengine_model.Sunday::

      "$(cfbin)/noseyparker /$(site)/$(host)/u1 $(sysadm) nomail"

@end smallexample 


@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node backup , cfbg, noseyparker, Using the help scripts
@section cfbackup and cfrestore scripts
@cindex Backing up filesystems
@cindex User backups
@cindex Automatic backup
@cindex Backup, automatic
@cindex cfbackup

Today, most people would agree that diskspace is cheap, whilst time
spent taking backups is expensive. The backup script included in the
@file{bin} directory solves this problem for us at Oslo College by
making automatic backups of users' directories using GNU-tar to
compressed tar files which are then placed in a spare partition of a
special disk.  The script is called up as follows:

@smallexample
shellcommands: 
 
  BackupHost.Sunday|BackupHost.Wednesday::
 
      #
      # Make a system backup of /iu/nexus/u? with Audun's script
      #
 
      "$(cfbin)/cfbackup -p -f /iu/dax/backup1 -s /iu/nexus/u1"
      "$(cfbin)/cfbackup -p -f /iu/dax/backup1 -s /iu/nexus/u2" 
      "$(cfbin)/cfbackup -p -f /iu/dax/backup2 -s /iu/nexus/u3"
      "$(cfbin)/cfbackup -p -f /iu/dax/backup2 -s /iu/nexus/u4" 
 
@end smallexample

The directories to be taken backup of are listed using the @code{-s} option.
The directory which the files get saved to is coded in the variable @code{$destination}
of the (Perl) backup script. @code{-f} tells the script where to leave the
tar-ed backup file: in this case the user partitions are spread between two
backup areas.
The @code{-p} option makes sure that each user
owns his/her own backup file. This means that each user can access their backup
files themselves using the @code{cfrestore} script (see below).

As the backup files build up on the backup disk, you can delete older files
using the tidy function:

@smallexample

tidy:
 
   BackupHost::
 
      # Here we tidy old backup tar files from the backup area
 
      /iu/dax/backup1      pat=*  age=15
      /iu/dax/backup2      pat=*  age=15

@end smallexample

@noindent 
This example would tidy all the old backupfiles after three
weeks.

Each user's directory (assumed to be a child of the directories named
using @code{-s}) is saved in a separate tar-file, labelled with the
date on which the backup was taken. They look like this:

@smallexample
backup.16.8.95.iu.nexus.u2.wiikl
backup.16.8.95.iu.nexus.u2.wullumt
backup.16.8.95.iu.nexus.u2.wux
backup.20.8.95.iu.nexus.u1.agneta
@end smallexample

@noindent 
A file can then be recovered by typing a command like
@smallexample

cfrestore myfile

@end smallexample

@cindex cfrestore
@cindex Automatic restoring of lost files
@cindex Retrieving backed-up files
@noindent
@code{cfrestore} will then search through the tar-file for files
matching the file you request and place them in a special directory
under your home directory, labelled by the name (and date) of the tar
file from which the file was extracted.  If you know which backup file
(the date) from which you want to restore a file, you can use the
@code{-f @var{backupfile}} option.

These scripts will at the very least require minor modifications for
a your local site configuration, but they can be used as a simple
and effective way of taking backups automatically.

NOTE: the scripts make convenient use of GNU tar and fileutils
packages.

@c -------------------------------------------------------------------------------
@c SECTION
@c -------------------------------------------------------------------------------

@node cfbg,  , backup , Using the help scripts
@section cfbg

Normally cfengine blocks in subprocesses. That means that when you
execute a shell command, cfengine waits for each command to exit before
continuing execution. This serializes the execution of shellcommands.
On occasions, you might wish to force a process to dissociate
from parent cfengine process and run in parallel. For example, you
might want the backup scripts (which can take quite a long time)
to not hold up cfengine. To do this, you can use a simple wrapper
script like @file{cfbg}. This command simply takes the remainder
of the command line (after cfbg) as a command to execute and
forks a new process for this command, without waiting. Cfengine is then
free to continue running. Here is an example

@smallexample
control:

  cfbin = ( /local/gnu/lib/cfengine/bin )

shellcommands:

  "$(cfbin)/cfbg $(cfbin)/cfbackup"

@end smallexample

The default script writes the output of the standard out and standard error
to a file in the @file{/tmp} directory. Alternatively you might wish to
send the output directly to @file{/dev/null}.

@c **********************************************************************
@c CHAPTER
@c **********************************************************************

@node Example configuration file, Runtime Options, Using the help scripts, Top
@chapter Example configuration files
@cindex Example configuration files

Here is a sample from a large configuration file, just to give you
some ideas. The file is broken up into manageable pieces for
convenience.

@menu
* cfengine.conf::               
* cf.groups::                   
* cf.main::                     
* cf.site::                     
* cf.motd::                     
* cf.users::                    
* cf.solaris::                  
* cf.linux::                    
* cf.freebsd::                  
* cfd.conf::                    
@end menu

@c .....................................................
@c SECTION
@c .....................................................

@node cfengine.conf, cf.groups, Example configuration file, Example configuration file
@section cfengine.conf
@cindex @file{cfengine.conf}

@smallexample
#####################################################################
# 
#  CFENGINE CONFIGURATION FOR site = iu.hioslo.no
#
#  This file is for root only.
#
######################################################################

###
#
# BEGIN cfengine.conf
#
###

import:

   #
   # Split things up to keep things tidy
   #

   any::            
                    cf.groups
                    cf.main
                    cf.site
                    cf.motd

   hpux::           cf.hpux
   linux::          cf.linux
   solaris::        cf.solaris
   sun4::           cf.sun4
   ultrix::         cf.ultrix
   freebsd::        cf.freebsd

   #
   # Do you want to do this ?
   #

   AllHomeServers:: cf.users


###
#
# END cfengine.conf
#
###
@end smallexample

@c .....................................................
@c SECTION
@c .....................................................

@node cf.groups, cf.main, cfengine.conf, Example configuration file
@section cf.groups
@cindex @file{cf.groups}

@smallexample
##############################################################
#
# cf.groups - for iu.hioslo.no
#
# This file contains  all group/class definitions
#
#################################################################

###
#
# BEGIN cf.groups
#
###

groups:

   #
   # Define some groups
   #
 
   iu = ( nexus ferengi regula borg dax lore axis worf daystrom voyager 
          aud1 aud2 aud3 aud4 bajor ds9 takpah takpeh nostromo galron
          thistledown rama chaos pc-steinarj pc-hildeh way jart kosh )

   diskless   = ( regula ferengi lore )

   standalone = ( nexus axis dax borg worf daystrom voyager 
                  aud1 aud2 aud3 aud4 bajor ds9 takpah takpeh
                  nostromo galron thistledown rama pc-torejo
                  pc-steinarj pc-hildeh )

   AllHomeServers   = ( nexus )
   AllBinaryServers = ( nexus borg )

   XBootServer  = ( nexus )
   WWWServers   = ( nexus )
   FTPserver    = ( nexus )
   NameServers  = ( nexus )
   PasswdServer = ( nexus )
   BackupHost   = ( nexus )

   MailHub      = ( nexus )
   MailClients  = ( iu -nexus )

###
#
# END cf.groups
#
###

@end smallexample

@c .....................................................
@c SECTION
@c .....................................................

@node cf.main, cf.site, cf.groups, Example configuration file
@section cf.main
@cindex @file{cf.main}

@smallexample
##############################################################
#
# cf.main - for iu.hioslo.no
#
# This file contains generic config stuff
#
#################################################################

###
#
# BEGIN cf.main
#
###

control: 

   access    = ( root )        # Only root should run this

   site      = ( iu )
   domain    = ( iu.hioslo.no )
   sysadm    = ( drift@@iu.hioslo.no ) 

   repository = ( /var/spool/cfengine )

   netmask   = ( 255.255.255.0 )
   timezone  = ( MET )
   nfstype   = ( nfs )

   sensiblesize  = ( 1000 )
   sensiblecount = ( 2 )
   editfilesize  = ( 20000 )

   mountpattern = ( /$(site)/$(host) )
   homepattern  = ( u? ) 

   #
   # If we undefine this with cfengine -N longjob
   # then we switch off all jobs labelled with this class
   #

   addclasses = ( longjob )

   #
   # Macros & constants are inherited downwards in imports
   # but are not passed up to parent files. Good idea to
   # define them all here
   #

   masterfiles = ( /iu/nexus/local/iu )
   main_server = ( nexus )
   cfbin       = ( /iu/nexus/local/gnu/lib/cfengine/bin )
   gnu         = ( /local/gnu )
   ftp         = ( /local/iu/ftp )
   nisslave    = ( dax )
   nisfiles    = ( /iu/nexus/local/iu/etc )

   #
   # The action sequence for daily (full) runs and
   # for hourly updates (called with -DHourly)
   #

   Hr00::

      actionsequence = 
         (
         copy
         mountall
         mountinfo
         checktimezone
         netconfig
         resolve
         unmount
         shellcommands
         addmounts
         links.Prepare
         files.Prepare
         directories
         links.Rest
         mailcheck
         mountall
         required
         tidy
         disable
         editfiles
         files.Rest
         processes
         )

   !Hr00::

      actionsequence =
         (
         resolve
         shellcommands
         copy
         editfiles
         processes
	 links
         )

   force::

      actionsequence = 
         (
         files.Prepare.Rest
         tidy
         )

######################################################################

homeservers:

   iu:: nexus

binservers:

   iu.solaris::                 nexus
   iu.linux::                   borg

mailserver:

   any:: nexus:/var/mail

mountables:

   any::
         nexus:/iu/nexus/u1
         nexus:/iu/nexus/u2
         nexus:/iu/nexus/u3
         nexus:/iu/nexus/u4
         nexus:/iu/nexus/u5
         nexus:/iu/nexus/u6
         nexus:/iu/nexus/ua
         nexus:/iu/nexus/ud
         nexus:/iu/nexus/local
         nexus:/opt/NeWSprint
         nexus:/opt/AcroRead
         borg:/iu/borg/local
         dax:/iu/dax/local

miscmounts:

   linux||freebsd::   nexus:/iu/nexus/local /iu/nexus/local ro

######################################################################

broadcast:

  ones

defaultroute:

   cadeler30-gw

######################################################################

resolve:

      128.39.89.10  # nexus
      158.36.85.10  # samson.hioslo.no
      129.241.1.99

######################################################################

tidy: 

   #
   # Some global tidy-ups
   #

      /tmp/                    pat=*             r=inf     A=1
      /var/tmp                 pat=*             r=inf     A=1
      /                        pat=core          r=1       A=0
      /etc                     pat=core          r=1       A=0

######################################################################

ignore:                       # Don't check or tidy these directories

      /local/lib/gnu/emacs/lock/
      /local/tmp
      ftp
      projects
      /local/bin/top
      /local/lib/tex/fonts
      /local/iu/etc
      /local/etc
      /local/iu/httpd/conf
      /usr/tmp/locktelelogic
      /usr/tmp/lockIDE
      RootMailLog

      #
      # Emacs lock files etc
      #

      !*
      /local/lib/xemacs

      #
      # X11 keeps X server data in /tmp/.X11
      # better not delete this!
      #

      .X11

      #
      # Some users like to give a file or two 777 protection here
      # so netsurfers can update a log or counter when running as
      # `nobody'
      #

      www

#####################################################################

disable:

   /etc/hosts.equiv
   /etc/nologin
   /usr/lib/sendmail.fc


###
#
# END cf.main
#
###

@end smallexample

@c .....................................................
@c SECTION
@c .....................................................

@node cf.site, cf.motd, cf.main, Example configuration file
@section cf.site
@cindex @file{cf.site}

@smallexample
##############################################################
#
# cf.site - for iu.hioslo.no
#
# This file contains site specific data
#
#################################################################

###
#
# BEGIN cf.site
#
###

links:

   Prepare::

      /local     -> /$(site)/$(binserver)/local
      /usr/local -> /local

   dax::

      /iu/dax/local             +> /iu/nexus/local
      /projects                 -> /iu/dax/local/projects
      /iu/nexus/u1/sowille/data -> /iu/dax/scratch/data
 
   XBootServer::

      #
      # Set up a /local/tftpboot area where all X terminal
      # stuff will be kept.
      #

      /tftpboot                  -> /local/tftpboot
      /local/tftpboot/td/configs -> /local/tftpboot/td/examples/configs
      /etc/bootptab              -> /tftpboot/bootptab
      /tftpboot/usr/lib/X11/td   -> /tftpboot/td

   NameServers::

      /etc/named.boot -> /local/iu/named/named.boot

   MailHub::

      /etc/mail/sendmail.cf ->! /iu/nexus/local/mail/sendmail.cf

   MailClients.solaris::

      /etc/mail/sendmail.cf ->! /iu/nexus/local/mail/client.cf

   nexus::

	/local/bin +> /local/latex/bin
 
#############################################################

disable:

  #
  # We run Berkeley sendmail and the config files are
  # all under /iu/nexus/local/lib/mail
  #

    /etc/aliases

 WWWServers.Sunday::

   #
   # Disabling these log files weekly prevents them from
   # growing so enormous that they fill the disk!
   #

   /local/iu/httpd/logs/access_log   rotate=empty
   /local/iu/httpd/logs/agent_log    rotate=empty
   /local/iu/httpd/logs/error_log    rotate=empty
   /local/iu/httpd/logs/referer_log  rotate=empty

   #
   # CERT warning, security fix
   #

  any::

    /usr/lib/expreserve

  FTPserver.Sunday.Hr00::

   /local/iu/xferlog rotate=3

#################################################################

files:

  Prepare::

      /etc/motd              m=0644 r=0 o=root act=touch
      /.cshrc                m=0644 r=0 o=root act=touch

   PasswdServer::

      /local/iu/etc/passwd m=0644 o=root g=other action=fixplain
      /local/iu/etc/shadow m=0644 o=root g=other action=fixplain

   WWWServers.Rest::

      /local/iu/www                           m=775        g=www act=fixall r=inf
      /local/iu/httpd/conf                    m=664 o=root g=www act=fixall r=inf
      /local/iu/www/cgi-bin-public/count_file m=777 o=root g=www act=fixplain

   FTPserver::

      #
      # Make sure anonymous ftp areas have the correct
      # protection, or logins won't be able to read
      # files - or perhaps a security risk. This is
      # solaris 2 specific...
      #

      $(ftp)/pub        mode=755 o=ftp  g=ftp  r=inf act=fixall
      $(ftp)/Obin       mode=111 o=root g=other      act=fixall
      $(ftp)/etc        mode=111 o=root g=other      act=fixdirs
      $(ftp)/usr/bin/ls mode=111 o=root g=other      act=fixall
      $(ftp)/dev        mode=555 o=root g=other      act=fixall
      $(ftp)/usr        mode=555 o=root g=other      act=fixdirs

   Prepare::

      /etc/shells mode=0644 action=touch

   AllBinaryServers.Rest.longjob::

     /local mode=-0002 r=inf owner=root,bin group=0,1,2,3,4,5,6,7,staff
            links=tidy action=fixall

     /local/iu/RootMailLog  m=0666 action=touch

   dax.Rest::

    /iu/dax/scratch        r=0 o=root mode=1777 action=fixall
    /iu/dax/local/projects r=0 o=root mode=755  action=fixdirs

   nexus::

    /local/mail/sendmail.cf o=root m=444 act=fixplain

    /iu/nexus/ua/robot/.rhosts o=robot m=600 act=touch
 
    /local/iu/named/pz         o=root  m=644 act=fixall r=1

    /local/latex/lib/tex/texmf/fonts  owner=root
                                      mode=1666
                                      recurse=inf
                                      action=fixall

#################################################################

tidy:

      #
      # Make sure the file repository doesn't fill up
      #

      /var/spool/cfengine pattern=*    age=3

      /var                pattern=core age=0  r=inf
      /var/spool/mqueue   pattern=*    age=14 type=mtime

   BackupHost::

      # Here we tidy old backup tar files from the backup area
      # A special tmp area gets cleared every 4 days. The files
      # are created by Audun's backup help script (see shellcommands)

      /iu/nexus/backup1      pat=*  age=7

#################################################################

shellcommands: 

   PasswdServer::

      # Build and install the BSD compatible passwd file
      # from the master passwd/shadow file on solaris

      "/local/iu/bin/BuildPasswdFiles"
      "/local/iu/bin/BuildGroupFiles"

  BackupHost.Sunday.Hr00|BackupHost.Wednesday.Hr00::

      #
      # Make a system backup of /iu/nexus/u? with Audun's script
      #

      "$(cfbin)/cfbackup -p -f /iu/nexus/backup1 -s /iu/nexus/ud"
      "$(cfbin)/cfbackup -p -f /iu/nexus/backup1 -s /iu/nexus/ua"
      "$(cfbin)/cfbackup -p -f /iu/nexus/backup1 -s /iu/nexus/u1"
      "$(cfbin)/cfbackup -p -f /iu/nexus/backup1 -s /iu/nexus/u2" 
      "$(cfbin)/cfbackup -p -f /iu/nexus/backup2 -s /iu/nexus/u3"
      "$(cfbin)/cfbackup -p -f /iu/nexus/backup2 -s /iu/nexus/u4" 
      "$(cfbin)/cfbackup -p -f /iu/nexus/backup2 -s /iu/nexus/u5" 
      "$(cfbin)/cfbackup -p -f /iu/nexus/backup2 -s /iu/nexus/u6" 

  nexus.Sunday.longjob.Hr00::

      #
      # See how much rubbish users have accumulated each Sunday
      #

      "$(cfbin)/noseyparker /iu/nexus/u1 $(sysadm) "
      "$(cfbin)/noseyparker /iu/nexus/u2 $(sysadm) " 
      "$(cfbin)/noseyparker /iu/nexus/u3 $(sysadm) " 
      "$(cfbin)/noseyparker /iu/nexus/u4 $(sysadm) " 
      "$(cfbin)/noseyparker /iu/nexus/u5 $(sysadm) " 
      "$(cfbin)/noseyparker /iu/nexus/u6 $(sysadm) " 
      "$(cfbin)/noseyparker /iu/nexus/ua $(sysadm) nomail" 
      "$(cfbin)/noseyparker /iu/nexus/ud $(sysadm) nomail" 

   nexus.longjob.Hr00::

      #
      # Update the GNU find/locate database each night
      #
 
      "$(gnu)/lib/locate/updatedb"
      "/local/iu/bin/newhomepage.sh"

###############################################################

editfiles:

    #
    # cfengine installs itself as a cron job - sneaky! :)
    #

    @{ /var/spool/cron/crontabs/root

    AppendIfNoSuchLine "0 * * * * $(cfbin)/cfwrap $(cfbin)/cfhourly"
    @}

   FTPserver::

      @{ /etc/shells

      AppendIfNoSuchLine "/bin/tcsh"
      AppendIfNoSuchLine "/local/gnu/bin/bash"
      @}


   XBootServer::

      @{ /etc/inetd.conf

      AppendIfNoSuchLine 
          "bootp dgram udp wait root /local/bin/bootpd bootpd -i -d"
      @}

   nexus::

      @{ /iu/nexus/ua/robot/.rhosts

      AppendIfNoSuchLine "borg"
      AppendIfNoSuchLine "borg.iu.hioslo.no"
      AppendIfNoSuchLine "aud4"
      AppendIfNoSuchLine "aud4.iu.hioslo.no"
      @}

   dax::

      @{ /etc/system

      AppendIfNoSuchLine "set pt_cnt=128"
      @}


######################################################################

required:

   #
   # Any host must have a /local, /usr/local fs. Check that
   # it exists and looks sensible. (i.e. not empty)
   #

   /$(site)/$(binserver)/local


######################################################################

copy:

   #
   # NIS seems broken at IU, so here we use NFS to fudge
   # a file distribution as a temporary solution. Actually
   # this makes the system work faster without NIS!
   #

      $(nisfiles)/services dest=/etc/services o=root g=other mode=0644
      $(nisfiles)/hosts.deny dest=/etc/hosts.deny o=root mode=0644

   !debian::

      $(nisfiles)/hosts    dest=/etc/hosts o=root g=other mode=0644

   PasswdServer::

      /etc/passwd dest=$(nisfiles)/passwd o=root g=other mode=0644
      /etc/shadow dest=$(nisfiles)/shadow o=root g=other mode=0644

   nexus::

      /local/iu/etc/dfstab dest=/etc/dfs/dfstab  o=root  mode=0744

   solaris.!PasswdServer::

      $(nisfiles)/passwd dest=/etc/passwd o=root g=other mode=0644
      $(nisfiles)/shadow dest=/etc/shadow o=root g=other mode=0600
      $(nisfiles)/group.solaris dest=/etc/group o=root g=other mode=0644

   linux::

      $(nisfiles)/passwd.linux dest=/etc/passwd o=root g=other mode=0644
      $(nisfiles)/group.linux dest=/etc/group o=root g=other mode=0644

###############################################################

processes:

      "eggdrop"                           signal=kill
      "irc"                               signal=kill
      "ping"                              signal=kill
      "NetXRay"                           signal=kill
      "netxray"                           signal=kill
      "ypserv"                            signal=kill
      "ypbind"                            signal=kill
      "rarpd"                             signal=kill
      "rpc.boot"                          signal=kill
      "README"                            signal=kill # You don't sh README !

   !XBootServer::

      "bootp"                             signal=kill

   #
   # These processes are not killed every hour, but once a day
   # when cfengine runs at night. Note that there are often
   # hanging pine and elm processes. These programs crash and
   # go berserk, using hundreds of hours of CPU time.
   #

   Hr00::

      "cron"                 signal=hup  # HUP these to update their config
      "inetd"                signal=hup

      "/local/sdt/sdt/bin"   signal=term # For those elektro dudes who forget
                                         # to log out
      "netscape"             signal=kill
      "pine"                 signal=kill
      "elm"                  signal=kill


###
#
# END cf.site
#
###

@end smallexample

@c .....................................................
@c SECTION
@c .....................................................

@node cf.motd, cf.users, cf.site, Example configuration file
@section cf.motd
@cindex @file{cf.motd}

@smallexample

##################################################################
#
# cf.motd
#
# This file is used to set the message of the day file on
# each host
#
##################################################################
 
 #####
 #
 # BEGIN cf.motd
 #
 #####


control:

   #
   # This points to the file containing general text
   #

   masterfile      = ( /iu/nexus/local/iu/etc/motd-master )
   local_message   = ( /etc/motd.local )

editfiles:

      @{ /etc/motd

      BeginGroupIfFileIsNewer "$(masterfile)"
        EmptyEntireFilePlease
        InsertFile "$(masterfile)"
        InsertFile "$(local_message)"
        PrependIfNoSuchLine "This system is running $(class):$(arch)"
      EndGroup
      @}

 #####
 #
 # BEGIN cf.motd
 #
 #####

@end smallexample


@c .....................................................
@c SECTION
@c .....................................................

@node cf.users, cf.solaris, cf.motd, Example configuration file
@section cf.users

Whether or not you perform any special services for users, with or
without their consent is entirely a matter of local policy. In a school
or college situation, users are often uncooperative and some are even
irresponsible.  This file shows you what you could do in an environment
with inexperienced users, but please don't feel as though you have to be
this totalitarian.

@smallexample
#################################################################
#
# cf.users - for iu.hioslo.no
#
# This file contains user specific actions
#
#################################################################

###
#
# BEGIN cf.users
#
###

ignore:

    robot

tidy:

   longjob::

     #
     # Some users just don't understand what they are doing
     # and this is safest, allbeit totalitarian
     #

     home                 pat=.rhosts                      age=0

     #
     # Tidy up users' home dirs
     #

     home                 pat=core             r=inf       age=0
     home                 pat=a.out            r=inf       age=1
     home                 p=*%                 r=inf       age=2
     home                 p=*~                 r=inf       age=2
     home                 p=#*                 r=inf       age=1    
     home                 p=*.dvi              r=inf       age=14   type=ctime
     home                 p=*.log              r=inf       age=2
     home                 p=Log.*              r=inf       age=3
     home                 p=CKP                r=inf       age=1
     home                 p=BAK                r=inf       age=1
     home                 p=log                r=inf       age=0
     home                 p=*.o                r=inf       age=0
     home                 p=*.aux              r=inf       age=3
     home                 p=*.zip              r=inf       age=7
     home/.deleted        p=*                  r=inf       age=0
     home/.wastebacket    p=*                  r=inf       age=14
     home/www             p=*~                 r=inf       age=1

     #
     # Clear the big cache files netscape creates
     #

     home/.netscape-cache  p=cache????*         r=inf       age=0
     home/.MCOM-cache      p=cache????*         r=inf       age=0
     home/.netscape/cache  p=*                  r=inf       age=0


#################################################################

files:

   AllHomeServers.longjob.rest::

     #
     # Check users files are not writable to the world
     # and there are no stale links (pointing nowhere)
     #

     home mode=o-w recurse=inf action=fixall # links=tidy

     home/.xsession mode=755 action=fixall
     home/.cshrc    mode=755 action=fixall

#################################################################

copy:

   Hr00.longjob::

   #
   # Make sure each user has an up to date standard
   # setup.  Cshrc just sources in a big standard file
   # which is kept in ~user/../.setupfiles/cshrc
   # to reduce disk wastage
   #

   $(masterfiles)/lib/Cshrc   dest=home/.cshrc
   $(masterfiles)/lib/tkgrc   dest=home/.tkgrc
   $(masterfiles)/lib/fvwm2rc dest=home/.fvwm2rc


###
#
# END cf.users
#
###
@end smallexample


@c .....................................................
@c SECTION
@c .....................................................


@node cf.solaris, cf.linux, cf.users, Example configuration file
@section cf.solaris

@smallexample
#################################################################
#
# cf.solaris - for iu.hioslo.no
#
# This file contains solaris specific patches
#
#################################################################

###
#
# BEGIN cf.solaris
#
###

directories:

     #
     # httpd/netscape want this to exist for some bizarre reason
     #

      /usr/lib/X11/nls

################################################################

tidy:

     /var/log  pattern=syslog.* age=0

   MailHub::

     /var/mail pattern=lp       age=0

#################################################################

files:

  #
  # If this doesn't exist fork will not work and the
  # system will not even be able to run the /etc/rc
  # scripts at boottime
  #

  /etc/system     o=root g=root m=644 action=touch

  /var/log/syslog o=root        m=666 action=touch

#############################################################

copy:

   #
   # Some standard setup files, can't link because
   # machine won't boot if their not on / partition.
   #

   /local/bin/tcsh dest=/bin/tcsh mode=755

   /local/iu/etc/nsswitch.standalone dest=/etc/nsswitch.conf

  #
  # Our named server uses a newer BIND
  # Put this here so that it will be preserved under
  # solaris reinstallation
  #

  NameServers::

   /local/iu/sbin/in.named         dest=/usr/sbin/in.named         mode=555
   /local/iu/sbin/in.named.reload  dest=/usr/sbin/in.named.reload  mode=555
   /local/iu/sbin/in.named.restart dest=/usr/sbin/in.named.restart mode=555
   /local/iu/sbin/in.ndc           dest=/usr/sbin/in.ndc           mode=555
   /local/iu/sbin/named-xfer       dest=/usr/sbin/named-xfer       mode=555
   /local/iu/lib/nslookup.help     dest=/usr/lib/nslookup.help     mode=444

  any::
   /local/iu/lib/libresolv.a        dest=/usr/lib/libresolv.a      mode=444
   /local/iu/lib/libresolv.so.2     dest=/usr/lib/libresolv.so.2   mode=444
   /local/bin/nslookup              dest=/usr/sbin/nslookup        mode=444

##############################################################

editfiles:

      @{ /etc/netmasks

      AppendIfNoSuchLine "128.39  255.255.255.0"
      @}

      @{ /etc/defaultrouter

      AppendIfNoSuchLine "128.39.89.1"
      @}

      @{ /usr/openwin/lib/app-defaults/XConsole

      AppendIfNoSuchLine "XConsole.autoRaise: on"
      @}

   #
   # CERT security patch for vold vulnerability
   #

   @{ /etc/rmmount.conf

   HashCommentLinesContaining "action cdrom"
   HashCommentLinesContaining "action floppy"
   @}

##############################################################

disable:

    /etc/.login  type=file
    /etc/aliases 

   #
   # These files are ENORMOUS, don't let them fill the disk
   #

   Wednesday::

      /var/lp/logs/lpsched rotate=empty

      /var/adm/wtmpx       rotate=empty
      /var/adm/wtmp        rotate=empty

##############################################################

files:

    /etc/passwd        m=0644 o=root g=other action=fixplain
    /etc/shadow        m=0600 o=root g=other action=fixplain
    /etc/defaultrouter m=0644 o=root g=other action=touch
    /var/adm/wtmpx     m=0664 o=adm  g=adm   action=touch
    /var/adm/wtmp      m=0644 o=root g=adm   action=touch
    /var/adm/utmp      m=0644 o=root g=adm   action=fixplain
    /var/adm/utmpx     m=0664 o=adm  g=adm   action=fixplain

    /tmp m=1777                              action=fixdirs

##############################################################

disable:

   #
   # CERT security patch
   #

   /usr/openwin/bin/kcms_calibrate
   /usr/openwin/bin/kcms_configure
   /usr/bin/admintool

################################################################

shellcommands:

   AllBinaryServers.Saturday.longjob.Hr00::

      #
      # Make sure the man -k / apropos data are up to date
      #

      "/usr/bin/catman  -M /local/man"
      "/usr/bin/catman  -M /local/X11R5/man"
      "/usr/bin/catman  -M /usr/man"
      "/usr/bin/catman  -M /local/gnu/man"
      "/usr/bin/catman  -M /usr/openwin/share/man"
      "/usr/bin/catman  -M /local/X11R5/man"
      "/usr/bin/catman  -M /usr/share/man"

################################################################

editfiles:


      #
      # A painless way to add an rc.local script to the rc files
      # under solaris without having to fight though inittab
      #

      @{ /etc/rc3.d/S15nfs.server

      AppendIfNoSuchLine "sh /local/iu/etc/rc.local"
      @}

      #
      # umask defined when inetd starts is inherited by all subprocesses
      # including ftpd which saves with mode 666 (!) unless we do this
      #

      @{ /etc/rc2.d/S72inetsvc

      PrependIfNoSuchLine "umask 022"
      @}


###
#
# END cf.solaris
#
###

@end smallexample


@c .....................................................
@c SECTION
@c .....................................................

@node cf.linux, cf.freebsd, cf.solaris, Example configuration file
@section cf.linux

@smallexample
#################################################################
#
# cf.linux - for iu.hioslo.no
#
# This file contains debian linux specific patches
#
#################################################################

###
#
# BEGIN cf.linux
#
###

files:

      /etc/printcap m=644 o=root action=fixplain

     #
     # Cert advisories
     #

      /bin/mount         m=755 o=root action=fixall
      /bin/umount        m=755 o=root action=fixall

#######################################################################

  disable:

     #
     # Cert advisories
     #

      /sbin/dip-3.3.7n

########################################################################

links:

    /local/bin/tcsh   ->  /bin/tcsh

    /local/lib/mail   ->  /$(site)/$(main_server)/local/lib/mail

########################################################################

editfiles:

  #
  # Samba default mode needs to be set...
  #

   @{ /etc/smb.conf

   ReplaceAll "700" With "644"
   @}

  #
  # Linux date is very stupid and needs a very careful
  # TZ definition, otherwise it loses
  #

   @{ /etc/csh.cshrc

   AppendIfNoSuchLine "setenv TZ 'MET-1MET DST-2,M3.5.0/2,M10.5.0/3'"
   @}

  #
  # resolv+ ordering
  #

   @{ /etc/host.conf

   PrependIfNoSuchLine "order bind"
   @}


  #
  # Should have been configured already (!)
  #

   @{ /etc/ld.so.conf

   AppendIfNoSuchLine "/usr/X11R6/lib"
   @}

  #
  # Kill annoying messages
  #

   @{ /etc/cron.daily/standard

   HashCommentLinesContaining "security"
   @}

#########################################################################

shellcommands:

  Hr00::

     #
     # Find/locate database
     #

     "/usr/bin/updatedb"

###
#
# END cf.linux
#
###


@end smallexample


@c .....................................................
@c SECTION
@c .....................................................

@node cf.freebsd, cfd.conf, cf.linux, Example configuration file
@section cf.freebsd / cf.netbsd

FreeBSD and NetBSD are sufficiently similar to have a single
file for both.

@smallexample
#################################################################
#
# cf.bsd - for iu.hioslo.no
#
# This file contains bsd specific patches
#
#################################################################

###
#
# BEGIN cf.bsd
#
###

links:

    /usr/spool        ->  /var/spool
    /local/bin/tcsh   ->  /bin/tcsh
    /local/bin/perl   ->  /usr/bin/perl
    /usr/lib/sendmail ->  /usr/sbin/sendmail

#################################################################

files:

   /usr/tmp mode=1777 owner=root action=fixall

#################################################################

editfiles:

   #
   # Comment out all lines to shut up this annoying cfengine-like
   # script, which sends mail every day!!!
   #

   @{ /etc/crontab

   HashCommentLinesContaining "daily"
   HashCommentLinesContaining "weekly"
   HashCommentLinesContaining "monthly"
   @}

#################################################################

copy:

      $(masterfiles)/etc/printcap.client      dest=/etc/printcap mode=0644

#########################################################################

shellcommands:

  Hr00::

    "/usr/libexec/locate.updatedb"
    "/usr/bin/makewhatis /usr/share/man:/usr/X11R6/man"

###
#
# END cf.bsd
#
###


@end smallexample

@c .....................................................
@c SECTION
@c .....................................................

@node cfd.conf,  , cf.freebsd, Example configuration file
@section cfd.conf
@cindex @file{cf.site}

@smallexample
#########################################################
#
# This is a cfd config file
#
# The access control here follows after any tcpd
# control in /etc/hosts.allow and /etc/hosts.deny
#
#########################################################

 #
 # Could import cf.groups here and use a structure like
 # in cfengine.conf, cf.main, cf.groups
 #

control:

  public = ( /usr/local/publicfiles )

  almost_public = ( /usr/local/almostpublicfiles )

  cfrunCommand = ( /iu/nexus/ud/mark/comp/Tests/cfrun-command )

  MaxConnections = ( 10 )

#########################################################

admit:   # or grant:

     $(public) *

     $(almost_public) *.iu.hioslo.no *.gnu.ai.mit.edu

     /etc/passwd *.iu.hioslo.no

     #
     # Who can exec cfengine remotely?
     #

     $(cfrunCommand) *.iu.hioslo.no

#########################################################

deny:

     $(public)/special *.moneyworld.com


@end smallexample

@c **********************************************************************
@c CHAPTER
@c **********************************************************************

@node Runtime Options, Network protocol specs, Example configuration file, Top
@appendix Runtime Options


@noindent Note that GNU long options are available with the syntax
@code{--longoption}.  The long names are given in brackets.
 
@table @samp
 
@item -a 
(@code{--sysadm}) Print only the name of the system administrator then quit.


@item -A
(@code{--auto}) Can be used to signify an automatic run of cfengine, as opposed
to a manual run. The distinction is not predetermined. Use of this option
currently causes cfengine to ignore locks. This option is reserved for future
development.

@item -c 
(@code{--no-check-files}) Do not check file systems for ownership / permissions etc.

@item -C 
(@code{--no-check-mounts}) Check mount points for consistency.  If this
option is specified then directories which lie in the ``mount point''
area are checked to see whether there is anything mounted on them.
Normally this is @emph{off} since not all machines use mounted file
systems in the same way.  e.g.  HPUX does not generally operate with
partitions, but nevertheless one might wish to mimick a partition-like
environment there, but it would be irritating to be informed that
nothing was mounted on the mount point.

@item -d 
(@code{--debug}) Enable debugging output.  Normally you will want to
send this to a file using the shell script command or a pipe.
 -d1 shows only parsing output.  -d2 shows only
runtime action output.  -d0 shows both levels. Debugging ouput is
intended mainly for the author's convenience and is not a supported
feature. The details of this output may change at any time.

@item -D 
(@code{--define}) Define a compound class symbol of the form
@emph{alpha.beta.gamma}.

@item -e
(@code{--no-edits}) Suppress file editing.

@item -E
(@code{--enforce-links}) Globally force links to be created where plain
files or links already exist. Since this option
is a big hammer, you have to use it in interactive mode and
answer a yes/no query before cfengine will run like this.

@item -f 
(@code{--file}) Parse filename after this switch.  By default cfengine
looks for a file called @emph{cfengine.conf} in the current directory.
 
@item -h  
(@code{--help}) Help information.  Display version banner and options
summary.

@item -H
(@code{--no-hard-classes}). Prevents cfengine from generating any internal
class name information. Can be used for emulation purposes.
@cindex Internal classes, switching off
@cindex Switching off internal classes
 
@item -i 
(@code{--no-ifconfig}) Do not attempt to configure the local area
network interface.

@item -I
(@code{--inform}) Switches on the inform output level, whereby cfengine
reports everything it changes..
 
@item -k
(@code{--no-copy}) Do not copy/image any files.

@item -K
(@code{--no-lock}) Ignore locks when running.

@item -l  
(@code{--traverse-links}) Normally cfengine does not follow symbolic
links when recursively parsing directories.  This option will force it
to do so.
 

@item -L
(@code{--delete-stale-links}) Delete links which do not point to
existing files (except in user home directories, which are not touched).

@item -m 
(@code{--no-mount}) Do not attempt to mount file systems or edit the
filesystem table.

@item -n 
(@code{--recon},@code{--dry-run},@code{--just-print}) No action.  Only
print what has to be done without actually doing it.

@item -N 
(@code{--negate},@code{--undefine}) Cancel a set of classes,
or undefine (set value to @emph{false}) a compound class of the form
@emph{alpha.beta.gamma}.

@item -p 
(@code{--parse-only}) Parse file and then stop.  Used for checking the
syntax of a program.  You do not have to be superuser to use this
option.

@item -q
(@code{--no-splay}) Switch off host splaying (sleeping).

@item -s 
(@code{--no-commands}) Do not execute scripts or shell commands.

@item -S 
(@code{--silent}) Silence run time warnings.

@item -t 
(@code{--no-tidy}) Do not tidy file systems.

@item -u
(@code{--use-env}) Causes cfengine to generate an environment variable
@samp{CFALLCLASSES} which can be read by child processes (scripts). This
variable contains a summary of all the currently defined classes at any
given time. This option causes some system 5 systems to generate a Bus
Error or segmentation fault. The same information is available from the
cfengine internal variable @code{$(allclasses)} and can be passed as a
parameter to scripts.
@cindex Environment variable CFALLCLASSES
@vindex CFALLCLASSES

@item -U
(@code{--underscore-classes}). When this option is set, cfengine adds
an underscore to the beginning of all hard system classes (like @code{_sun4}, @code{_linux}
etc.) This can be used to avoid naming conflicts if you are so
unjudicious as to name a host by the name of a hard class. Other classes
are not affected.

@item -v  
(@code{--verbose}) Verbose mode.  Prints detailed information about
actions and state.

@item -V 
(@code{--version}) Print only the version string and then quit.

@item -x
(@code{--no-preconf}) Do not execute the @file{cf.preconf} net
configuration file.

@item -X
(@code{--no-links}) Do not execute the @code{links} section of a
program.

@item -w 
(@code{--no-warn},@code{--quiet}) Do not print warning
messages.



@end table

@c **********************************************************************
@c CHAPTER
@c **********************************************************************

@node Network protocol specs, Variable Index, Runtime Options, Top
@appendix Cfengine network protocol specs

Cfengine uses a simple protocol for communicating via a streams-based
tcp connection. This section documents the protocol for anyone who
might want to create their own clients or server components to
interface with cfengine. Several transfers use a standard buffer
size of 4096 bytes. The get-file service uses a character based
read interface in which the buffer size is not directly relevant; the
size of the get-file buffer is dictated by client-side disk blocksizes.

Each new connection to the remote server daemon must
begin with a verification or `login' string whereby the client
identifies itself to the server. This information is used to verify the
connection by using a reverse DNS lookup and then a double-reverse
lookup. This is the basis of hostname authentication.

The various services are listed below:

@table @emph

@item Stat file

@smallexample
  AUTH client-name server-name
  SYNCH long-time-string STAT filename

  reply with OK: <stat-reply-string>
@end smallexample

@item Get file

@smallexample
   AUTH client-name server-name
   GET filename

   reply with <stream>, break on zero chars received
   or BAD: <message>
@end smallexample

@item Opendir
Recursive parsing of directory trees poses a technical problem. If
cfengine keeps a connection open and send buffers on a need-to-know
basis, then the number of daemon connections will mount up and overload
the server.  If cfengine caches the entire directory on the client side,
allowing the server connection to be severed, then the caching could
easily fill the memory of the client. The policy chosen is to attempt to
cache all names client-side, in spite of the possible memory
problem. The reason for this choice is that, even on large filesystems
(max size of paritions with 32 bit pointers is 4GB), the sum memory used
by every filename is only of the order of a few megabytes, and this is
within reasonable modern memory limits. It is assumed that, even 64 bit
users will not create filesystems which are much large than this.

@smallexample
    AUTH client-name server-name
    OPENDIR dir-name

    reply with <stream>, break on zero chars received
@end smallexample
In the future it might be useful to stat the file automatically here
and cache the value client-side.

@item   Exec
@smallexample
       AUTH client-name server-name
       EXEC option-string
       CLASSES stream terminated with --- (CFD_TERMINATE)

       reply with <stream>, break on zero chars received
@end smallexample

@item Checksum verification
@smallexample
       MD5 filename 16 byte sequence

       reply with CFD_TRUE for no match (copy) or CFD_FALSE for match (no copy)
@end smallexample

@item Reply formatting
The format of reply messages, except for stream data, is
@smallexample

  OK: @var{message}

  BAD: @var{message}
   
@end smallexample
A return prefix of `BAD' implies a failure server-side and the
client-side wrapper functions return -1 in this case.

The server daemon currently runs single threaded for all requests except
GetFile. Since cfd uses heavyweight processes for general applicablity
this avoids unnecessary forking and context switching which would
download the server. An upper limit on the number of forks which may be
performed is set in the config file. This is mananged using the SIGCHLD
signal and a pair of arrays in the master processes (This approach is
used to avoid shared memory and semaphore usage which is not portable
to many older BSD derivative systems).

@end table

@c **********************************************************************
@c INDEX
@c **********************************************************************

@node Variable Index, Concept Index, Network protocol specs, Top
@unnumbered Variable Index

@printindex vr

@node Concept Index, FAQ Index, Variable Index, Top
@unnumbered Concept Index

@printindex cp

@node FAQ Index,  , Concept Index, Top
@unnumbered FAQ Index

@printindex mb

@contents

@bye