Ubuntu Pastebin

Paste from costamagnagianfranco at Thu, 7 Jan 2016 13:16:20 +0000

Download as text
   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
diff -Nru ppp-2.4.7/debian/changelog ppp-2.4.7/debian/changelog
--- ppp-2.4.7/debian/changelog	2015-12-04 09:23:37.000000000 +0100
+++ ppp-2.4.7/debian/changelog	2016-01-07 14:14:51.000000000 +0100
@@ -1,3 +1,20 @@
+ppp (2.4.7-1+1ubuntu1) xenial; urgency=low
+
+  * Merge from Debian unstable.  Remaining changes:
+    - debian/patches/load_ppp_generic_if_needed: load ppp_generic kernel
+      module if needed.
+    - add EAP-TLS/MPPE support patch from Jan Just Keijser.
+    - debian/control: add libssl-dev to Build-Depends for the EAP-TLS patch.
+  * debian/patches/ppp-2.4.5-eaptls-mppe-0.994.patch,
+    debian/patches/ppp-2.4.6-eaptls-mppe-0.997.patch: updated the EAP-TLS/MPPE
+    support patch to the latest version from its upstream (also refreshed it).
+  * debian/ppp.preinst: deal with the change in LSB headers start runlevels
+    of pppd-dns due to dropping our changes (which are no longer necessary
+    since resolvconf is installed in most systems and has been for a while);
+    this should probably be kept until the next LTS.
+
+ -- Gianfranco Costamagna <locutusofborg@debian.org>  Thu, 07 Jan 2016 14:12:40 +0100
+
 ppp (2.4.7-1+1) unstable; urgency=medium
 
   * Upload to unstable.
@@ -47,6 +64,23 @@
 
  -- Chris Boot <debian@bootc.net>  Fri, 06 Nov 2015 15:32:25 +0000
 
+ppp (2.4.6-3.1ubuntu1) vivid; urgency=low
+
+  * Merge from Debian unstable.  Remaining changes:
+    - debian/patches/load_ppp_generic_if_needed: load ppp_generic kernel
+      module if needed.
+    - add EAP-TLS/MPPE support patch from Jan Just Keijser.
+    - debian/control: add libssl-dev to Build-Depends for the EAP-TLS patch.
+  * debian/patches/ppp-2.4.5-eaptls-mppe-0.994.patch,
+    debian/patches/ppp-2.4.6-eaptls-mppe-0.997.patch: updated the EAP-TLS/MPPE
+    support patch to the latest version from its upstream (also refreshed it).
+  * debian/ppp.preinst: deal with the change in LSB headers start runlevels
+    of pppd-dns due to dropping our changes (which are no longer necessary
+    since resolvconf is installed in most systems and has been for a while);
+    this should probably be kept until the next LTS.
+
+ -- Scott Kitterman <scott@kitterman.com>  Thu, 16 Apr 2015 09:07:29 -0400
+
 ppp (2.4.6-3.1) unstable; urgency=high
 
   * Non-maintainer upload.
@@ -60,6 +94,23 @@
 
  -- Emanuele Rocca <ema@debian.org>  Tue, 14 Apr 2015 08:18:06 +0200
 
+ppp (2.4.6-3ubuntu1) vivid; urgency=medium
+
+  * Merge with Debian unstable; remaining changes:
+    - debian/patches/load_ppp_generic_if_needed: load ppp_generic kernel
+      module if needed.
+    - add EAP-TLS/MPPE support patch from Jan Just Keijser.
+    - debian/control: add libssl-dev to Build-Depends for the EAP-TLS patch.
+  * debian/patches/ppp-2.4.5-eaptls-mppe-0.994.patch,
+    debian/patches/ppp-2.4.6-eaptls-mppe-0.997.patch: updated the EAP-TLS/MPPE
+    support patch to the latest version from its upstream (also refreshed it).
+  * debian/ppp.preinst: deal with the change in LSB headers start runlevels
+    of pppd-dns due to dropping our changes (which are no longer necessary
+    since resolvconf is installed in most systems and has been for a while);
+    this should probably be kept until the next LTS.
+
+ -- Mathieu Trudel-Lapierre <mathieu-tl@ubuntu.com>  Fri, 19 Dec 2014 13:51:52 -0500
+
 ppp (2.4.6-3) unstable; urgency=high
 
   * Urgency high due to fix for CVE-2014-3158.
@@ -234,6 +285,39 @@
 
  -- Chris Boot <bootc@bootc.net>  Tue, 28 May 2013 15:56:31 +0100
 
+ppp (2.4.5-5.1ubuntu3) utopic; urgency=medium
+
+  * Drop gdm dependency from the pppd-dns script, to resolve failing to
+    configure ppp package without having gdm's init.d script enabled (and
+    thus gdm installed & configured).
+
+ -- Dimitri John Ledkov <xnox@ubuntu.com>  Thu, 29 May 2014 08:54:57 +0200
+
+ppp (2.4.5-5.1ubuntu2) raring-proposed; urgency=low
+
+  * add EAPTLS-MPPE 0.994 patch from http://www.nikhef.nl/~janjust/ppp/
+    (Closes: #602503, LP: #643417) (quilt refreshed)
+  * debian/control: Build-Depends on libssl-dev 
+
+ -- Pavel Plesov <pavel.plesov@gmail.com>  Sun, 23 Dec 2012 23:44:40 +0400
+
+ppp (2.4.5-5.1ubuntu1) raring; urgency=low
+
+  [ Ubuntu Merge-o-Matic ]
+  * Merge from Debian unstable.  Remaining changes:
+    - /etc/ppp/options: default is noauth instead of auth.
+    - extra/pon: Perform ppp_on_boot migration from pppoe package.
+    - debian/ppp.postinst: init script migration for version before
+      2.4.5~git20081126t100229-0ubuntu2.
+    - debian/ppp.pppd-dns: Update LSB header.
+    - Provide pppoe_on_boot file.
+    - Move pppd-dns script to S45.
+    - debian/patches/load_ppp_generic_if_needed: load ppp_generic kernel
+      module if needed.
+    - Fix FTBFS with linux 3.5 headers.
+
+ -- Adam Conrad <adconrad@ubuntu.com>  Sun, 02 Dec 2012 03:57:07 -0700
+
 ppp (2.4.5-5.1) unstable; urgency=low
 
   * Non-maintainer upload.
@@ -241,12 +325,49 @@
 
  -- Robert Millan <rmh@debian.org>  Sun, 22 Apr 2012 16:25:45 +0200
 
+ppp (2.4.5-5ubuntu2) quantal-proposed; urgency=low
+
+  * FTBS fix against linux 3.5 headers: Update debian/patches/update_if_pppol2tp
+    to reflect changes in Linux 3.5 includes.
+
+ -- Tim Gardner <tim.gardner@canonical.com>  Tue, 25 Sep 2012 16:20:00 +0000
+
+ppp (2.4.5-5ubuntu1) natty; urgency=low
+
+  * Merge from debian unstable. (LP: #712419) Remaining changes:
+    - /etc/ppp/options: default is noauth instead of auth.
+    - extra/pon: Perform ppp_on_boot migration from pppoe package.
+    - debian/ppp.postinst: init script migration for version before
+      2.4.5~git20081126t100229-0ubuntu2.
+    - debian/ppp.pppd-dns: Update LSB header.
+    - Provide pppoe_on_boot file.
+    - Move pppd-dns script to S45.
+    - debian/patches/load_ppp_generic_if_needed: load ppp_generic kernel
+      module if needed.
+
+ -- Angel Abad <angelabad@ubuntu.com>  Thu, 03 Feb 2011 13:16:46 +0100
+
 ppp (2.4.5-5) unstable; urgency=medium
 
   * Updated debconf translation: da. (Closes: #601791)
 
  -- Marco d'Itri <md@linux.it>  Wed, 19 Jan 2011 23:24:16 +0100
 
+ppp (2.4.5-4ubuntu1) natty; urgency=low
+
+  * Merge with Debian; remaining changes:
+    - /etc/ppp/options: default is noauth instead of auth.
+    - extra/pon: Perform ppp_on_boot migration from pppoe package.
+    - debian/ppp.postinst: init script migration for version before
+      2.4.5~git20081126t100229-0ubuntu2.
+    - debian/ppp.pppd-dns: Update LSB header.
+    - Provide pppoe_on_boot file.
+    - Move pppd-dns script to S45.
+    - debian/patches/load_ppp_generic_if_needed: load ppp_generic kernel
+      module if needed.
+
+ -- Matthias Klose <doko@ubuntu.com>  Wed, 24 Nov 2010 18:12:47 +0100
+
 ppp (2.4.5-4) unstable; urgency=low
 
   * Make sure to actually rebuild pppd for the udeb instead of using the
@@ -323,6 +444,115 @@
 
  -- Christian Perrier <bubulle@debian.org>  Fri, 28 Nov 2008 18:36:26 +0100
 
+ppp (2.4.5~git20081126t100229-0ubuntu4) maverick; urgency=low
+
+  * debian/patches/update_if_pppol2tp: Update include/linux/if_pppol2tp.h to
+    match current kernel definitions (LP: #600947).
+
+ -- Colin Watson <cjwatson@ubuntu.com>  Fri, 09 Jul 2010 17:27:36 +0100
+
+ppp (2.4.5~git20081126t100229-0ubuntu3) lucid; urgency=low
+
+  * rebuild rest of main for armel armv7/thumb2 optimization;
+    UbuntuSpec:mobile-lucid-arm-gcc-v7-thumb2
+
+ -- Alexander Sack <asac@ubuntu.com>  Sun, 07 Mar 2010 01:01:51 +0100
+
+ppp (2.4.5~git20081126t100229-0ubuntu2) jaunty; urgency=low
+
+  * debian/rules: Start the init script in runlevels 1-5, it does not need to
+    start before gdm.
+  * debian/ppp.postinst: Remove old init script symlinks.
+  * debian/ppp.pppd-dns: Update LSB header.
+
+ -- Scott James Remnant <scott@ubuntu.com>  Fri, 20 Feb 2009 15:15:49 +0000
+
+ppp (2.4.5~git20081126t100229-0ubuntu1) jaunty; urgency=low
+
+  * new upstream snapshot 2.4.5pre gitXXXX
+  * debian/rules,debian/scripts/vars bump upstream version and
+    and tarball dir
+  * rebase debian patches that still apply
+    - debian/patches/008_pathnames.h.diff,
+      debian/patches/010_scripts_README.diff,
+      debian/patches/011_scripts_redialer.diff,
+      debian/patches/018_ip-up_option.diff,
+      debian/patches/atm_resolver_light,
+      debian/patches/chat_man,
+      debian/patches/cifdefroute.dif,
+      debian/patches/close_dev_ppp,
+      debian/patches/fix_linkpidfile,
+      debian/patches/fix_null_pppdb,
+      debian/patches/load_ppp_generic_if_needed,
+      debian/patches/no_crypt_hack,
+      debian/patches/no_crypt_hack_2.4.5,
+      debian/patches/ppp-2.3.11-oedod.dif,
+      debian/patches/ppp-2.4.2-stripMSdomain,
+      debian/patches/pppdump_use_zlib,
+      debian/patches/pppdump_z_no_deflate,
+      debian/patches/pppoatm_cleanup,
+      debian/patches/pppoe_readme,
+      debian/patches/readable_connerrs,
+      debian/patches/resolv.conf_no_log,
+      debian/patches/setevn_call_file,
+      debian/patches/syslog_local2,
+      debian/patches/zzz_config,
+      debian/patches/zzz_man_typos
+  * drop patches superseeded upstream
+    - debian/patches/fix_close_fd0
+    - debian/patches/fix_mschapv2_ppp
+    - debian/patches/pppoatm_fix_mtu
+    - debian/patches/pppoe_cleanup
+    - debian/patches/zzzz_lp258801_fix_ppp_dns_1.patch
+    - debian/patches/zzzz_lp258801_fix_ppp_dns_2.patch
+    - debian/patches/zzzz_lp258801_fix_ppp_dns.patch
+  * add patches required for new codebase:
+    - no_crypt_hack_2.4.5: crypt is now also getting used in session.c
+      apply NO_CRYPT_HACK for -udeb support here too
+
+ -- Alexander Sack <asac@ubuntu.com>  Mon, 16 Feb 2009 11:57:28 +0100
+
+ppp (2.4.4rel-10.1) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Fix pending l10n issues. Debconf translations:
+    - Traditional Chinese. Closes: #505952
+    - Catalan. Closes: #506336
+    - Swedish. Closes: #491421
+    - Japanese. Closes: #489333
+    - Polish. Closes: #506852
+    - Belarusian. Closes: #506927
+
+ -- Christian Perrier <bubulle@debian.org>  Fri, 28 Nov 2008 18:36:26 +0100
+
+ppp (2.4.4rel-10ubuntu2.8.10.1) intrepid-proposed; urgency=low
+
+  * fix LP: #258801; Gets bogus DNS servers during PPP negotiation; we
+    apply two more patches from git (details in patch)
+    - add debian/patches/zzzz_lp258801_fix_ppp_dns_1.patch
+    - add debian/patches/zzzz_lp258801_fix_ppp_dns_2.patch
+
+ -- Alexander Sack <asac@ubuntu.com>  Wed, 19 Nov 2008 14:05:43 +0100
+
+ppp (2.4.4rel-10ubuntu2) intrepid; urgency=low
+
+  * fix LP: #258801; Gets bogus DNS servers during PPP negotiation; we apply
+    the patch from http://marc.info/?l=linux-ppp&m=119559914711075&w=2
+    - add debian/patches/zzzz_lp258801_fix_ppp_dns.patch
+
+ -- Alexander Sack <asac@ubuntu.com>  Thu, 16 Oct 2008 03:17:37 +0200
+
+ppp (2.4.4rel-10ubuntu1) intrepid; urgency=low
+
+  * Merge from debian unstable, remaining changes:
+    - "Perform ppp_on_boot migration from pppoe package."
+    - provide pppoe_on_boot file
+    - debian/patches/load_ppp_generic_if_needed: load ppp_generic kernel
+      module if needed
+    - /etc/ppp/options: default is noauth instead of auth.
+
+ -- Michael Vogt <michael.vogt@ubuntu.com>  Mon, 23 Jun 2008 14:04:47 +0200
+
 ppp (2.4.4rel-10) unstable; urgency=low
 
    * ppp-udeb: allow for preseeding of the netcfg/get_hostname template.
@@ -359,6 +589,24 @@
 
  -- Frans Pop <fjp@debian.org>  Tue, 08 Apr 2008 16:53:04 +0200
 
+ppp (2.4.4rel-9ubuntu2) gutsy; urgency=low
+
+  * Trigger rebuild for hppa
+
+ -- LaMont Jones <lamont@ubuntu.com>  Thu, 04 Oct 2007 12:21:29 -0600
+
+ppp (2.4.4rel-9ubuntu1) gutsy; urgency=low
+
+  * Merge from debian unstable, remaining changes:
+    - "Perform ppp_on_boot migration from pppoe package."
+    - provide pppoe_on_boot file
+    - debian/patches/load_ppp_generic_if_needed: load ppp_generic kernel
+      module if needed
+    - /etc/ppp/options: default is noauth instead of auth.
+    - maintainer field set to ubuntu
+
+ -- Michael Vogt <michael.vogt@ubuntu.com>  Tue, 15 May 2007 11:09:49 +0200
+
 ppp (2.4.4rel-9) unstable; urgency=low
 
   * ppp-udeb: quote username and password in pap/chap secrets since they
@@ -432,6 +680,22 @@
 
  -- Eddy Petrișor <eddy.petrisor@gmail.com>  Mon, 29 Jan 2007 16:58:03 +0200
 
+ppp (2.4.4rel-4.1ubuntu2) feisty; urgency=low
+
+  * /etc/ppp/options: default is noauth instead of auth.
+
+ -- Ian Jackson <iwj@ubuntu.com>  Wed,  4 Apr 2007 16:46:49 +0100
+
+ppp (2.4.4rel-4.1ubuntu1) feisty; urgency=low
+
+  * Merge from debian unstable, remaining changes:
+    - "Perform ppp_on_boot migration from pppoe package."
+    - provide pppoe_on_boot file
+    - debian/patches/load_ppp_generic_if_needed: load ppp_generic kernel
+      module if needed
+
+ -- Michael Vogt <michael.vogt@ubuntu.com>  Wed, 20 Dec 2006 12:23:42 +0100
+
 ppp (2.4.4rel-4.1) unstable; urgency=low
 
   * Non-maintainer upload with maintainer's consent.
@@ -444,6 +708,16 @@
 
  -- Arnaud Fontaine <arnaud@andesi.org>  Thu, 14 Dec 2006 21:31:55 +0100
 
+ppp (2.4.4rel-4ubuntu1) feisty; urgency=low
+
+  * Merge from debian unstable. Remaining changes:
+    - "Perform ppp_on_boot migration from pppoe package."
+    - provide pppoe_on_boot file
+    - debian/patches/load_ppp_generic_if_needed: load ppp_generic kernel
+      module if needed
+
+ -- Michael Vogt <michael.vogt@ubuntu.com>  Fri, 24 Nov 2006 08:39:13 +0100
+
 ppp (2.4.4rel-4) unstable; urgency=low
 
   [ Eddy Petrișor ]
@@ -497,6 +771,12 @@
 
  -- Marco d'Itri <md@linux.it>  Wed, 12 Jul 2006 18:26:01 +0200
 
+ppp (2.4.4rel-1ubuntu1) edgy; urgency=low
+
+  * Merge to Debian unstable.
+
+ -- Martin Pitt <martin.pitt@ubuntu.com>  Mon, 10 Jul 2006 18:34:10 +0200
+
 ppp (2.4.4rel-1) unstable; urgency=high
 
   * New upstream release. Fixes:
@@ -512,6 +792,36 @@
 
  -- Marco d'Itri <md@linux.it>  Sun,  9 Jul 2006 18:38:54 +0200
 
+ppp (2.4.4b1-1ubuntu4) edgy; urgency=low
+
+  * SECURITY UPDATE: Potential privilege escalation.
+  * debian/patches/winbind-setuid-failure-check:
+    - Check for a failing setuid() call (which can happen if the user hits PAM
+      limits). Before, a failing setuid() call would execute the NTLM
+      authentication helper as root.
+    - CVE-2006-2194
+
+ -- Martin Pitt <martin.pitt@ubuntu.com>  Wed,  5 Jul 2006 11:48:13 +0200
+
+ppp (2.4.4b1-1ubuntu3) dapper; urgency=low
+
+  * Move script to S55.
+
+ -- Scott James Remnant <scott@ubuntu.com>  Thu, 23 Feb 2006 15:30:22 +0000
+
+ppp (2.4.4b1-1ubuntu2) dapper; urgency=low
+
+  * Move pppd-dns script to S45.
+
+ -- Scott James Remnant <scott@ubuntu.com>  Mon, 30 Jan 2006 14:23:23 +0000
+
+ppp (2.4.4b1-1ubuntu1) dapper; urgency=low
+
+  * Synchronise with Debian unstable.
+  * Still keep the pppoe_on_boot stuff.
+
+ -- Matthias Klose <doko@ubuntu.com>  Thu, 15 Dec 2005 14:46:57 +0000
+
 ppp (2.4.4b1-1) unstable; urgency=low
 
   * New upstream release. Fixes:
@@ -541,6 +851,12 @@
 
  -- Marco d'Itri <md@linux.it>  Sun,  4 Dec 2005 15:22:23 +0100
 
+ppp (2.4.3-20050321+2ubuntu1) breezy; urgency=low
+
+  * Resynchronise with Debian.
+
+ -- Adam Conrad <adconrad@ubuntu.com>  Fri, 27 May 2005 15:47:55 +0000
+
 ppp (2.4.3-20050321+2) unstable; urgency=high
 
   * Added patch close_dev_ppp to fix pppd spinning on select() and using
@@ -556,6 +872,20 @@
 
  -- Marco d'Itri <md@linux.it>  Wed,  4 May 2005 02:00:04 +0200
 
+ppp (2.4.3-20050321+1ubuntu2) breezy; urgency=low
+
+  * Drop debian/patches/libpcap0.8, which has since been applied to
+    the upstream sources, and debian/patches/pcap, which is the
+    Debian patch to revert to libpcap0.7 (Closes Ubuntu bug #10033)
+
+ -- Adam Conrad <adconrad@0c3.net>  Fri, 22 Apr 2005 00:16:08 +0000
+
+ppp (2.4.3-20050321+1ubuntu1) breezy; urgency=low
+
+  * Resynchronise with Debian, resolving merge conflicts.
+
+ -- Adam Conrad <adconrad@0c3.net>  Thu, 21 Apr 2005 08:53:53 +0000
+
 ppp (2.4.3-20050321+1) unstable; urgency=high
 
   * New upstream snapshot, with a fix for the persist configuration option.
@@ -615,6 +945,12 @@
 
  -- Marco d'Itri <md@linux.it>  Thu, 24 Feb 2005 23:51:54 +0100
 
+ppp (2.4.2+20040428-6ubuntu1) hoary; urgency=low
+
+  * Resynchronise with Debian.
+
+ -- Michael Vogt <mvo@debian.org>  Wed, 12 Jan 2005 10:00:49 +0100
+
 ppp (2.4.2+20040428-6) unstable; urgency=medium
 
   * Removed references to nscd from the 0000usepeerdns scripts.
@@ -633,6 +969,27 @@
 
  -- Marco d'Itri <md@linux.it>  Thu, 30 Dec 2004 17:21:22 +0100
 
+ppp (2.4.2+20040428-5ubuntu3) hoary; urgency=low
+
+  * Migrate to libpcap0.8
+    - debian/patches/libpcap0.8
+    - Build-Depend on libpcap0.8-dev rather than libpcap0.7-dev
+
+ -- Matt Zimmerman <mdz@canonical.com>  Tue, 28 Dec 2004 13:44:43 -0800
+
+ppp (2.4.2+20040428-5ubuntu2) hoary; urgency=low
+
+  * Merge debian/ppp.init file.
+  * Remove patch applied in unstable (cbcp-check-packetlengths.diff).
+
+ -- Matthias Klose <m@klose.in-berlin.de>  Mon, 15 Nov 2004 15:22:11 +0000
+
+ppp (2.4.2+20040428-5ubuntu1) hoary; urgency=low
+
+  * Resynchronise with Debian.
+
+ -- Scott James Remnant <scott@canonical.com>  Tue, 09 Nov 2004 23:37:30 +0000
+
 ppp (2.4.2+20040428-5) unstable; urgency=medium
 
   * Removed patch pty_command_timeout. (Closes: #279929)
@@ -675,6 +1032,66 @@
 
  -- Marco d'Itri <md@linux.it>  Sun, 31 Oct 2004 16:02:19 +0100
 
+ppp (2.4.2+20040428-2ubuntu7) hoary; urgency=low
+
+  * Security upload for hoary (see previous changelog for details).
+
+ -- Martin Pitt <mpitt@debian.org>  Fri, 29 Oct 2004 09:02:37 +0200
+
+ppp (2.4.2+20040428-2ubuntu6.1) warty-security; urgency=low
+
+  * SECURITY UPDATE: fix potential buffer overflow and DOS (Warty bug #2808)
+  * added debian/patches/cbcp-check-packetlengths.diff to add proper packet
+    length and bounds checking to pppd/cbcp.c (taken from upstream CVS)
+  * References:
+    http://www.securityfocus.com/archive/1/379450
+
+ -- Martin Pitt <mpitt@debian.org>  Thu, 28 Oct 2004 14:48:17 +0200
+
+ppp (2.4.2+20040428-2ubuntu6) warty; urgency=low
+
+  * Small fix for ppp_on_boot migration; also fixes pointless warning in pon
+    (closes: Ubuntu#1977).
+  * Make really, really sure we get a /dev/ppp device by only loading
+    ppp_generic if /dev/ppp doesn't exist, and sleep for five seconds to work
+    around the udev race; move this to pppd, instead of pon, which also
+    guarantees that it's run as root (closes: Ubuntu#1980, #1981).
+
+ -- Daniel Stone <daniel.stone@canonical.com>  Sat,  2 Oct 2004 17:27:53 +1000
+
+ppp (2.4.2+20040428-2ubuntu5) warty; urgency=low
+
+  * If /etc/ppp_on_boot exists and is a symlink to /etc/ppp/ppp_on_boot.dsl,
+    which doesn't exist, then transition the symlink to pppoe_on_boot (closes:
+    Ubuntu#1153).
+
+ -- Daniel Stone <daniel.stone@canonical.com>  Sun, 26 Sep 2004 14:13:45 +1000
+
+ppp (2.4.2+20040428-2ubuntu4) warty; urgency=low
+
+  * Made pon load ppp_deflate (quietly), so /dev/ppp gets created (closes:
+    Ubuntu#1644).
+
+ -- Daniel Stone <daniel.stone@canonical.com>  Fri, 24 Sep 2004 14:12:06 +1000
+
+ppp (2.4.2+20040428-2ubuntu3) warty; urgency=low
+
+  * Add pppoe_on_boot, from pppoe's ppp_on_boot.dsl.
+
+ -- Daniel Stone <daniel.stone@canonical.com>  Thu, 23 Sep 2004 13:02:42 +1000
+
+ppp (2.4.2+20040428-2ubuntu2) warty; urgency=low
+
+  * Added versioned depend on lsb-base
+
+ -- Nathaniel McCallum <npmccallum@canonical.com>  Fri,  3 Sep 2004 15:14:36 -0400
+
+ppp (2.4.2+20040428-2ubuntu1) warty; urgency=low
+
+  * debian/ppp.init: pretty initscript
+
+ -- Nathaniel McCallum <npmccallum@canonical.com>  Fri,  3 Sep 2004 11:52:53 -0400
+
 ppp (2.4.2+20040428-2) unstable; urgency=medium
 
   * Temporarily removed patch ppp-2.4.2-libpcap.diff: switch back to
diff -Nru ppp-2.4.7/debian/control ppp-2.4.7/debian/control
--- ppp-2.4.7/debian/control	2015-12-04 09:23:37.000000000 +0100
+++ ppp-2.4.7/debian/control	2016-01-07 14:14:09.000000000 +0100
@@ -2,10 +2,11 @@
 Section: admin
 Priority: optional
 Homepage: http://ppp.samba.org/
-Maintainer: Chris Boot <debian@bootc.net>
+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
+XSBC-Original-Maintainer: Chris Boot <debian@bootc.net>
 Uploaders: Marco d'Itri <md@linux.it>
 Build-Depends: debhelper (>= 9~), libpcap0.8-dev, libpam0g-dev, zlib1g-dev,
- dh-systemd
+ dh-systemd, libssl-dev
 Standards-Version: 3.9.6
 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/pkg-ppp.git
 Vcs-Git: git://anonscm.debian.org/collab-maint/pkg-ppp.git
diff -Nru ppp-2.4.7/debian/patches/load_ppp_generic_if_needed ppp-2.4.7/debian/patches/load_ppp_generic_if_needed
--- ppp-2.4.7/debian/patches/load_ppp_generic_if_needed	1970-01-01 01:00:00.000000000 +0100
+++ ppp-2.4.7/debian/patches/load_ppp_generic_if_needed	2016-01-07 14:11:10.000000000 +0100
@@ -0,0 +1,66 @@
+From 053fa32a9ccd0ac1fbbda50db7aff7fdae18652a Mon Sep 17 00:00:00 2001
+From: Alexander Sack <asac@jwsdot.com>
+Date: Thu, 18 Dec 2008 05:33:13 +0100
+Subject: [PATCH] port: ppp-2.4.4rel/debian/patches/load_ppp_generic_if_needed
+
+---
+ pppd/sys-linux.c |   41 +++++++++++++++++++++++++++++++++++++++++
+ 1 files changed, 41 insertions(+), 0 deletions(-)
+
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -92,6 +92,7 @@
+ #include <ctype.h>
+ #include <termios.h>
+ #include <unistd.h>
++#include <wait.h>
+ 
+ /* This is in netdevice.h. However, this compile will fail miserably if
+    you attempt to include netdevice.h because it has so many references
+@@ -2126,6 +2127,46 @@
+ 
+     if (kernel_version >= KVERSION(2,3,13)) {
+ 	error("Couldn't open the /dev/ppp device: %m");
++	char modprobePath[PATH_MAX] = "";
++	int status, p, count;
++	pid_t pid;
++
++	fd = open("/proc/sys/kernel/modprobe", O_RDONLY);
++	if (fd >= 0) {
++		int count = read(fd, modprobePath, PATH_MAX - 1);
++		if (count < 1)
++			modprobePath[0] = 0;
++		else if (modprobePath[count - 1] == '\n')
++			modprobePath[count - 1] = 0;
++		close(fd);
++	}
++
++	if (modprobePath[0] == 0)
++		strcpy(modprobePath, "/sbin/modprobe");
++
++	switch (pid = fork()) {
++		case 0: /* child */
++			setenv("PATH", "/sbin", 1);
++			status = execl(modprobePath, "modprobe", "ppp_generic", NULL);
++		case -1: /* couldn't fork */
++			errno = ENOENT;
++		default: /* parent */
++			do
++				p = waitpid(pid, &status, 0);
++			while (p == -1 && count++ < 4);
++
++			sleep (5);
++
++	}
++
++	if ((fd = open("/dev/ppp", O_RDWR)) >= 0) {
++		new_style_driver = 1;
++		driver_version = 2;
++		driver_modification = 4;
++		driver_patch = 0;
++		close(fd);
++		return 1;
++	}
+ 	if (errno == ENOENT)
+ 	    no_ppp_msg =
+ 		"You need to create the /dev/ppp device node by\n"
diff -Nru ppp-2.4.7/debian/patches/ppp-2.4.6-eaptls-mppe-0.997.patch ppp-2.4.7/debian/patches/ppp-2.4.6-eaptls-mppe-0.997.patch
--- ppp-2.4.7/debian/patches/ppp-2.4.6-eaptls-mppe-0.997.patch	1970-01-01 01:00:00.000000000 +0100
+++ ppp-2.4.7/debian/patches/ppp-2.4.6-eaptls-mppe-0.997.patch	2016-01-07 14:12:09.000000000 +0100
@@ -0,0 +1,3161 @@
+Author: Jan Just Keijser <janjust@nikhef.nl>
+Description: EAP-TLS patch for pppd
+Bug-Ubuntu: https://launchpad.net/bugs/643417
+Bug-Debian: http://bugs.debian.org/602503
+Bug-Fedora: https://bugzilla.redhat.com/556407
+Origin: http://www.nikhef.nl/~janjust/ppp/download.html
+
+---
+ README.eap-tls              |  280 ++++++++++
+ etc.ppp/eaptls-client       |   10 
+ etc.ppp/eaptls-server       |   11 
+ etc.ppp/openssl.cnf         |   14 
+ linux/Makefile.top          |    6 
+ pppd/Makefile.linux         |   12 
+ pppd/auth.c                 |  413 ++++++++++++++
+ pppd/ccp.c                  |   20 
+ pppd/chap-md5.c             |    4 
+ pppd/eap-tls.c              | 1212 ++++++++++++++++++++++++++++++++++++++++++++
+ pppd/eap-tls.h              |  107 +++
+ pppd/eap.c                  |  449 ++++++++++++++++
+ pppd/eap.h                  |   32 +
+ pppd/md5.c                  |    4 
+ pppd/md5.h                  |    3 
+ pppd/pathnames.h            |    7 
+ pppd/plugins/Makefile.linux |    3 
+ pppd/plugins/passprompt.c   |    3 
+ pppd/plugins/passwordfd.c   |    4 
+ pppd/pppd.8                 |   33 +
+ pppd/pppd.h                 |    9 
+ 21 files changed, 2629 insertions(+), 7 deletions(-)
+
+Index: b/README.eap-tls
+===================================================================
+--- /dev/null
++++ b/README.eap-tls
+@@ -0,0 +1,280 @@
++EAP-TLS authentication support for PPP
++======================================
++
++1. Intro
++
++    The Extensible Authentication Protocol (EAP; RFC 3748) is a
++    security protocol that can be used with PPP.  It provides a means
++    to plug in multiple optional authentication methods.
++
++    Transport Level Security (TLS; RFC 2246) provides for mutual 
++    authentication, integrity-protected ciphersuite negotiation and 
++    key exchange between two endpoints.  It also provides for optional
++    MPPE encryption.
++
++    EAP-TLS (RFC 2716) incapsulates the TLS messages in EAP packets,
++    allowing TLS mutual authentication to be used as a generic EAP
++    mechanism. It also provides optional encryption using the MPPE
++    protocol.
++
++    This patch provide EAP-TLS support to pppd.
++    This authentication method can be used in both client or server
++    mode.
++
++2. Building
++
++    To build pppd with EAP-TLS support, OpenSSL (http://www.openssl.org)
++    is required. Any version from 0.9.7 should work.
++    
++    Configure, compile, and install as usual. 
++
++3. Configuration
++
++    On the client side there are two ways to configure EAP-TLS:
++
++    1. supply the appropriate 'ca', 'cert' and 'key' command-line parameters
++
++    2. edit the /etc/ppp/eaptls-client file.
++    Insert a line for each system with which you use EAP-TLS.
++    The line is composed of this fields separated by tab:
++
++      - Client name 
++        The name used by the client for authentication, can be *
++      - Server name
++        The name of the server, can be *
++      - Client certificate file 
++        The file containing the certificate chain for the 
++        client in PEM format
++      - Server certificate file
++        If you want to specify the certificate that the 
++        server is allowed to use, put the certificate file name.
++        Else put a dash '-'.
++      - CA certificate file
++        The file containing the trusted CA certificates in PEM
++        format.
++      - Client private key file
++        The file containing the client private key in PEM format.
++
++
++    On the server side edit the /etc/ppp/eaptls-server file.
++    Insert a line for each system with which you use EAP-TLS.
++    The line is composed of this fields separated by tab:
++
++      - Client name
++        The name used by the client for authentication, can be *
++      - Server name
++        The name of the server, can be *
++      - Client certificate file
++        If you want to specify the certificate that the
++        client is allowed to use, put the certificate file name.
++        Else put a dash '-'.
++      - Server certificate file
++        The file containing the certificate chain for the
++        server in PEM format
++      - CA certificate file
++        The file containing the trusted CA certificates in PEM format.
++      - Client private key file
++        The file containing the server private key in PEM format.
++      - addresses
++        A list of IP addresses the client is allowed to use.
++
++
++    OpenSSL engine support is included starting with v0.95 of this patch. 
++    Currently the only engine tested is the 'pkcs11' engine (hardware token
++    support). To use the 'pksc11' engine:
++      - Use a special private key fileiname in the /etc/ppp/eaptls-client file:
++          <engine>:<identifier>
++        e.g.
++          pkcs11:123456
++
++      - The certificate can also be loaded from the 'pkcs11' engine using
++        a special client certificate filename in the /etc/ppp/eaptls-client file:
++          <engine>:<identifier>
++        e.g.
++          pkcs11:123456
++
++      - Create an /etc/ppp/openssl.cnf file to load the right OpenSSL engine prior
++        to starting 'pppd'. A sample openssl.cnf file is
++
++        openssl_conf = openssl_def
++
++        [ openssl_def ]
++        engines = engine_section
++
++        [ engine_section ]
++        pkcs11 = pkcs11_section
++
++        [ pkcs11_section ]
++        engine_id = pkcs11
++        dynamic_path = /usr/lib64/openssl/engines/engine_pkcs11.so
++        MODULE_PATH = /usr/lib64/libeTPkcs11.so
++        init = 0
++
++      - There are two ways to specify a password/PIN for the PKCS11 engine:
++          - inside the openssl.cnf file using
++              PIN = your-secret-pin
++            Note The keyword 'PIN' is case sensitive!
++          - Using the 'password' in the ppp options file.
++        From v0.97 of the eap-tls patch the password can also be supplied
++        using the appropriate 'eaptls_passwd_hook' (see plugins/passprompt.c
++        for an example).
++
++
++4. Options
++
++    These pppd options are available:
++
++      ca <ca-file>
++        Use the CA public certificate found in <ca-file> in PEM format
++      cert <cert-file>
++        Use the client public certificate found in <cert-file> in PEM format
++        or in engine:engine_id format
++      key <key-file>
++        Use the client private key found in <key-file> in PEM format
++        or in engine:engine_id format
++      crl <crl-file>
++        Use the Certificate Revocation List (CRL) file <crl-file> in PEM format.
++      crl-dir <dir>
++        Use CRL files from directory <dir>. It contains CRL files in PEM
++        format and each file contains a CRL. The files are looked up 
++        by the issuer name hash value. Use the c_rehash utility 
++        to create necessary links.
++      need-peer-eap
++        If the peer doesn't ask us to authenticate or doesn't use eap
++        to authenticate us, disconnect.
++
++    Note: 
++      password-encrypted certificates can be used as of v0.94 of this 
++      patch. The password for the eap-tls.key file is specified using 
++      the regular
++          password ....
++      statement in the ppp options file, or by using the appropriate
++      plugin which supplies a 'eaptls_passwd_hook' routine.
++
++5. Connecting
++
++    If you're setting up a pppd server, edit the EAP-TLS configuration file 
++    as written above and then run pppd with the 'auth' option to authenticate
++    the client. The EAP-TLS method will be used if the other eap methods can't
++    be used (no secrets).
++
++    If you're setting up a client, edit the configuration file and then run
++    pppd with 'remotename' option to specify the server name. Add the 
++    'need-peer-eap' option if you want to be sure the peer ask you to
++    authenticate (and to use eap) and to disconnect if it doesn't.
++
++6. Example
++
++    The following example can be used to connect a Linux client with the 'pptp'
++    package to a Linux server running the 'pptpd' (PoPToP) package. The server
++    was configured with a certificate with name (CN) 'pptp-server', the client
++    was configured with a certificate with name (CN) 'pptp-client', both 
++    signed by the same Certificate Authority (CA).
++
++    Server side:
++      - /etc/pptpd.conf file:
++          option /etc/ppp/options-pptpd-eaptls
++          localip 172.16.1.1
++          remoteip 172.16.1.10-20 
++      - /etc/ppp/options-pptpd-eaptls file:
++          name pptp-server
++          lock 
++          mtu 1500 
++          mru 1450
++          auth 
++          lcp-echo-failure 3 
++          lcp-echo-interval 5 
++          nodeflate 
++          nobsdcomp
++          nopredictor1
++          nopcomp
++          noaccomp
++          
++          require-eap
++          require-mppe-128
++          
++          crl /home/janjust/ppp/keys/crl.pem
++          
++          debug
++          logfile /tmp/pppd.log
++
++      - /etc/ppp/eaptls-server file:
++           * pptp-server - /etc/ppp/pptp-server.crt /etc/ppp/ca.crt /etc/ppp/pptp-server.key *
++
++      - On the server, run 
++          pptdp --conf /etc/pptpd.conf
++       
++    Client side:
++      - Run
++          pppd noauth require-eap require-mppe-128 \
++            ipcp-accept-local ipcp-accept-remote noipdefault \
++            cert  /etc/ppp/keys/pptp-client.crt \
++            key   /etc/ppp/keys/pptp-client.key \
++            ca    /etc/ppp/keys/ca.crt \
++            name pptp-client remotename pptp-server \
++            debug logfile /tmp/pppd.log
++            pty "pptp pptp-server.example.com --nolaunchpppd"
++
++    Check /var/log/messages and the files /tmp/pppd.log on both sides for debugging info.
++
++7. Notes
++
++    This is experimental code.
++    Send suggestions and comments to Jan Just Keijser <janjust@nikhef.nl>
++
++8. Changelog of ppp-<>-eaptls-mppe-* patches
++
++v0.7     (22-Nov-2005)
++ - First version of the patch to include MPPE support
++ - ppp-2.4.3 only
++v0.9     (25-Jul-2006)
++ - Bug fixes
++ - First version for ppp-2.4.4
++v0.91    (03-Sep-2006)
++ - Added missing #include for md5.h
++ - Last version for ppp-2.4.3
++v0.92    (22-Apr-2008)
++ - Fix for openssl 0.9.8 issue with md5 function overload.
++v0.93    (14-Aug-2008)
++ - Make sure 'noauth' option can be used to bypass server certificate verification.
++v0.94    (15-Oct-2008)
++ - Added support for password-protected private keys by (ab)using the 'password' field. 
++v0.95    (23-Dec-2009)
++ - First version with OpenSSL engine support.
++v0.96    (27-Jan-2010)
++ - Added fully functional support for OpenSSL engines (PKCS#11)
++ - First version for ppp-2.4.5
++v0.97    (20-Apr-2010)
++ - Some bug fixes for v0.96
++ - Added support for entering the password via a plugin. The sample plugin 
++     .../pppd/plugins/passprompt.c has been extended with EAP-TLS support.
++   The "old" methods using the password option or the /etc/ppp/openssl.cnf file still work.
++ - Added support for specifying the client CA, certificate and private key on the command-line
++   or via the ppp config file.
++v0.98    (20-Apr-2010)
++ - Fix initialisation bug when using ca/cert/key command-line options.
++ - Last version for ppp-2.4.4
++v0.99    (05-Oct-2010)
++ - Fix coredump when using multilink option.
++v0.991   (08-Aug-2011)
++ - Fix compilation issue with openssl 1.0.
++v0.992   (01-Dec-2011)
++ - Fix compilation issue with eaptls_check_hook and passwordfd plugin.
++v0.993   (24-Apr-2012)
++ - Fix compilation issue when EAP_TLS=n in pppd/Makefile.
++v0.994   (11-Jun-2012)
++ - Fix compilation issue on Ubuntu 11.10.
++v0.995   (27-May-2014)
++ - Add support for a CRL file using the command-line option 'crl' 
++   (prior only 'crl-dir' was supported).
++ - Fix segfault when pkcs11 enginename was not specified correctly.
++ - Fix segfault when client was misconfigured.
++ - Disable SSL Session Ticket support as Windows 8 does not support this.
++v0.996   (28-May-2014)
++ - Fix minor bug where SessionTicket message was printed as 'Unknown SSL3 code 4'
++ - Add EAP-TLS-specific options to pppd.8 manual page.
++ - Updated README.eap-tls file with new option and provide an example.
++v0.997   (19-Jun-2014)
++ - change SSL_OP_NO_TICKETS to SSL_OP_NO_TICKET
++ - fix bug in initialisation code with fragmented packets.
++
+Index: b/etc.ppp/eaptls-client
+===================================================================
+--- /dev/null
++++ b/etc.ppp/eaptls-client
+@@ -0,0 +1,10 @@
++# Parameters for authentication using EAP-TLS (client)
++
++# client name (can be *)
++# server name (can be *)
++# client certificate file (required)
++# server certificate file (optional, if unused put '-')
++# CA certificate file (required)
++# client private key file (required)
++
++#client	server	/root/cert/client.crt	-	/root/cert/ca.crt	/root/cert/client.key
+Index: b/etc.ppp/eaptls-server
+===================================================================
+--- /dev/null
++++ b/etc.ppp/eaptls-server
+@@ -0,0 +1,11 @@
++# Parameters for authentication using EAP-TLS (server)
++
++# client name (can be *)
++# server name (can be *)
++# client certificate file (optional, if unused put '-')
++# server certificate file (required)
++# CA certificate file (required)
++# server private key file (required)
++# allowed addresses (required, can be *)
++
++#client	server	-	/root/cert/server.crt	/root/cert/ca.crt	/root/cert/server.key	192.168.1.0/24
+Index: b/etc.ppp/openssl.cnf
+===================================================================
+--- /dev/null
++++ b/etc.ppp/openssl.cnf
+@@ -0,0 +1,14 @@
++openssl_conf = openssl_def
++
++[ openssl_def ]
++engines = engine_section
++
++[ engine_section ]
++pkcs11 = pkcs11_section
++
++[ pkcs11_section ]
++engine_id = pkcs11
++dynamic_path = /usr/lib64/openssl/engines/engine_pkcs11.so
++MODULE_PATH = /usr/lib64/libeTPkcs11.so
++init = 0
++
+Index: b/linux/Makefile.top
+===================================================================
+--- a/linux/Makefile.top
++++ b/linux/Makefile.top
+@@ -26,7 +26,7 @@ install-progs:
+ 	cd pppdump; $(MAKE) $(MFLAGS) install
+ 
+ install-etcppp: $(ETCDIR) $(ETCDIR)/options $(ETCDIR)/pap-secrets \
+-	$(ETCDIR)/chap-secrets
++	$(ETCDIR)/chap-secrets $(ETCDIR)/eaptls-server $(ETCDIR)/eaptls-client
+ 
+ install-devel:
+ 	cd pppd; $(MAKE) $(MFLAGS) install-devel
+@@ -37,6 +37,10 @@ $(ETCDIR)/pap-secrets:
+ 	$(INSTALL) -c -m 600 etc.ppp/pap-secrets $@
+ $(ETCDIR)/chap-secrets:
+ 	$(INSTALL) -c -m 600 etc.ppp/chap-secrets $@
++$(ETCDIR)/eaptls-server:
++	$(INSTALL) -c -m 600 etc.ppp/eaptls-server $@
++$(ETCDIR)/eaptls-client:
++	$(INSTALL) -c -m 600 etc.ppp/eaptls-client $@
+ 
+ $(BINDIR):
+ 	$(INSTALL) -d -m 755 $@
+Index: b/pppd/Makefile.linux
+===================================================================
+--- a/pppd/Makefile.linux
++++ b/pppd/Makefile.linux
+@@ -76,6 +76,9 @@ CBCP=y
+ # Use libutil
+ USE_LIBUTIL=y
+ 
++# Enable EAP-TLS authentication (requires libssl and libcrypto)
++USE_EAPTLS=y
++
+ MAXOCTETS=y
+ 
+ INCLUDE_DIRS= -I../include
+@@ -116,6 +119,15 @@ HEADERS += sha1.h
+ PPPDOBJS += sha1.o
+ endif
+ 
++# EAP-TLS
++ifdef USE_EAPTLS
++CFLAGS += -DUSE_EAPTLS=1 -I/usr/kerberos/include
++LIBS += -lssl -lcrypto
++PPPDSRC += eap-tls.c
++HEADERS += eap-tls.h
++PPPDOBJS += eap-tls.o
++endif
++
+ ifdef HAS_SHADOW
+ CFLAGS   += -DHAS_SHADOW
+ #LIBS     += -lshadow $(LIBS)
+Index: b/pppd/auth.c
+===================================================================
+--- a/pppd/auth.c
++++ b/pppd/auth.c
+@@ -109,6 +109,9 @@
+ #include "upap.h"
+ #include "chap-new.h"
+ #include "eap.h"
++#ifdef USE_EAPTLS
++#include "eap-tls.h"
++#endif
+ #ifdef CBCP_SUPPORT
+ #include "cbcp.h"
+ #endif
+@@ -183,6 +186,11 @@ int (*chap_check_hook) __P((void)) = NUL
+ /* Hook for a plugin to get the CHAP password for authenticating us */
+ int (*chap_passwd_hook) __P((char *user, char *passwd)) = NULL;
+ 
++#ifdef USE_EAPTLS
++/* Hook for a plugin to get the EAP-TLS password for authenticating us */
++int (*eaptls_passwd_hook) __P((char *user, char *passwd)) = NULL;
++#endif
++
+ /* Hook for a plugin to say whether it is OK if the peer
+    refuses to authenticate. */
+ int (*null_auth_hook) __P((struct wordlist **paddrs,
+@@ -238,6 +246,14 @@ bool explicit_remote = 0;	/* User specif
+ bool explicit_user = 0;		/* Set if "user" option supplied */
+ bool explicit_passwd = 0;	/* Set if "password" option supplied */
+ char remote_name[MAXNAMELEN];	/* Peer's name for authentication */
++#ifdef USE_EAPTLS
++char *cacert_file  = NULL;	/* CA certificate file (pem format) */
++char *cert_file    = NULL;	/* client certificate file (pem format) */
++char *privkey_file = NULL;	/* client private key file (pem format) */
++char *crl_dir      = NULL;	/* directory containing CRL files */
++char *crl_file     = NULL;	/* Certificate Revocation List (CRL) file (pem format) */
++bool need_peer_eap = 0;			/* Require peer to authenticate us */
++#endif
+ 
+ static char *uafname;		/* name of most recent +ua file */
+ 
+@@ -254,6 +270,19 @@ static int  have_pap_secret __P((int *))
+ static int  have_chap_secret __P((char *, char *, int, int *));
+ static int  have_srp_secret __P((char *client, char *server, int need_ip,
+     int *lacks_ipp));
++
++#ifdef USE_EAPTLS
++static int  have_eaptls_secret_server
++__P((char *client, char *server, int need_ip, int *lacks_ipp));
++static int  have_eaptls_secret_client __P((char *client, char *server));
++static int  scan_authfile_eaptls __P((FILE * f, char *client, char *server,
++			       char *cli_cert, char *serv_cert,
++			       char *ca_cert, char *pk,
++			       struct wordlist ** addrs,
++			       struct wordlist ** opts,
++			       char *filename, int flags));
++#endif
++
+ static int  ip_addr_check __P((u_int32_t, struct permitted_ip *));
+ static int  scan_authfile __P((FILE *, char *, char *, char *,
+ 			       struct wordlist **, struct wordlist **,
+@@ -401,6 +430,15 @@ option_t auth_options[] = {
+       "Set telephone number(s) which are allowed to connect",
+       OPT_PRIV | OPT_A2LIST },
+ 
++#ifdef USE_EAPTLS
++    { "ca", o_string, &cacert_file,   "EAP-TLS CA certificate in PEM format" },
++    { "cert", o_string, &cert_file,   "EAP-TLS client certificate in PEM format" },
++    { "key", o_string, &privkey_file, "EAP-TLS client private key in PEM format" },
++    { "crl-dir", o_string, &crl_dir,  "Use CRLs in directory" },
++    { "crl", o_string, &crl_file,     "Use specific CRL file" },
++    { "need-peer-eap", o_bool, &need_peer_eap,
++      "Require the peer to authenticate us", 1 },
++#endif /* USE_EAPTLS */
+     { NULL }
+ };
+ 
+@@ -730,6 +768,9 @@ link_established(unit)
+     lcp_options *wo = &lcp_wantoptions[unit];
+     lcp_options *go = &lcp_gotoptions[unit];
+     lcp_options *ho = &lcp_hisoptions[unit];
++#ifdef USE_EAPTLS
++    lcp_options *ao = &lcp_allowoptions[unit];
++#endif
+     int i;
+     struct protent *protp;
+ 
+@@ -764,6 +805,22 @@ link_established(unit)
+ 	}
+     }
+ 
++#ifdef USE_EAPTLS
++    if (need_peer_eap && !ao->neg_eap) {
++	warn("eap required to authenticate us but no suitable secrets");
++	lcp_close(unit, "couldn't negotiate eap");
++	status = EXIT_AUTH_TOPEER_FAILED;
++	return;
++    }
++
++    if (need_peer_eap && !ho->neg_eap) {
++	warn("peer doesn't want to authenticate us with eap");
++	lcp_close(unit, "couldn't negotiate eap");
++	status = EXIT_PEER_AUTH_FAILED;
++	return;
++    }
++#endif
++
+     new_phase(PHASE_AUTHENTICATE);
+     auth = 0;
+     if (go->neg_eap) {
+@@ -1277,6 +1334,15 @@ auth_check_options()
+ 				    our_name, 1, &lacks_ip);
+     }
+ 
++#ifdef USE_EAPTLS
++    if (!can_auth && wo->neg_eap) {
++	can_auth =
++	    have_eaptls_secret_server((explicit_remote ? remote_name :
++				       NULL), our_name, 1, &lacks_ip);
++
++    }
++#endif
++
+     if (auth_required && !can_auth && noauth_addrs == NULL) {
+ 	if (default_auth) {
+ 	    option_error(
+@@ -1331,7 +1397,11 @@ auth_reset(unit)
+ 	passwd[0] != 0 ||
+ 	(hadchap == 1 || (hadchap == -1 && have_chap_secret(user,
+ 	    (explicit_remote? remote_name: NULL), 0, NULL))) ||
+-	have_srp_secret(user, (explicit_remote? remote_name: NULL), 0, NULL));
++	have_srp_secret(user, (explicit_remote? remote_name: NULL), 0, NULL)
++#ifdef USE_EAPTLS
++		|| have_eaptls_secret_client(user, (explicit_remote? remote_name: NULL))
++#endif
++	);
+ 
+     hadchap = -1;
+     if (go->neg_upap && !uselogin && !have_pap_secret(NULL))
+@@ -1346,8 +1416,14 @@ auth_reset(unit)
+ 	    !have_chap_secret((explicit_remote? remote_name: NULL), our_name,
+ 		1, NULL))) &&
+ 	!have_srp_secret((explicit_remote? remote_name: NULL), our_name, 1,
+-	    NULL))
++	    NULL)
++#ifdef USE_EAPTLS
++	 && !have_eaptls_secret_server((explicit_remote? remote_name: NULL),
++				   our_name, 1, NULL)
++#endif
++		)
+ 	go->neg_eap = 0;
++
+ }
+ 
+ 
+@@ -1709,6 +1785,7 @@ have_srp_secret(client, server, need_ip,
+ }
+ 
+ 
++
+ /*
+  * get_secret - open the CHAP secret file and return the secret
+  * for authenticating the given client on the given server.
+@@ -2361,3 +2438,335 @@ auth_script(script)
+ 
+     auth_script_pid = run_program(script, argv, 0, auth_script_done, NULL, 0);
+ }
++
++
++#ifdef USE_EAPTLS
++static int
++have_eaptls_secret_server(client, server, need_ip, lacks_ipp)
++    char *client;
++    char *server;
++    int need_ip;
++    int *lacks_ipp;
++{
++    FILE *f;
++    int ret;
++    char *filename;
++    struct wordlist *addrs;
++    char servcertfile[MAXWORDLEN];
++    char clicertfile[MAXWORDLEN];
++    char cacertfile[MAXWORDLEN];
++    char pkfile[MAXWORDLEN];
++
++    filename = _PATH_EAPTLSSERVFILE;
++    f = fopen(filename, "r");
++    if (f == NULL)
++		return 0;
++
++    if (client != NULL && client[0] == 0)
++		client = NULL;
++    else if (server != NULL && server[0] == 0)
++		server = NULL;
++
++    ret =
++	scan_authfile_eaptls(f, client, server, clicertfile, servcertfile,
++			     cacertfile, pkfile, &addrs, NULL, filename,
++			     0);
++
++    fclose(f);
++
++/*
++    if (ret >= 0 && !eaptls_init_ssl(1, cacertfile, servcertfile,
++				clicertfile, pkfile))
++		ret = -1;
++*/
++
++	if (ret >= 0 && need_ip && !some_ip_ok(addrs)) {
++		if (lacks_ipp != 0)
++			*lacks_ipp = 1;
++		ret = -1;
++    }
++    if (addrs != 0)
++		free_wordlist(addrs);
++
++    return ret >= 0;
++}
++
++
++static int
++have_eaptls_secret_client(client, server)
++    char *client;
++    char *server;
++{
++    FILE *f;
++    int ret;
++    char *filename;
++    struct wordlist *addrs = NULL;
++    char servcertfile[MAXWORDLEN];
++    char clicertfile[MAXWORDLEN];
++    char cacertfile[MAXWORDLEN];
++    char pkfile[MAXWORDLEN];
++
++    if (client != NULL && client[0] == 0)
++		client = NULL;
++    else if (server != NULL && server[0] == 0)
++		server = NULL;
++
++	if (cacert_file && cert_file && privkey_file)
++		return 1;
++
++    filename = _PATH_EAPTLSCLIFILE;
++    f = fopen(filename, "r");
++    if (f == NULL)
++		return 0;
++
++    ret =
++	scan_authfile_eaptls(f, client, server, clicertfile, servcertfile,
++			     cacertfile, pkfile, &addrs, NULL, filename,
++			     0);
++    fclose(f);
++
++/*
++    if (ret >= 0 && !eaptls_init_ssl(0, cacertfile, clicertfile,
++				servcertfile, pkfile))
++		ret = -1;
++*/
++
++    if (addrs != 0)
++		free_wordlist(addrs);
++
++    return ret >= 0;
++}
++
++
++static int
++scan_authfile_eaptls(f, client, server, cli_cert, serv_cert, ca_cert, pk,
++		     addrs, opts, filename, flags)
++    FILE *f;
++    char *client;
++    char *server;
++    char *cli_cert;
++    char *serv_cert;
++    char *ca_cert;
++    char *pk;
++    struct wordlist **addrs;
++    struct wordlist **opts;
++    char *filename;
++    int flags;
++{
++    int newline;
++    int got_flag, best_flag;
++    struct wordlist *ap, *addr_list, *alist, **app;
++    char word[MAXWORDLEN];
++
++    if (addrs != NULL)
++	*addrs = NULL;
++    if (opts != NULL)
++	*opts = NULL;
++    addr_list = NULL;
++    if (!getword(f, word, &newline, filename))
++	return -1;		/* file is empty??? */
++    newline = 1;
++    best_flag = -1;
++    for (;;) {
++	/*
++	 * Skip until we find a word at the start of a line.
++	 */
++	while (!newline && getword(f, word, &newline, filename));
++	if (!newline)
++	    break;		/* got to end of file */
++
++	/*
++	 * Got a client - check if it's a match or a wildcard.
++	 */
++	got_flag = 0;
++	if (client != NULL && strcmp(word, client) != 0 && !ISWILD(word)) {
++	    newline = 0;
++	    continue;
++	}
++	if (!ISWILD(word))
++	    got_flag = NONWILD_CLIENT;
++
++	/*
++	 * Now get a server and check if it matches.
++	 */
++	if (!getword(f, word, &newline, filename))
++	    break;
++	if (newline)
++	    continue;
++	if (!ISWILD(word)) {
++	    if (server != NULL && strcmp(word, server) != 0)
++		continue;
++	    got_flag |= NONWILD_SERVER;
++	}
++
++	/*
++	 * Got some sort of a match - see if it's better than what
++	 * we have already.
++	 */
++	if (got_flag <= best_flag)
++	    continue;
++
++	/*
++	 * Get the cli_cert
++	 */
++	if (!getword(f, word, &newline, filename))
++	    break;
++	if (newline)
++	    continue;
++	if (strcmp(word, "-") != 0) {
++	    strlcpy(cli_cert, word, MAXWORDLEN);
++	} else
++	    cli_cert[0] = 0;
++
++	/*
++	 * Get serv_cert
++	 */
++	if (!getword(f, word, &newline, filename))
++	    break;
++	if (newline)
++	    continue;
++	if (strcmp(word, "-") != 0) {
++	    strlcpy(serv_cert, word, MAXWORDLEN);
++	} else
++	    serv_cert[0] = 0;
++
++	/*
++	 * Get ca_cert
++	 */
++	if (!getword(f, word, &newline, filename))
++	    break;
++	if (newline)
++	    continue;
++	strlcpy(ca_cert, word, MAXWORDLEN);
++
++	/*
++	 * Get pk
++	 */
++	if (!getword(f, word, &newline, filename))
++	    break;
++	if (newline)
++	    continue;
++	strlcpy(pk, word, MAXWORDLEN);
++
++
++	/*
++	 * Now read address authorization info and make a wordlist.
++	 */
++	app = &alist;
++	for (;;) {
++	    if (!getword(f, word, &newline, filename) || newline)
++		break;
++	    ap = (struct wordlist *)
++		malloc(sizeof(struct wordlist) + strlen(word) + 1);
++	    if (ap == NULL)
++		novm("authorized addresses");
++	    ap->word = (char *) (ap + 1);
++	    strcpy(ap->word, word);
++	    *app = ap;
++	    app = &ap->next;
++	}
++	*app = NULL;
++	/*
++	 * This is the best so far; remember it.
++	 */
++	best_flag = got_flag;
++	if (addr_list)
++	    free_wordlist(addr_list);
++	addr_list = alist;
++
++	if (!newline)
++	    break;
++    }
++
++    /* scan for a -- word indicating the start of options */
++    for (app = &addr_list; (ap = *app) != NULL; app = &ap->next)
++	if (strcmp(ap->word, "--") == 0)
++	    break;
++    /* ap = start of options */
++    if (ap != NULL) {
++	ap = ap->next;		/* first option */
++	free(*app);		/* free the "--" word */
++	*app = NULL;		/* terminate addr list */
++    }
++    if (opts != NULL)
++	*opts = ap;
++    else if (ap != NULL)
++	free_wordlist(ap);
++    if (addrs != NULL)
++	*addrs = addr_list;
++    else if (addr_list != NULL)
++	free_wordlist(addr_list);
++
++    return best_flag;
++}
++
++
++int
++get_eaptls_secret(unit, client, server, clicertfile, servcertfile,
++		  cacertfile, pkfile, am_server)
++    int unit;
++    char *client;
++    char *server;
++    char *clicertfile;
++    char *servcertfile;
++    char *cacertfile;
++    char *pkfile;
++    int am_server;
++{
++    FILE *fp;
++    int ret;
++    char *filename         = NULL;
++    struct wordlist *addrs = NULL;
++    struct wordlist *opts  = NULL;
++
++	/* in client mode the ca+cert+privkey can also be specified as options */
++	if (!am_server && cacert_file && cert_file && privkey_file )
++	{
++		strlcpy( clicertfile, cert_file, MAXWORDLEN );
++		strlcpy( cacertfile, cacert_file, MAXWORDLEN );
++		strlcpy( pkfile, privkey_file, MAXWORDLEN );
++		servcertfile[0] = '\0';
++	}
++	else
++	{
++		filename = (am_server ? _PATH_EAPTLSSERVFILE : _PATH_EAPTLSCLIFILE);
++		addrs = NULL;
++
++		fp = fopen(filename, "r");
++		if (fp == NULL)
++		{
++			error("Can't open eap-tls secret file %s: %m", filename);
++			return 0;
++   	 	}
++
++		check_access(fp, filename);
++
++		ret = scan_authfile_eaptls(fp, client, server, clicertfile, servcertfile,
++				cacertfile, pkfile, &addrs, &opts, filename, 0);
++
++		fclose(fp);
++
++		if (ret < 0) return 0;
++	}
++
++    if (eaptls_passwd_hook)
++    {
++		dbglog( "Calling eaptls password hook" );
++		if ( (*eaptls_passwd_hook)(pkfile, passwd) < 0)
++		{
++	   		 error("Unable to obtain EAP-TLS password for %s (%s) from plugin", 
++				client, pkfile);
++		    return 0;
++		}
++	}
++    if (am_server)
++		set_allowed_addrs(unit, addrs, opts);
++    else if (opts != NULL)
++		free_wordlist(opts);
++    if (addrs != NULL)
++		free_wordlist(addrs);
++
++    return 1;
++}
++#endif
++
+Index: b/pppd/ccp.c
+===================================================================
+--- a/pppd/ccp.c
++++ b/pppd/ccp.c
+@@ -540,6 +540,9 @@ ccp_resetci(f)
+     if (go->mppe) {
+ 	ccp_options *ao = &ccp_allowoptions[f->unit];
+ 	int auth_mschap_bits = auth_done[f->unit];
++#ifdef USE_EAPTLS
++	int auth_eap_bits = auth_done[f->unit];
++#endif
+ 	int numbits;
+ 
+ 	/*
+@@ -567,8 +570,23 @@ ccp_resetci(f)
+ 	    lcp_close(f->unit, "MPPE required but not available");
+ 	    return;
+ 	}
++
++#ifdef USE_EAPTLS
++    /*
++     * MPPE is also possible in combination with EAP-TLS.
++     * It is not possible to detect if we're doing EAP or EAP-TLS
++     * at this stage, hence we accept all forms of EAP. If TLS is
++     * not used then the MPPE keys will not be derived anyway.
++     */
++	/* Leave only the eap auth bits set */
++	auth_eap_bits &= (EAP_WITHPEER | EAP_PEER );
++
++	if ((numbits == 0) && (auth_eap_bits == 0)) {
++	    error("MPPE required, but MS-CHAP[v2] nor EAP-TLS auth are performed.");
++#else
+ 	if (!numbits) {
+-	    error("MPPE required, but MS-CHAP[v2] auth not performed.");
++		error("MPPE required, but MS-CHAP[v2] auth not performed.");
++#endif
+ 	    lcp_close(f->unit, "MPPE required but not available");
+ 	    return;
+ 	}
+Index: b/pppd/chap-md5.c
+===================================================================
+--- a/pppd/chap-md5.c
++++ b/pppd/chap-md5.c
+@@ -36,7 +36,11 @@
+ #include "chap-new.h"
+ #include "chap-md5.h"
+ #include "magic.h"
++#ifdef USE_EAPTLS
++#include "eap-tls.h"
++#else
+ #include "md5.h"
++#endif /* USE_EAPTLS */
+ 
+ #define MD5_HASH_SIZE		16
+ #define MD5_MIN_CHALLENGE	16
+Index: b/pppd/eap-tls.c
+===================================================================
+--- /dev/null
++++ b/pppd/eap-tls.c
+@@ -0,0 +1,1212 @@
++/*
++ * eap-tls.c - EAP-TLS implementation for PPP
++ *
++ * Copyright (c) Beniamino Galvani 2005 All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ *
++ * 1. Redistributions of source code must retain the above copyright
++ *    notice, this list of conditions and the following disclaimer.
++ *
++ * 2. Redistributions in binary form must reproduce the above copyright
++ *    notice, this list of conditions and the following disclaimer in
++ *    the documentation and/or other materials provided with the
++ *    distribution.
++ *
++ * 3. The name(s) of the authors of this software must not be used to
++ *    endorse or promote products derived from this software without
++ *    prior written permission.
++ *
++ * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
++ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
++ * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
++ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
++ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
++ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
++ *
++ */
++
++#include <string.h>
++#include <unistd.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <fcntl.h>
++
++#include <openssl/conf.h>
++#include <openssl/engine.h>
++#include <openssl/hmac.h>
++#include <openssl/err.h>
++#include <openssl/x509v3.h>
++
++#include "pppd.h"
++#include "eap.h"
++#include "eap-tls.h"
++#include "fsm.h"
++#include "lcp.h"
++#include "pathnames.h"
++
++/* The openssl configuration file and engines can be loaded only once */
++static CONF   *ssl_config  = NULL;
++static ENGINE *cert_engine = NULL;
++static ENGINE *pkey_engine = NULL;
++
++#ifdef MPPE
++
++/*
++ * TLS PRF from RFC 2246
++ */
++static void P_hash(const EVP_MD *evp_md,
++		   const unsigned char *secret, unsigned int secret_len,
++		   const unsigned char *seed,   unsigned int seed_len,
++		   unsigned char *out, unsigned int out_len)
++{
++	HMAC_CTX ctx_a, ctx_out;
++	unsigned char a[HMAC_MAX_MD_CBLOCK];
++	unsigned int size;
++
++	HMAC_CTX_init(&ctx_a);
++	HMAC_CTX_init(&ctx_out);
++	HMAC_Init_ex(&ctx_a, secret, secret_len, evp_md, NULL);
++	HMAC_Init_ex(&ctx_out, secret, secret_len, evp_md, NULL);
++
++	size = HMAC_size(&ctx_out);
++
++	/* Calculate A(1) */
++	HMAC_Update(&ctx_a, seed, seed_len);
++	HMAC_Final(&ctx_a, a, NULL);
++
++	while (1) {
++		/* Calculate next part of output */
++		HMAC_Update(&ctx_out, a, size);
++		HMAC_Update(&ctx_out, seed, seed_len);
++
++		/* Check if last part */
++		if (out_len < size) {
++			HMAC_Final(&ctx_out, a, NULL);
++			memcpy(out, a, out_len);
++			break;
++		}
++
++		/* Place digest in output buffer */
++		HMAC_Final(&ctx_out, out, NULL);
++		HMAC_Init_ex(&ctx_out, NULL, 0, NULL, NULL);
++		out += size;
++		out_len -= size;
++
++		/* Calculate next A(i) */
++		HMAC_Init_ex(&ctx_a, NULL, 0, NULL, NULL);
++		HMAC_Update(&ctx_a, a, size);
++		HMAC_Final(&ctx_a, a, NULL);
++	}
++
++	HMAC_CTX_cleanup(&ctx_a);
++	HMAC_CTX_cleanup(&ctx_out);
++	memset(a, 0, sizeof(a));
++}
++
++static void PRF(const unsigned char *secret, unsigned int secret_len,
++		const unsigned char *seed,   unsigned int seed_len,
++		unsigned char *out, unsigned char *buf, unsigned int out_len)
++{
++        unsigned int i;
++        unsigned int len = (secret_len + 1) / 2;
++	const unsigned char *s1 = secret;
++	const unsigned char *s2 = secret + (secret_len - len);
++
++	P_hash(EVP_md5(),  s1, len, seed, seed_len, out, out_len);
++	P_hash(EVP_sha1(), s2, len, seed, seed_len, buf, out_len);
++
++	for (i=0; i < out_len; i++) {
++	        out[i] ^= buf[i];
++	}
++}
++
++#define EAPTLS_MPPE_KEY_LEN     32
++
++/*
++ *  Generate keys according to RFC 2716 and add to reply
++ */
++void eaptls_gen_mppe_keys(struct eaptls_session *ets, const char *prf_label,
++                          int client)
++{
++    unsigned char out[4*EAPTLS_MPPE_KEY_LEN], buf[4*EAPTLS_MPPE_KEY_LEN];
++    unsigned char seed[64 + 2*SSL3_RANDOM_SIZE];
++    unsigned char *p = seed;
++	SSL			  *s = ets->ssl;
++    size_t prf_size;
++
++    prf_size = strlen(prf_label);
++
++    memcpy(p, prf_label, prf_size);
++    p += prf_size;
++
++    memcpy(p, s->s3->client_random, SSL3_RANDOM_SIZE);
++    p += SSL3_RANDOM_SIZE;
++    prf_size += SSL3_RANDOM_SIZE;
++
++    memcpy(p, s->s3->server_random, SSL3_RANDOM_SIZE);
++    prf_size += SSL3_RANDOM_SIZE;
++
++    PRF(s->session->master_key, s->session->master_key_length,
++        seed, prf_size, out, buf, sizeof(out));
++
++    /* 
++     * We now have the master send and receive keys.
++     * From these, generate the session send and receive keys.
++     * (see RFC3079 / draft-ietf-pppext-mppe-keys-03.txt for details)
++     */
++    if (client)
++    {
++	    p = out;
++		BCOPY( p, mppe_send_key, sizeof(mppe_send_key) );
++		p += EAPTLS_MPPE_KEY_LEN;
++    	BCOPY( p, mppe_recv_key, sizeof(mppe_recv_key) );
++    }
++    else
++    {
++	    p = out;
++    	BCOPY( p, mppe_recv_key, sizeof(mppe_recv_key) );
++		p += EAPTLS_MPPE_KEY_LEN;
++		BCOPY( p, mppe_send_key, sizeof(mppe_send_key) );
++    }
++
++    mppe_keys_set = 1;
++}
++
++#endif
++
++void log_ssl_errors( void )
++{
++	unsigned long ssl_err = ERR_get_error();
++
++    if (ssl_err != 0)
++		dbglog("EAP-TLS SSL error stack:");
++	while (ssl_err != 0) {
++		dbglog( ERR_error_string( ssl_err, NULL ) );
++		ssl_err = ERR_get_error();
++	}
++}
++
++
++int password_callback (char *buf, int size, int rwflag, void *u)
++{
++	if (buf)
++	{
++		strncpy (buf, passwd, size);
++		return strlen (buf);
++	}
++	return 0;
++}
++
++
++CONF *eaptls_ssl_load_config( void )
++{
++    CONF        *config;
++    int          ret_code;
++    long         error_line = 33;
++
++    config = NCONF_new( NULL );
++	dbglog( "Loading OpenSSL config file" );
++    ret_code = NCONF_load( config, _PATH_OPENSSLCONFFILE, &error_line );
++    if (ret_code == 0)
++    {
++        warn( "EAP-TLS: Error in OpenSSL config file %s at line %d", _PATH_OPENSSLCONFFILE, error_line );
++        NCONF_free( config );
++        config = NULL;
++        ERR_clear_error();
++    }
++
++	dbglog( "Loading OpenSSL built-ins" );
++    ENGINE_load_builtin_engines();
++    OPENSSL_load_builtin_modules();
++   
++	dbglog( "Loading OpenSSL configured modules" );
++    if (CONF_modules_load( config, NULL, 0 ) <= 0 )
++    {
++        warn( "EAP-TLS: Error loading OpenSSL modules" );
++	    log_ssl_errors();
++        config = NULL;
++    }
++
++    return config;
++}
++
++ENGINE *eaptls_ssl_load_engine( char *engine_name )
++{
++	ENGINE      *e = NULL;
++
++	dbglog( "Enabling OpenSSL auto engines" );
++	ENGINE_register_all_complete();
++
++	dbglog( "Loading OpenSSL '%s' engine support", engine_name );
++	e = ENGINE_by_id( engine_name );
++    if (!e) 
++	{
++		dbglog( "EAP-TLS: Cannot load '%s' engine support, trying 'dynamic'", engine_name );
++		e = ENGINE_by_id( "dynamic" );
++		if (e)
++		{
++			if (!ENGINE_ctrl_cmd_string(e, "SO_PATH", engine_name, 0)
++   	         || !ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0))
++			{
++				warn( "EAP-TLS: Error loading dynamic engine '%s'", engine_name );
++		        log_ssl_errors();
++				ENGINE_free(e);
++				e = NULL;
++			}
++		}
++		else
++		{
++			warn( "EAP-TLS: Cannot load dynamic engine support" );
++		}
++	}
++
++    if (e)
++	{
++		dbglog( "Initialising engine" );
++		if(!ENGINE_set_default(e, ENGINE_METHOD_ALL))
++		{
++			warn( "EAP-TLS: Cannot use that engine" );
++			log_ssl_errors();
++			ENGINE_free(e);
++			e = NULL;
++		}
++	}
++
++    return e;
++}
++
++/*
++ * Initialize the SSL stacks and tests if certificates, key and crl
++ * for client or server use can be loaded.
++ */
++SSL_CTX *eaptls_init_ssl(int init_server, char *cacertfile,
++			char *certfile, char *peer_certfile, char *privkeyfile)
++{
++	char		*cert_engine_name = NULL;
++	char		*cert_identifier = NULL;
++	char		*pkey_engine_name = NULL;
++	char		*pkey_identifier = NULL;
++	SSL_CTX		*ctx;
++	X509_STORE	*certstore;
++	X509_LOOKUP	*lookup;
++	X509		*tmp;
++
++	/*
++	 * Without these can't continue 
++	 */
++	if (!cacertfile[0])
++    {
++		error("EAP-TLS: CA certificate missing");
++		return NULL;
++    }
++
++	if (!certfile[0])
++    {
++		error("EAP-TLS: User certificate missing");
++		return NULL;
++    }
++
++	if (!privkeyfile[0])
++    {
++		error("EAP-TLS: User private key missing");
++		return NULL;
++    }
++
++	SSL_library_init();
++	SSL_load_error_strings();
++
++	ctx = SSL_CTX_new(TLSv1_method());
++
++	if (!ctx) {
++		error("EAP-TLS: Cannot initialize SSL CTX context");
++		goto fail;
++	}
++
++	/* if the certificate filename is of the form engine:id. e.g.
++		pkcs11:12345
++	   then we try to load and use this engine.
++	   If the certificate filename starts with a / or . then we
++	   ALWAYS assume it is a file and not an engine/pkcs11 identifier
++	 */
++	if ( index( certfile, '/' ) == NULL && index( certfile, '.') == NULL )
++	{
++		cert_identifier = index( certfile, ':' );
++
++		if (cert_identifier)
++		{
++			cert_engine_name = certfile;
++			*cert_identifier = '\0';
++			cert_identifier++;
++
++			dbglog( "Found certificate engine '%s'", cert_engine_name );
++			dbglog( "Found certificate identifier '%s'", cert_identifier );
++		}
++	}
++
++	/* if the privatekey filename is of the form engine:id. e.g.
++		pkcs11:12345
++	   then we try to load and use this engine.
++	   If the privatekey filename starts with a / or . then we
++	   ALWAYS assume it is a file and not an engine/pkcs11 identifier
++	 */
++	if ( index( privkeyfile, '/' ) == NULL && index( privkeyfile, '.') == NULL )
++	{
++		pkey_identifier = index( privkeyfile, ':' );
++
++		if (pkey_identifier)
++		{
++			pkey_engine_name = privkeyfile;
++			*pkey_identifier = '\0';
++			pkey_identifier++;
++
++			dbglog( "Found privatekey engine '%s'", pkey_engine_name );
++			dbglog( "Found privatekey identifier '%s'", pkey_identifier );
++		}
++	}
++
++	if (cert_identifier && pkey_identifier)
++	{
++		if (strlen( cert_identifier ) == 0)
++		{
++			if (strlen( pkey_identifier ) == 0)
++				error( "EAP-TLS: both the certificate and privatekey identifiers are missing!" );
++			else
++			{
++				dbglog( "Substituting privatekey identifier for certificate identifier" );
++				cert_identifier = pkey_identifier;
++			}
++		}
++		else
++		{
++			if (strlen( pkey_identifier ) == 0)
++			{
++				dbglog( "Substituting certificate identifier for privatekey identifier" );
++				pkey_identifier = cert_identifier;
++			}
++		}
++
++	}
++
++	/* load the openssl config file only once */
++	if (!ssl_config)
++	{
++		if (cert_engine_name || pkey_engine_name)
++			ssl_config = eaptls_ssl_load_config();
++
++		if (ssl_config && cert_engine_name)
++			cert_engine = eaptls_ssl_load_engine( cert_engine_name );
++
++		if (ssl_config && pkey_engine_name)
++		{
++			/* don't load the same engine twice */
++			if ( cert_engine && strcmp( cert_engine_name, pkey_engine_name) == 0 )
++				pkey_engine = cert_engine;
++			else
++				pkey_engine = eaptls_ssl_load_engine( pkey_engine_name );
++		}
++	}
++
++    SSL_CTX_set_default_passwd_cb (ctx, password_callback);
++
++	if (!SSL_CTX_load_verify_locations(ctx, cacertfile, NULL))
++	{
++		error("EAP-TLS: Cannot load or verify CA file %s", cacertfile);
++		goto fail;
++	}
++
++    if (init_server)
++		SSL_CTX_set_client_CA_list(ctx, SSL_load_client_CA_file(cacertfile));
++
++	if (cert_engine)
++	{
++		struct
++		{
++			const char *s_slot_cert_id;
++			X509 *cert;
++		} cert_info;
++
++		cert_info.s_slot_cert_id = cert_identifier;
++		cert_info.cert = NULL;
++		
++		if (!ENGINE_ctrl_cmd( cert_engine, "LOAD_CERT_CTRL", 0, &cert_info, NULL, 0 ) )
++		{
++			error( "EAP-TLS: Error loading certificate with id '%s' from engine", cert_identifier );
++			goto fail;
++		}
++
++		if (cert_info.cert)
++		{
++		    dbglog( "Got the certificate, adding it to SSL context" );
++			dbglog( "subject = %s", X509_NAME_oneline( X509_get_subject_name( cert_info.cert ), NULL, 0 ) );
++			if (SSL_CTX_use_certificate(ctx, cert_info.cert) <= 0)
++			{
++				error("EAP-TLS: Cannot use PKCS11 certificate %s", cert_identifier);
++				goto fail;
++			}
++		}
++		else
++		{
++			warn("EAP-TLS: Cannot load PKCS11 key %s", cert_identifier);
++			log_ssl_errors();
++		}
++	}
++	else
++	{
++		if (!SSL_CTX_use_certificate_file(ctx, certfile, SSL_FILETYPE_PEM))
++		{
++			error( "EAP-TLS: Cannot use public certificate %s", certfile );
++			goto fail;
++		}
++	}
++
++	if (pkey_engine)
++	{
++		EVP_PKEY   *pkey = NULL;
++		PW_CB_DATA  cb_data;
++
++		cb_data.password = passwd;
++		cb_data.prompt_info = pkey_identifier;
++
++		dbglog( "Loading private key '%s' from engine", pkey_identifier );
++		pkey = ENGINE_load_private_key(pkey_engine, pkey_identifier, NULL, &cb_data);
++		if (pkey)
++		{
++		    dbglog( "Got the private key, adding it to SSL context" );
++			if (SSL_CTX_use_PrivateKey(ctx, pkey) <= 0)
++			{
++				error("EAP-TLS: Cannot use PKCS11 key %s", pkey_identifier);
++				goto fail;
++			}
++		}
++		else
++		{
++			warn("EAP-TLS: Cannot load PKCS11 key %s", pkey_identifier);
++			log_ssl_errors();
++		}
++	}
++	else
++	{
++		if (!SSL_CTX_use_PrivateKey_file(ctx, privkeyfile, SSL_FILETYPE_PEM))
++		{ 
++			error("EAP-TLS: Cannot use private key %s", privkeyfile);
++			goto fail;
++		}
++	}
++
++	if (SSL_CTX_check_private_key(ctx) != 1) {
++		error("EAP-TLS: Private key %s fails security check", privkeyfile);
++		goto fail;
++	}
++
++    /* Explicitly set the NO_TICKETS flag to support Win7/Win8 clients */
++	SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3
++#ifdef SSL_OP_NO_TICKET
++    | SSL_OP_NO_TICKET
++#endif
++);
++	SSL_CTX_set_verify_depth(ctx, 5);
++	SSL_CTX_set_verify(ctx,
++			   SSL_VERIFY_PEER |
++			   SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
++			   &ssl_verify_callback);
++
++	if (crl_dir) {
++		if (!(certstore = SSL_CTX_get_cert_store(ctx))) {
++			error("EAP-TLS: Failed to get certificate store");
++			goto fail;
++		}
++
++		if (!(lookup =
++		     X509_STORE_add_lookup(certstore, X509_LOOKUP_hash_dir()))) {
++			error("EAP-TLS: Store lookup for CRL failed");
++
++			goto fail;
++		}
++
++		X509_LOOKUP_add_dir(lookup, crl_dir, X509_FILETYPE_PEM);
++		X509_STORE_set_flags(certstore, X509_V_FLAG_CRL_CHECK);
++	}
++
++    if (crl_file) {
++        FILE     *fp  = NULL;
++        X509_CRL *crl = NULL;
++
++        fp = fopen(crl_file, "r");
++        if (!fp) {
++            error("EAP-TLS: Cannot open CRL file '%s'", crl_file);
++            goto fail;
++        }
++
++        crl = PEM_read_X509_CRL(fp, NULL, NULL, NULL);
++        if (!crl) {
++            error("EAP-TLS: Cannot read CRL file '%s'", crl_file);
++            goto fail;
++        }
++
++		if (!(certstore = SSL_CTX_get_cert_store(ctx))) {
++			error("EAP-TLS: Failed to get certificate store");
++			goto fail;
++		}
++        if (!X509_STORE_add_crl(certstore, crl)) {
++            error("EAP-TLS: Cannot add CRL to certificate store");
++            goto fail;
++        }
++		X509_STORE_set_flags(certstore, X509_V_FLAG_CRL_CHECK);
++
++    }
++
++	/*
++	 * If a peer certificate file was specified, it must be valid, else fail 
++	 */
++	if (peer_certfile[0]) {
++		if (!(tmp = get_X509_from_file(peer_certfile))) {
++			error("EAP-TLS: Error loading client certificate from file %s",
++			     peer_certfile);
++			goto fail;
++		}
++		X509_free(tmp);
++	}
++
++	return ctx;
++
++fail:
++	log_ssl_errors();
++	SSL_CTX_free(ctx);
++	return NULL;
++}
++
++/*
++ * Determine the maximum packet size by looking at the LCP handshake
++ */
++
++int eaptls_get_mtu(int unit)
++{
++	int mtu, mru;
++
++	lcp_options *wo = &lcp_wantoptions[unit];
++	lcp_options *go = &lcp_gotoptions[unit];
++	lcp_options *ho = &lcp_hisoptions[unit];
++	lcp_options *ao = &lcp_allowoptions[unit];
++
++	mtu = ho->neg_mru? ho->mru: PPP_MRU;
++	mru = go->neg_mru? MAX(wo->mru, go->mru): PPP_MRU;
++    mtu = MIN(MIN(mtu, mru), ao->mru)- PPP_HDRLEN - 10;
++
++	dbglog("MTU = %d", mtu);
++ 	return mtu;
++}
++
++
++/*
++ * Init the ssl handshake (server mode)
++ */
++int eaptls_init_ssl_server(eap_state * esp)
++{
++	struct eaptls_session *ets;
++	char servcertfile[MAXWORDLEN];
++	char clicertfile[MAXWORDLEN];
++	char cacertfile[MAXWORDLEN];
++	char pkfile[MAXWORDLEN];
++	/*
++	 * Allocate new eaptls session 
++	 */
++	esp->es_server.ea_session = malloc(sizeof(struct eaptls_session));
++	if (!esp->es_server.ea_session)
++		fatal("Allocation error");
++	ets = esp->es_server.ea_session;
++
++	if (!esp->es_server.ea_peer) {
++		error("EAP-TLS: Error: client name not set (BUG)");
++		return 0;
++	}
++
++	strncpy(ets->peer, esp->es_server.ea_peer, MAXWORDLEN);
++
++	dbglog( "getting eaptls secret" );
++	if (!get_eaptls_secret(esp->es_unit, esp->es_server.ea_peer,
++			       esp->es_server.ea_name, clicertfile,
++			       servcertfile, cacertfile, pkfile, 1)) {
++		error( "EAP-TLS: Cannot get secret/password for client \"%s\", server \"%s\"",
++				esp->es_server.ea_peer, esp->es_server.ea_name );
++		return 0;
++	}
++
++	ets->mtu = eaptls_get_mtu(esp->es_unit);
++
++	ets->ctx = eaptls_init_ssl(1, cacertfile, servcertfile, clicertfile, pkfile);
++	if (!ets->ctx)
++		goto fail;
++
++	if (!(ets->ssl = SSL_new(ets->ctx)))
++		goto fail;
++
++	/*
++	 * Set auto-retry to avoid timeouts on BIO_read
++	 */
++	SSL_set_mode(ets->ssl, SSL_MODE_AUTO_RETRY);
++
++	/*
++	 * Initialize the BIOs we use to read/write to ssl engine 
++	 */
++	ets->into_ssl = BIO_new(BIO_s_mem());
++	ets->from_ssl = BIO_new(BIO_s_mem());
++	SSL_set_bio(ets->ssl, ets->into_ssl, ets->from_ssl);
++
++	SSL_set_msg_callback(ets->ssl, ssl_msg_callback);
++	SSL_set_msg_callback_arg(ets->ssl, ets);
++
++	/*
++	 * Attach the session struct to the connection, so we can later
++	 * retrieve it when doing certificate verification
++	 */
++	SSL_set_ex_data(ets->ssl, 0, ets);
++
++	SSL_set_accept_state(ets->ssl);
++
++	ets->data = NULL;
++	ets->datalen = 0;
++	ets->alert_sent = 0;
++	ets->alert_recv = 0;
++
++	/*
++	 * If we specified the client certificate file, store it in ets->peercertfile,
++	 * so we can check it later in ssl_verify_callback()
++	 */
++	if (clicertfile[0])
++		strncpy(&ets->peercertfile[0], clicertfile, MAXWORDLEN);
++	else
++		ets->peercertfile[0] = 0;
++
++	return 1;
++
++fail:
++	SSL_CTX_free(ets->ctx);
++	return 0;
++}
++
++/*
++ * Init the ssl handshake (client mode)
++ */
++int eaptls_init_ssl_client(eap_state * esp)
++{
++	struct eaptls_session *ets;
++	char servcertfile[MAXWORDLEN];
++	char clicertfile[MAXWORDLEN];
++	char cacertfile[MAXWORDLEN];
++	char pkfile[MAXWORDLEN];
++
++	/*
++	 * Allocate new eaptls session 
++	 */
++	esp->es_client.ea_session = malloc(sizeof(struct eaptls_session));
++	if (!esp->es_client.ea_session)
++		fatal("Allocation error");
++	ets = esp->es_client.ea_session;
++
++	/*
++	 * If available, copy server name in ets; it will be used in cert
++	 * verify 
++	 */
++	if (esp->es_client.ea_peer)
++		strncpy(ets->peer, esp->es_client.ea_peer, MAXWORDLEN);
++	else
++		ets->peer[0] = 0;
++	
++	ets->mtu = eaptls_get_mtu(esp->es_unit);
++
++	dbglog( "calling get_eaptls_secret" );
++	if (!get_eaptls_secret(esp->es_unit, esp->es_client.ea_name,
++			       ets->peer, clicertfile,
++			       servcertfile, cacertfile, pkfile, 0)) {
++		error( "EAP-TLS: Cannot get secret/password for client \"%s\", server \"%s\"",
++				esp->es_client.ea_name, ets->peer );
++		return 0;
++	}
++
++	dbglog( "calling eaptls_init_ssl" );
++	ets->ctx = eaptls_init_ssl(0, cacertfile, clicertfile, servcertfile, pkfile);
++	if (!ets->ctx)
++		goto fail;
++
++	ets->ssl = SSL_new(ets->ctx);
++
++	if (!ets->ssl)
++		goto fail;
++
++	/*
++	 * Initialize the BIOs we use to read/write to ssl engine 
++	 */
++	dbglog( "Initializing SSL BIOs" );
++	ets->into_ssl = BIO_new(BIO_s_mem());
++	ets->from_ssl = BIO_new(BIO_s_mem());
++	SSL_set_bio(ets->ssl, ets->into_ssl, ets->from_ssl);
++
++	SSL_set_msg_callback(ets->ssl, ssl_msg_callback);
++	SSL_set_msg_callback_arg(ets->ssl, ets);
++
++	/*
++	 * Attach the session struct to the connection, so we can later
++	 * retrieve it when doing certificate verification
++	 */
++	SSL_set_ex_data(ets->ssl, 0, ets);
++
++	SSL_set_connect_state(ets->ssl);
++
++	ets->data = NULL;
++	ets->datalen = 0;
++	ets->alert_sent = 0;
++	ets->alert_recv = 0;
++
++	/*
++	 * If we specified the server certificate file, store it in
++	 * ets->peercertfile, so we can check it later in
++	 * ssl_verify_callback() 
++	 */
++	if (servcertfile[0])
++		strncpy(ets->peercertfile, servcertfile, MAXWORDLEN);
++	else
++		ets->peercertfile[0] = 0;
++
++	return 1;
++
++fail:
++	dbglog( "eaptls_init_ssl_client: fail" );
++	SSL_CTX_free(ets->ctx);
++	return 0;
++
++}
++
++void eaptls_free_session(struct eaptls_session *ets)
++{
++	if (ets->ssl)
++		SSL_free(ets->ssl);
++
++	if (ets->ctx)
++		SSL_CTX_free(ets->ctx);
++
++	free(ets);
++}
++
++/*
++ * Handle a received packet, reassembling fragmented messages and
++ * passing them to the ssl engine
++ */
++int eaptls_receive(struct eaptls_session *ets, u_char * inp, int len)
++{
++	u_char flags;
++	u_int tlslen;
++	u_char dummy[65536];
++
++	GETCHAR(flags, inp);
++	len--;
++
++    if (flags & EAP_TLS_FLAGS_LI && !ets->data) {
++ 
++		/*
++		 * This is the first packet of a message
++		*/
++ 
++		GETLONG(tlslen, inp);
++		len -= 4;
++
++		if (tlslen > EAP_TLS_MAX_LEN) {
++			error("Error: tls message length > %d, truncated",
++				EAP_TLS_MAX_LEN);
++			tlslen = EAP_TLS_MAX_LEN;
++		}
++
++		/*
++		 * Allocate memory for the whole message
++		*/
++		ets->data = malloc(tlslen);
++		if (!ets->data)
++			fatal("EAP TLS: allocation error\n");
++
++		ets->datalen = 0;
++		ets->tlslen = tlslen;
++
++	}
++	else if (flags & EAP_TLS_FLAGS_LI && ets->data) {
++		/*
++		 * Non first with LI (strange...)
++		*/
++ 
++		GETLONG(tlslen, inp);
++		len -= 4;
++ 
++	}
++	else if (!ets->data) {
++		/*
++		 * A non fragmented message without LI flag
++		*/
++ 
++		ets->data = malloc(len);
++		if (!ets->data)
++			fatal("EAP TLS: allocation error\n");
++ 
++		ets->datalen = 0;
++		ets->tlslen = len;
++	}
++
++	if (flags & EAP_TLS_FLAGS_MF)
++		ets->frag = 1;
++	else
++		ets->frag = 0;
++
++	if (len + ets->datalen > ets->tlslen) {
++		warn("EAP TLS: received data > TLS message length");
++		return 1;
++	}
++
++	BCOPY(inp, ets->data + ets->datalen, len);
++	ets->datalen += len;
++
++	if (!ets->frag) {
++
++		/*
++		 * If we have the whole message, pass it to ssl 
++		 */
++
++		if (ets->datalen != ets->tlslen) {
++			warn("EAP TLS: received data != TLS message length");
++			return 1;
++		}
++
++		if (BIO_write(ets->into_ssl, ets->data, ets->datalen) == -1)
++			log_ssl_errors();
++
++		SSL_read(ets->ssl, dummy, 65536);
++
++		free(ets->data);
++		ets->data = NULL;
++		ets->datalen = 0;
++	}
++
++	return 0;
++}
++
++/*
++ * Return an eap-tls packet in outp.
++ * A TLS message read from the ssl engine is buffered in ets->data.
++ * At each call we control if there is buffered data and send a 
++ * packet of mtu bytes.
++ */
++int eaptls_send(struct eaptls_session *ets, u_char ** outp)
++{
++	bool first = 0;
++	int size;
++	u_char fromtls[65536];
++	int res;
++	u_char *start;
++
++	start = *outp;
++
++	if (!ets->data) {
++
++		if(!ets->alert_sent)
++			SSL_read(ets->ssl, fromtls, 65536);
++
++		/*
++		 * Read from ssl 
++		 */
++		if ((res = BIO_read(ets->from_ssl, fromtls, 65536)) == -1)
++			fatal("No data from BIO_read");
++
++		ets->datalen = res;
++
++		ets->data = malloc(ets->datalen);
++		BCOPY(fromtls, ets->data, ets->datalen);
++
++		ets->offset = 0;
++		first = 1;
++
++	}
++
++	size = ets->datalen - ets->offset;
++    
++	if (size > ets->mtu) {
++		size = ets->mtu;
++		ets->frag = 1;
++	} else
++		ets->frag = 0;
++
++	PUTCHAR(EAPT_TLS, *outp);
++
++	/*
++	 * Set right flags and length if necessary 
++	 */
++	if (ets->frag && first) {
++		PUTCHAR(EAP_TLS_FLAGS_LI | EAP_TLS_FLAGS_MF, *outp);
++		PUTLONG(ets->datalen, *outp);
++	} else if (ets->frag) {
++		PUTCHAR(EAP_TLS_FLAGS_MF, *outp);
++	} else
++		PUTCHAR(0, *outp);
++
++	/*
++	 * Copy the data in outp 
++	 */
++	BCOPY(ets->data + ets->offset, *outp, size);
++	INCPTR(size, *outp);
++
++	/*
++	 * Copy the packet in retransmission buffer 
++	 */
++	BCOPY(start, &ets->rtx[0], *outp - start);
++	ets->rtx_len = *outp - start;
++
++	ets->offset += size;
++
++	if (ets->offset >= ets->datalen) {
++
++		/*
++		 * The whole message has been sent 
++		 */
++
++		free(ets->data);
++		ets->data = NULL;
++		ets->datalen = 0;
++		ets->offset = 0;
++	}
++
++	return 0;
++}
++
++/*
++ * Get the sent packet from the retransmission buffer
++ */
++void eaptls_retransmit(struct eaptls_session *ets, u_char ** outp)
++{
++	BCOPY(ets->rtx, *outp, ets->rtx_len);
++	INCPTR(ets->rtx_len, *outp);
++}
++
++/*
++ * Verify a certificate.
++ * Most of the work (signatures and issuer attributes checking)
++ * is done by ssl; we check the CN in the peer certificate 
++ * against the peer name.
++ */
++int ssl_verify_callback(int preverify_ok, X509_STORE_CTX * ctx)
++{
++	char subject[256];
++	char cn_str[256];
++	X509 *peer_cert;
++	int err, depth;
++	int ok = preverify_ok;
++	SSL *ssl;
++	struct eaptls_session *ets;
++
++	peer_cert = X509_STORE_CTX_get_current_cert(ctx);
++	err = X509_STORE_CTX_get_error(ctx);
++	depth = X509_STORE_CTX_get_error_depth(ctx);
++
++	dbglog("certificate verify depth: %d", depth);
++
++    if (auth_required && !ok) {
++		X509_NAME_oneline(X509_get_subject_name(peer_cert),
++				  subject, 256);
++
++		X509_NAME_get_text_by_NID(X509_get_subject_name(peer_cert),
++					  NID_commonName, cn_str, 256);
++
++		dbglog("Certificate verification error:\n depth: %d CN: %s"
++		       "\n err: %d (%s)\n", depth, cn_str, err,
++		       X509_verify_cert_error_string(err));
++
++		return 0;
++	}
++
++	ssl = X509_STORE_CTX_get_ex_data(ctx,
++				       SSL_get_ex_data_X509_STORE_CTX_idx());
++
++	ets = (struct eaptls_session *)SSL_get_ex_data(ssl, 0);
++
++	if (ets == NULL) {
++		error("Error: SSL_get_ex_data returned NULL");
++		return 0;
++	}
++
++	log_ssl_errors();
++
++	if (!depth) {		/* This is the peer certificate */
++
++		X509_NAME_oneline(X509_get_subject_name(peer_cert),
++				  subject, 256);
++
++		X509_NAME_get_text_by_NID(X509_get_subject_name(peer_cert),
++					  NID_commonName, cn_str, 256);
++
++		/*
++		 * If acting as client and the name of the server wasn't specified
++		 * explicitely, we can't verify the server authenticity 
++		 */
++		if (!ets->peer[0]) {
++			warn("Peer name not specified: no check");
++			return 1;
++		}
++
++		/*
++		 * Check the CN 
++		 */
++		if (strcmp(cn_str, ets->peer)) {
++			error
++			    ("Certificate verification error: CN (%s) != peer_name (%s)",
++			     cn_str, ets->peer);
++			return 0;
++		}
++
++		warn("Certificate CN: %s , peer name %s", cn_str, ets->peer);
++
++		/*
++		 * If a peer certificate file was specified, here we check it 
++		 */
++		if (ets->peercertfile[0]) {
++			if (ssl_cmp_certs(&ets->peercertfile[0], peer_cert)
++			    != 0) {
++				error
++				    ("Peer certificate doesn't match stored certificate");
++				return 0;
++			}
++		}
++	}
++
++	return 1;
++}
++
++/*
++ * Compare a certificate with the one stored in a file
++ */
++int ssl_cmp_certs(char *filename, X509 * a)
++{
++	X509 *b;
++	int ret;
++
++	if (!(b = get_X509_from_file(filename)))
++		return 1;
++
++	ret = X509_cmp(a, b);
++	X509_free(b);
++
++	return ret;
++
++}
++
++X509 *get_X509_from_file(char *filename)
++{
++	FILE *fp;
++	X509 *ret;
++
++	if (!(fp = fopen(filename, "r")))
++		return NULL;
++
++	ret = PEM_read_X509(fp, NULL, NULL, NULL);
++
++	fclose(fp);
++
++	return ret;
++}
++
++/*
++ * Every sent & received message this callback function is invoked,
++ * so we know when alert messages have arrived or are sent and
++ * we can print debug information about TLS handshake.
++ */
++void
++ssl_msg_callback(int write_p, int version, int content_type,
++		 const void *buf, size_t len, SSL * ssl, void *arg)
++{
++	char string[256];
++	struct eaptls_session *ets = (struct eaptls_session *)arg;
++	unsigned char code;
++
++	if(write_p)
++		strcpy(string, " -> ");
++	else
++		strcpy(string, " <- ");
++
++	
++	switch(content_type) {
++
++	case SSL3_RT_ALERT:	
++		strcat(string, "Alert: ");	
++		code = ((const unsigned char *)buf)[1];
++
++		if (write_p) {
++			ets->alert_sent = 1;
++			ets->alert_sent_desc = code;
++		} else {
++			ets->alert_recv = 1;
++			ets->alert_recv_desc = code;
++		}
++
++		strcat(string, SSL_alert_desc_string_long(code));
++		break;
++
++	case SSL3_RT_CHANGE_CIPHER_SPEC:
++		strcat(string, "ChangeCipherSpec");
++		break;
++
++	case SSL3_RT_HANDSHAKE:
++
++		strcat(string, "Handshake: ");
++		code = ((const unsigned char *)buf)[0];
++
++		switch(code) {
++			case SSL3_MT_HELLO_REQUEST:
++				strcat(string,"Hello Request");
++				break;
++			case SSL3_MT_CLIENT_HELLO:
++				strcat(string,"Client Hello");
++				break;
++			case SSL3_MT_SERVER_HELLO:
++				strcat(string,"Server Hello");
++				break;
++#ifdef SSL3_MT_NEWSESSION_TICKET
++			case SSL3_MT_NEWSESSION_TICKET:
++				strcat(string,"New Session Ticket");
++				break;
++#endif
++			case SSL3_MT_CERTIFICATE:
++				strcat(string,"Certificate");
++				break;
++			case SSL3_MT_SERVER_KEY_EXCHANGE:
++				strcat(string,"Server Key Exchange");
++				break;
++			case SSL3_MT_CERTIFICATE_REQUEST:
++				strcat(string,"Certificate Request");
++				break;
++			case SSL3_MT_SERVER_DONE:
++				strcat(string,"Server Hello Done");
++								break;
++			case SSL3_MT_CERTIFICATE_VERIFY:
++				strcat(string,"Certificate Verify");
++				break;
++			case SSL3_MT_CLIENT_KEY_EXCHANGE:
++				strcat(string,"Client Key Exchange");
++				break;
++			case SSL3_MT_FINISHED:
++				strcat(string,"Finished");
++				break;
++
++			default:
++				sprintf( string, "Handshake: Unknown SSL3 code received: %d", code );
++		}
++		break;
++
++	default:
++		sprintf( string, "SSL message contains unknown content type: %d", content_type );
++		
++	}
++
++	/* Alert messages must always be displayed */
++	if(content_type == SSL3_RT_ALERT)
++		error("%s", string);
++	else
++		dbglog("%s", string);
++}
++
+Index: b/pppd/eap-tls.h
+===================================================================
+--- /dev/null
++++ b/pppd/eap-tls.h
+@@ -0,0 +1,107 @@
++/*
++ * eap-tls.h
++ *
++ * Copyright (c) Beniamino Galvani 2005 All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ *
++ * 1. Redistributions of source code must retain the above copyright
++ *    notice, this list of conditions and the following disclaimer.
++ *
++ * 2. Redistributions in binary form must reproduce the above copyright
++ *    notice, this list of conditions and the following disclaimer in
++ *    the documentation and/or other materials provided with the
++ *    distribution.
++ *
++ * 3. The name(s) of the authors of this software must not be used to
++ *    endorse or promote products derived from this software without
++ *    prior written permission.
++ *
++ * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
++ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
++ * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
++ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
++ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
++ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
++ *
++ */
++
++#ifndef __EAP_TLS_H__
++#define __EAP_TLS_H__
++
++#include "eap.h"
++
++#include <openssl/ssl.h>
++#include <openssl/bio.h>
++#include <openssl/md5.h>
++
++#define EAP_TLS_FLAGS_LI        128	/* length included flag */
++#define EAP_TLS_FLAGS_MF        64	/* more fragments flag */
++#define EAP_TLS_FLAGS_START     32	/* start flag */
++
++#define EAP_TLS_MAX_LEN         65536	/* max eap tls packet size */
++
++struct eaptls_session
++{
++	u_char *data;		/* buffered data */
++	int datalen;		/* buffered data len */
++	int offset;		/* from where to send */
++	int tlslen;		/* total length of tls data */
++	bool frag;		/* packet is fragmented */
++	SSL_CTX *ctx;
++	SSL *ssl;		/* ssl connection */
++	BIO *from_ssl;
++	BIO *into_ssl;
++	char peer[MAXWORDLEN];	/* peer name */
++	char peercertfile[MAXWORDLEN];
++	bool alert_sent;
++	u_char alert_sent_desc;
++	bool alert_recv;
++	u_char alert_recv_desc;
++	char rtx[65536];	/* retransmission buffer */
++	int rtx_len;
++	int mtu;		/* unit mtu */
++};
++
++typedef struct pw_cb_data
++{
++	const void *password;
++	const char *prompt_info;
++} PW_CB_DATA;
++
++
++int ssl_verify_callback(int, X509_STORE_CTX *);
++void ssl_msg_callback(int write_p, int version, int ct, const void *buf,
++		      size_t len, SSL * ssl, void *arg);
++
++X509 *get_X509_from_file(char *filename);
++int ssl_cmp_certs(char *filename, X509 * a);
++
++SSL_CTX *eaptls_init_ssl(int init_server, char *cacertfile,
++            char *certfile, char *peer_certfile, char *privkeyfile);
++int eaptls_init_ssl_server(eap_state * esp);
++int eaptls_init_ssl_client(eap_state * esp);
++void eaptls_free_session(struct eaptls_session *ets);
++
++int eaptls_receive(struct eaptls_session *ets, u_char * inp, int len);
++int eaptls_send(struct eaptls_session *ets, u_char ** outp);
++void eaptls_retransmit(struct eaptls_session *ets, u_char ** outp);
++
++int get_eaptls_secret(int unit, char *client, char *server,
++		      char *clicertfile, char *servcertfile, char *cacertfile,
++		      char *pkfile, int am_server);
++
++#ifdef MPPE
++#include "mppe.h"   /* MPPE_MAX_KEY_LEN */
++extern u_char mppe_send_key[MPPE_MAX_KEY_LEN];
++extern u_char mppe_recv_key[MPPE_MAX_KEY_LEN];
++extern int mppe_keys_set;
++
++void eaptls_gen_mppe_keys(struct eaptls_session *ets, const char *prf_label, int client);
++
++#endif
++
++#endif
+Index: b/pppd/eap.c
+===================================================================
+--- a/pppd/eap.c
++++ b/pppd/eap.c
+@@ -43,6 +43,11 @@
+  * Based on draft-ietf-pppext-eap-srp-03.txt.
+  */
+ 
++/*
++ * Modification by Beniamino Galvani, Mar 2005
++ * Implemented EAP-TLS authentication
++ */
++
+ #define RCSID	"$Id: eap.c,v 1.4 2004/11/09 22:39:25 paulus Exp $"
+ 
+ /*
+@@ -62,8 +67,12 @@
+ 
+ #include "pppd.h"
+ #include "pathnames.h"
+-#include "md5.h"
+ #include "eap.h"
++#ifdef USE_EAPTLS
++#include "eap-tls.h"
++#else
++#include "md5.h"
++#endif /* USE_EAPTLS */
+ 
+ #ifdef USE_SRP
+ #include <t_pwd.h>
+@@ -209,6 +218,9 @@ int unit;
+ 	esp->es_server.ea_id = (u_char)(drand48() * 0x100);
+ 	esp->es_client.ea_timeout = EAP_DEFREQTIME;
+ 	esp->es_client.ea_maxrequests = EAP_DEFALLOWREQ;
++#ifdef USE_EAPTLS
++	esp->es_client.ea_using_eaptls = 0;
++#endif /* USE_EAPTLS */
+ }
+ 
+ /*
+@@ -436,8 +448,16 @@ int status;
+ 	u_char vals[2];
+ 	struct b64state bs;
+ #endif /* USE_SRP */
++#ifdef USE_EAPTLS
++	struct eaptls_session *ets;
++	int secret_len;
++	char secret[MAXWORDLEN];
++#endif /* USE_EAPTLS */
+ 
+ 	esp->es_server.ea_timeout = esp->es_savedtime;
++#ifdef USE_EAPTLS
++	esp->es_server.ea_prev_state = esp->es_server.ea_state;
++#endif /* USE_EAPTLS */
+ 	switch (esp->es_server.ea_state) {
+ 	case eapBadAuth:
+ 		return;
+@@ -562,9 +582,79 @@ int status;
+ 			break;
+ 		}
+ #endif /* USE_SRP */
++#ifdef USE_EAPTLS
++                if (!get_secret(esp->es_unit, esp->es_server.ea_peer,
++                    esp->es_server.ea_name, secret, &secret_len, 1)) {
++
++			esp->es_server.ea_state = eapTlsStart;
++			break;
++		}
++#endif /* USE_EAPTLS */
++
+ 		esp->es_server.ea_state = eapMD5Chall;
+ 		break;
+ 
++#ifdef USE_EAPTLS
++	case eapTlsStart:
++		/* Initialize ssl session */
++		if(!eaptls_init_ssl_server(esp)) {
++			esp->es_server.ea_state = eapBadAuth;
++			break;
++		}
++
++		esp->es_server.ea_state = eapTlsRecv;
++		break;
++
++	case eapTlsRecv:
++		ets = (struct eaptls_session *) esp->es_server.ea_session;
++
++		if(ets->alert_sent) {
++			esp->es_server.ea_state = eapTlsSendAlert;
++			break;
++		}
++
++		if (status) {
++			esp->es_server.ea_state = eapBadAuth;
++			break;
++		}
++		ets = (struct eaptls_session *) esp->es_server.ea_session;
++
++		if(ets->frag)
++			esp->es_server.ea_state = eapTlsSendAck;
++		else
++			esp->es_server.ea_state = eapTlsSend;
++		break;
++
++	case eapTlsSend:
++		ets = (struct eaptls_session *) esp->es_server.ea_session;
++
++		if(ets->frag)
++			esp->es_server.ea_state = eapTlsRecvAck;
++		else
++			if(SSL_is_init_finished(ets->ssl)) 
++				esp->es_server.ea_state = eapTlsRecvClient; 
++			else
++				esp->es_server.ea_state = eapTlsRecv;
++		break;
++
++	case eapTlsSendAck:
++			esp->es_server.ea_state = eapTlsRecv;
++		break;
++
++	case eapTlsRecvAck:
++                if (status) {
++                        esp->es_server.ea_state = eapBadAuth;
++                        break;
++                }
++
++		esp->es_server.ea_state = eapTlsSend;
++		break;
++
++	case eapTlsSendAlert:
++		esp->es_server.ea_state = eapTlsRecvAlertAck;
++		break;
++#endif /* USE_EAPTLS */
++
+ 	case eapSRP1:
+ #ifdef USE_SRP
+ 		ts = (struct t_server *)esp->es_server.ea_session;
+@@ -718,6 +808,30 @@ eap_state *esp;
+ 		INCPTR(esp->es_server.ea_namelen, outp);
+ 		break;
+ 
++#ifdef USE_EAPTLS
++	case eapTlsStart:
++		PUTCHAR(EAPT_TLS, outp);
++		PUTCHAR(EAP_TLS_FLAGS_START, outp);
++		eap_figure_next_state(esp, 0);
++		break;
++
++	case eapTlsSend:
++		eaptls_send(esp->es_server.ea_session, &outp);
++		eap_figure_next_state(esp, 0);
++		break;
++
++	case eapTlsSendAck:
++		PUTCHAR(EAPT_TLS, outp);
++		PUTCHAR(0, outp);
++		eap_figure_next_state(esp, 0);
++		break;
++
++	case eapTlsSendAlert:
++		eaptls_send(esp->es_server.ea_session, &outp);
++		eap_figure_next_state(esp, 0);
++		break;
++#endif /* USE_EAPTLS */
++
+ #ifdef USE_SRP
+ 	case eapSRP1:
+ 		PUTCHAR(EAPT_SRP, outp);
+@@ -904,11 +1018,57 @@ static void
+ eap_server_timeout(arg)
+ void *arg;
+ {
++#ifdef USE_EAPTLS
++	u_char *outp;
++	u_char *lenloc;
++	int outlen;
++#endif /* USE_EAPTLS */
++
+ 	eap_state *esp = (eap_state *) arg;
+ 
+ 	if (!eap_server_active(esp))
+ 		return;
+ 
++#ifdef USE_EAPTLS
++	switch(esp->es_server.ea_prev_state) {
++
++	/* 
++	 *  In eap-tls the state changes after a request, so we return to
++	 *  previous state ...
++	 */
++	case(eapTlsStart):
++	case(eapTlsSendAck):
++		esp->es_server.ea_state = esp->es_server.ea_prev_state;
++		break;
++
++	/*
++	 *  ... or resend the stored data
++	 */
++	case(eapTlsSend):
++	case(eapTlsSendAlert):
++		outp = outpacket_buf;
++		MAKEHEADER(outp, PPP_EAP);
++		PUTCHAR(EAP_REQUEST, outp);
++		PUTCHAR(esp->es_server.ea_id, outp);
++		lenloc = outp;
++		INCPTR(2, outp);
++
++		eaptls_retransmit(esp->es_server.ea_session, &outp);
++
++		outlen = (outp - outpacket_buf) - PPP_HDRLEN;
++		PUTSHORT(outlen, lenloc);
++		output(esp->es_unit, outpacket_buf, outlen + PPP_HDRLEN);
++		esp->es_server.ea_requests++;
++
++		if (esp->es_server.ea_timeout > 0)
++			TIMEOUT(eap_server_timeout, esp, esp->es_server.ea_timeout);
++
++		return;
++	default:
++		break;
++	}
++#endif /* USE_EAPTLS */
++
+ 	/* EAP ID number must not change on timeout. */
+ 	eap_send_request(esp);
+ }
+@@ -1166,6 +1326,81 @@ u_char *str;
+ }
+ #endif /* USE_SRP */
+ 
++#ifdef USE_EAPTLS
++/*
++ * Send an EAP-TLS response message with tls data
++ */
++static void
++eap_tls_response(esp, id)
++eap_state *esp;
++u_char id;
++{
++        u_char *outp;
++        int outlen;
++	u_char *lenloc;
++
++        outp = outpacket_buf;
++
++        MAKEHEADER(outp, PPP_EAP);
++
++        PUTCHAR(EAP_RESPONSE, outp);
++        PUTCHAR(id, outp);
++
++	lenloc = outp;
++	INCPTR(2, outp);        
++
++	/*
++	   If the id in the request is unchanged, we must retransmit
++	   the old data
++	*/
++	if(id == esp->es_client.ea_id)
++		eaptls_retransmit(esp->es_client.ea_session, &outp);
++	else
++		eaptls_send(esp->es_client.ea_session, &outp);
++
++	outlen = (outp - outpacket_buf) - PPP_HDRLEN;
++	PUTSHORT(outlen, lenloc);
++
++	output(esp->es_unit, outpacket_buf, PPP_HDRLEN + outlen);
++
++	esp->es_client.ea_id = id;
++
++}
++
++/*
++ * Send an EAP-TLS ack
++ */
++static void
++eap_tls_sendack(esp, id)
++eap_state *esp;
++u_char id;
++{
++	u_char *outp;
++	int outlen;
++	u_char *lenloc;
++
++	outp = outpacket_buf;
++
++	MAKEHEADER(outp, PPP_EAP);
++
++	PUTCHAR(EAP_RESPONSE, outp);
++	PUTCHAR(id, outp);
++	esp->es_client.ea_id = id;
++
++	lenloc = outp;
++	INCPTR(2, outp);
++
++	PUTCHAR(EAPT_TLS, outp);
++	PUTCHAR(0, outp);
++
++	outlen = (outp - outpacket_buf) - PPP_HDRLEN;
++	PUTSHORT(outlen, lenloc);
++
++	output(esp->es_unit, outpacket_buf, PPP_HDRLEN + outlen);
++
++}
++#endif /* USE_EAPTLS */
++
+ static void
+ eap_send_nak(esp, id, type)
+ eap_state *esp;
+@@ -1320,6 +1555,11 @@ int len;
+ 	char rhostname[256];
+ 	MD5_CTX mdContext;
+ 	u_char hash[MD5_SIGNATURE_SIZE];
++#ifdef USE_EAPTLS
++	u_char flags;
++	struct eaptls_session *ets = esp->es_client.ea_session;
++#endif /* USE_EAPTLS */
++
+ #ifdef USE_SRP
+ 	struct t_client *tc;
+ 	struct t_num sval, gval, Nval, *Ap, Bval;
+@@ -1456,6 +1696,90 @@ int len;
+ 		    esp->es_client.ea_namelen);
+ 		break;
+ 
++#ifdef USE_EAPTLS
++	case EAPT_TLS:
++
++		switch(esp->es_client.ea_state) {
++
++		case eapListen:
++
++			GETCHAR(flags, inp);
++			if(flags & EAP_TLS_FLAGS_START){
++
++				esp->es_client.ea_using_eaptls = 1;
++
++                                if (explicit_remote){
++                                        esp->es_client.ea_peer = strdup(remote_name);
++                                        esp->es_client.ea_peerlen = strlen(remote_name);
++                                } else
++                                        esp->es_client.ea_peer = NULL;
++
++				/* Init ssl session */
++				if(!eaptls_init_ssl_client(esp)) {
++					dbglog("cannot init ssl");
++					eap_send_nak(esp, id, EAPT_TLS);
++					esp->es_client.ea_using_eaptls = 0;
++					break;
++				}
++
++				ets = esp->es_client.ea_session;
++				eap_tls_response(esp, id);
++				esp->es_client.ea_state = (ets->frag ? eapTlsRecvAck :
++								eapTlsRecv);
++				break;
++			}
++
++			/* The server has sent a bad start packet. */
++			eap_send_nak(esp, id, EAPT_TLS);
++			break;
++
++		case eapTlsRecvAck:
++			eap_tls_response(esp, id);
++			esp->es_client.ea_state = (ets->frag ? eapTlsRecvAck : 
++							eapTlsRecv);
++			break;
++
++		case eapTlsRecv:
++			eaptls_receive(ets, inp, len);
++
++			if(ets->frag) {
++				eap_tls_sendack(esp, id);
++				esp->es_client.ea_state = eapTlsRecv;
++				break;
++			}
++
++			if(ets->alert_recv) {
++				eap_tls_sendack(esp, id);
++				esp->es_client.ea_state = eapTlsRecvFailure;
++				break;
++			}
++
++			/* Check if TLS handshake is finished */
++			if(SSL_is_init_finished(ets->ssl)){
++#ifdef MPPE
++ 				eaptls_gen_mppe_keys( ets, "client EAP encryption", 1 );
++#endif
++				eaptls_free_session(ets);
++				eap_tls_sendack(esp, id);
++				esp->es_client.ea_state = eapTlsRecvSuccess;
++				break;
++			}
++
++			eap_tls_response(esp,id);
++                        esp->es_client.ea_state = (ets->frag ? eapTlsRecvAck :
++                                                        eapTlsRecv);
++
++                        break;
++
++		default:
++			eap_send_nak(esp, id, EAPT_TLS);
++			esp->es_client.ea_using_eaptls = 0;
++			break;
++		}
++
++		break;
++#endif /* USE_EAPTLS */
++
+ #ifdef USE_SRP
+ 	case EAPT_SRP:
+ 		if (len < 1) {
+@@ -1737,6 +2061,11 @@ int len;
+ 	u_char dig[SHA_DIGESTSIZE];
+ #endif /* USE_SRP */
+ 
++#ifdef USE_EAPTLS
++	struct eaptls_session *ets;
++	u_char flags;
++#endif /* USE_EAPTLS */
++
+ 	if (esp->es_server.ea_id != id) {
+ 		dbglog("EAP: discarding Response %d; expected ID %d", id,
+ 		    esp->es_server.ea_id);
+@@ -1776,6 +2105,60 @@ int len;
+ 		eap_figure_next_state(esp, 0);
+ 		break;
+ 
++#ifdef USE_EAPTLS
++	case EAPT_TLS:
++		switch(esp->es_server.ea_state) {
++
++		case eapTlsRecv:
++			ets = (struct eaptls_session *) esp->es_server.ea_session;
++			eap_figure_next_state(esp, 
++				eaptls_receive(esp->es_server.ea_session, inp, len));
++
++			if(ets->alert_recv) {
++				eap_send_failure(esp);
++				break;
++			}
++			break;
++
++		case eapTlsRecvAck:
++			if(len > 1) {
++				dbglog("EAP-TLS ACK with extra data");
++			}
++			eap_figure_next_state(esp, 0);
++			break;
++
++		case eapTlsRecvClient:
++			/* Receive authentication response from client */
++
++			GETCHAR(flags, inp);
++
++			if(len == 1 && !flags) {	/* Ack = ok */
++#ifdef MPPE
++ 				eaptls_gen_mppe_keys( esp->es_server.ea_session, "client EAP encryption", 0 );
++#endif
++				eap_send_success(esp);
++			}
++			else {			/* failure */
++				eaptls_receive(esp->es_server.ea_session, inp, len);
++				warn("Server authentication failed");
++				eap_send_failure(esp);
++			}
++
++			eaptls_free_session(esp->es_server.ea_session);
++
++			break;
++
++		case eapTlsRecvAlertAck:
++			eap_send_failure(esp);
++			break;
++
++		default:
++			eap_figure_next_state(esp, 1);
++			break;
++		}
++		break;
++#endif /* USE_EAPTLS */
++
+ 	case EAPT_NOTIFICATION:
+ 		dbglog("EAP unexpected Notification; response discarded");
+ 		break;
+@@ -1807,6 +2190,13 @@ int len;
+ 			esp->es_server.ea_state = eapMD5Chall;
+ 			break;
+ 
++#ifdef USE_EAPTLS
++			/* Send EAP-TLS start packet */
++		case EAPT_TLS:
++			esp->es_server.ea_state = eapTlsStart;
++			break;
++#endif /* USE_EAPTLS */
++
+ 		default:
+ 			dbglog("EAP: peer requesting unknown Type %d", vallen);
+ 			switch (esp->es_server.ea_state) {
+@@ -2018,13 +2408,27 @@ u_char *inp;
+ int id;
+ int len;
+ {
+-	if (esp->es_client.ea_state != eapOpen && !eap_client_active(esp)) {
++	if (esp->es_client.ea_state != eapOpen && !eap_client_active(esp)
++#ifdef USE_EAPTLS
++		&& esp->es_client.ea_state != eapTlsRecvSuccess
++#endif /* USE_EAPTLS */
++		) {
+ 		dbglog("EAP unexpected success message in state %s (%d)",
+ 		    eap_state_name(esp->es_client.ea_state),
+ 		    esp->es_client.ea_state);
+ 		return;
+ 	}
+ 
++#ifdef USE_EAPTLS
++	if(esp->es_client.ea_using_eaptls && esp->es_client.ea_state != 
++		eapTlsRecvSuccess) {
++		dbglog("EAP-TLS unexpected success message in state %s (%d)",
++                    eap_state_name(esp->es_client.ea_state),
++                    esp->es_client.ea_state);
++		return;
++	}
++#endif /* USE_EAPTLS */
++
+ 	if (esp->es_client.ea_timeout > 0) {
+ 		UNTIMEOUT(eap_client_timeout, (void *)esp);
+ 	}
+@@ -2150,6 +2554,9 @@ void *arg;
+ 	int code, id, len, rtype, vallen;
+ 	u_char *pstart;
+ 	u_int32_t uval;
++#ifdef USE_EAPTLS
++	u_char flags;
++#endif /* USE_EAPTLS */
+ 
+ 	if (inlen < EAP_HEADERLEN)
+ 		return (0);
+@@ -2214,6 +2621,24 @@ void *arg;
+ 			}
+ 			break;
+ 
++#ifdef USE_EAPTLS
++		case EAPT_TLS:
++			if (len < 1)
++				break;
++			GETCHAR(flags, inp);
++			len--;
++
++                        if(flags == 0 && len == 0){
++                                printer(arg, " Ack");
++                                break;
++                        }
++
++			printer(arg, flags & EAP_TLS_FLAGS_LI ? " L":" -");
++			printer(arg, flags & EAP_TLS_FLAGS_MF ? "M":"-");
++			printer(arg, flags & EAP_TLS_FLAGS_START ? "S":"- ");
++			break;
++#endif /* USE_EAPTLS */
++
+ 		case EAPT_SRP:
+ 			if (len < 3)
+ 				goto truncated;
+@@ -2325,6 +2750,25 @@ void *arg;
+ 			}
+ 			break;
+ 
++#ifdef USE_EAPTLS
++		case EAPT_TLS:
++			if (len < 1)
++				break;
++			GETCHAR(flags, inp);
++			len--;
++
++                        if(flags == 0 && len == 0){
++                                printer(arg, " Ack");
++                                break;
++                        }
++
++			printer(arg, flags & EAP_TLS_FLAGS_LI ? " L":" -");
++			printer(arg, flags & EAP_TLS_FLAGS_MF ? "M":"-");
++			printer(arg, flags & EAP_TLS_FLAGS_START ? "S":"- ");
++
++			break;
++#endif /* USE_EAPTLS */
++
+ 		case EAPT_NAK:
+ 			if (len <= 0) {
+ 				printer(arg, " <missing hint>");
+@@ -2426,3 +2870,4 @@ void *arg;
+ 
+ 	return (inp - pstart);
+ }
++
+Index: b/pppd/eap.h
+===================================================================
+--- a/pppd/eap.h
++++ b/pppd/eap.h
+@@ -84,6 +84,16 @@ enum eap_state_code {
+ 	eapClosed,	/* Authentication not in use */
+ 	eapListen,	/* Client ready (and timer running) */
+ 	eapIdentify,	/* EAP Identify sent */
++	eapTlsStart,	/* Send EAP-TLS start packet */
++	eapTlsRecv,	/* Receive EAP-TLS tls data */
++	eapTlsSendAck,	/* Send EAP-TLS ack */
++	eapTlsSend,	/* Send EAP-TLS tls data */
++	eapTlsRecvAck,	/* Receive EAP-TLS ack */
++	eapTlsRecvClient, 	/* Receive EAP-TLS auth response from client*/
++	eapTlsSendAlert,	/* Send EAP-TLS tls alert (server)*/
++	eapTlsRecvAlertAck,	/* Receive EAP-TLS ack after sending alert */
++	eapTlsRecvSuccess,	/* Receive EAP success */
++	eapTlsRecvFailure,	/* Receive EAP failure */
+ 	eapSRP1,	/* Sent EAP SRP-SHA1 Subtype 1 */
+ 	eapSRP2,	/* Sent EAP SRP-SHA1 Subtype 2 */
+ 	eapSRP3,	/* Sent EAP SRP-SHA1 Subtype 3 */
+@@ -95,9 +105,18 @@ enum eap_state_code {
+ 
+ #define	EAP_STATES	\
+ 	"Initial", "Pending", "Closed", "Listen", "Identify", \
++	"TlsStart", "TlsRecv", "TlsSendAck", "TlsSend", "TlsRecvAck", "TlsRecvClient",\
++	"TlsSendAlert", "TlsRecvAlertAck" , "TlsRecvSuccess", "TlsRecvFailure", \
+ 	"SRP1", "SRP2", "SRP3", "MD5Chall", "Open", "SRP4", "BadAuth"
+ 
+-#define	eap_client_active(esp)	((esp)->es_client.ea_state == eapListen)
++#ifdef USE_EAPTLS
++#define	eap_client_active(esp)	((esp)->es_client.ea_state != eapInitial ||\
++				 (esp)->es_client.ea_state != eapPending ||\
++				 (esp)->es_client.ea_state != eapClosed)
++#else
++#define eap_client_active(esp)	((esp)->es_client.ea_state == eapListen)
++#endif /* USE_EAPTLS */
++
+ #define	eap_server_active(esp)	\
+ 	((esp)->es_server.ea_state >= eapIdentify && \
+ 	 (esp)->es_server.ea_state <= eapMD5Chall)
+@@ -112,11 +131,17 @@ struct eap_auth {
+ 	u_short ea_namelen;	/* Length of our name */
+ 	u_short ea_peerlen;	/* Length of peer's name */
+ 	enum eap_state_code ea_state;
++#ifdef USE_EAPTLS
++	enum eap_state_code ea_prev_state;
++#endif
+ 	u_char ea_id;		/* Current id */
+ 	u_char ea_requests;	/* Number of Requests sent/received */
+ 	u_char ea_responses;	/* Number of Responses */
+ 	u_char ea_type;		/* One of EAPT_* */
+ 	u_int32_t ea_keyflags;	/* SRP shared key usage flags */
++#ifdef USE_EAPTLS
++	bool ea_using_eaptls;
++#endif
+ };
+ 
+ /*
+@@ -139,7 +164,12 @@ typedef struct eap_state {
+  * Timeouts.
+  */
+ #define	EAP_DEFTIMEOUT		3	/* Timeout (seconds) for rexmit */
++#ifdef USE_EAPTLS
++#define	EAP_DEFTRANSMITS	30	/* max # times to transmit */
++					/* certificates can be long ... */
++#else
+ #define	EAP_DEFTRANSMITS	10	/* max # times to transmit */
++#endif /* USE_EAPTLS */
+ #define	EAP_DEFREQTIME		20	/* Time to wait for peer request */
+ #define	EAP_DEFALLOWREQ		20	/* max # times to accept requests */
+ 
+Index: b/pppd/md5.c
+===================================================================
+--- a/pppd/md5.c
++++ b/pppd/md5.c
+@@ -33,6 +33,8 @@
+  ***********************************************************************
+  */
+ 
++#ifndef USE_EAPTLS
++
+ #include <string.h>
+ #include "md5.h"
+ 
+@@ -305,3 +307,5 @@ UINT4 *in;
+  ** End of md5.c                                                      **
+  ******************************** (cut) ********************************
+  */
++#endif /* USE_EAPTLS */
++
+Index: b/pppd/md5.h
+===================================================================
+--- a/pppd/md5.h
++++ b/pppd/md5.h
+@@ -36,6 +36,7 @@
+  ** documentation and/or software.                                    **
+  ***********************************************************************
+  */
++#ifndef USE_EAPTLS
+ 
+ #ifndef __MD5_INCLUDE__
+ 
+@@ -63,3 +64,5 @@ void MD5_Final (unsigned char hash[], MD
+ 
+ #define __MD5_INCLUDE__
+ #endif /* __MD5_INCLUDE__ */
++
++#endif /* USE_EAPTLS */
+Index: b/pppd/pathnames.h
+===================================================================
+--- a/pppd/pathnames.h
++++ b/pppd/pathnames.h
+@@ -21,6 +21,13 @@
+ #define _PATH_UPAPFILE 	 _ROOT_PATH "/etc/ppp/pap-secrets"
+ #define _PATH_CHAPFILE 	 _ROOT_PATH "/etc/ppp/chap-secrets"
+ #define _PATH_SRPFILE 	 _ROOT_PATH "/etc/ppp/srp-secrets"
++
++#ifdef USE_EAPTLS
++#define _PATH_EAPTLSCLIFILE	_ROOT_PATH "/etc/ppp/eaptls-client"
++#define _PATH_EAPTLSSERVFILE	_ROOT_PATH "/etc/ppp/eaptls-server"
++#define _PATH_OPENSSLCONFFILE	_ROOT_PATH "/etc/ppp/openssl.cnf"
++#endif /* USE_EAPTLS */
++
+ #define _PATH_SYSOPTIONS _ROOT_PATH "/etc/ppp/options"
+ #define _PATH_IPUP	 _ROOT_PATH "/etc/ppp/ip-up"
+ #define _PATH_IPDOWN	 _ROOT_PATH "/etc/ppp/ip-down"
+Index: b/pppd/plugins/Makefile.linux
+===================================================================
+--- a/pppd/plugins/Makefile.linux
++++ b/pppd/plugins/Makefile.linux
+@@ -4,6 +4,9 @@ CFLAGS	= $(COPTS) -I.. -I../../include -
+ LDFLAGS	= $(LDOPTS)
+ INSTALL	= install
+ 
++# EAP-TLS
++CFLAGS += -DUSE_EAPTLS=1
++
+ DESTDIR = $(INSTROOT)@DESTDIR@
+ BINDIR = $(DESTDIR)/sbin
+ MANDIR = $(DESTDIR)/share/man/man8
+Index: b/pppd/plugins/passprompt.c
+===================================================================
+--- a/pppd/plugins/passprompt.c
++++ b/pppd/plugins/passprompt.c
+@@ -107,4 +107,7 @@ void plugin_init(void)
+ {
+     add_options(options);
+     pap_passwd_hook = promptpass;
++#ifdef USE_EAPTLS
++    eaptls_passwd_hook = promptpass;
++#endif
+ }
+Index: b/pppd/plugins/passwordfd.c
+===================================================================
+--- a/pppd/plugins/passwordfd.c
++++ b/pppd/plugins/passwordfd.c
+@@ -79,4 +79,8 @@ void plugin_init (void)
+ 
+     chap_check_hook = pwfd_check;
+     chap_passwd_hook = pwfd_passwd;
++
++#ifdef USE_EAPTLS
++    eaptls_passwd_hook = pwfd_passwd;
++#endif
+ }
+Index: b/pppd/pppd.8
+===================================================================
+--- a/pppd/pppd.8
++++ b/pppd/pppd.8
+@@ -253,6 +253,12 @@ Alternatively, a value of 0 for \fInr\fR
+ compression in the corresponding direction.  Use \fInobsdcomp\fR or
+ \fIbsdcomp 0\fR to disable BSD-Compress compression entirely.
+ .TP
++.B ca \fIca-file
++(EAP-TLS) Use the file \fIca-file\fR as the X.509 Certificate Authority
++(CA) file (in PEM format), needed for setting up an EAP-TLS connection.
++This option is used on the client-side in conjunction with the \fBcert\fR
++and \fBkey\fR options.
++.TP
+ .B cdtrcts
+ Use a non-standard hardware flow control (i.e. DTR/CTS) to control
+ the flow of data on the serial port.  If neither the \fIcrtscts\fR,
+@@ -264,6 +270,12 @@ RTS output. Such serial ports use this m
+ bi-directional flow control. The sacrifice is that this flow
+ control mode does not permit using DTR as a modem control line.
+ .TP
++.B cert \fIcertfile
++(EAP-TLS) Use the file \fIcertfile\fR as the X.509 certificate (in PEM
++format), needed for setting up an EAP-TLS connection. This option is
++used on the client-side in conjunction with the \fBca\fR and 
++\fBkey\fR options.
++.TP
+ .B chap\-interval \fIn
+ If this option is given, pppd will rechallenge the peer every \fIn\fR
+ seconds.
+@@ -292,6 +304,18 @@ negotiation by sending its first LCP pac
+ 1000 (1 second).  This wait period only applies if the \fBconnect\fR
+ or \fBpty\fR option is used.
+ .TP
++.B crl \fIfilename
++(EAP-TLS) Use the file \fIfilename\fR as the Certificate Revocation List
++to check for the validity of the peer's certificate. This option is not
++mandatory for setting up an EAP-TLS connection. Also see the \fBcrl-dir\fR
++option.
++.TP
++.B crl-dir \fIdirectory
++(EAP-TLS) Use the directory \fIdirectory\fR to scan for CRL files in
++has format ($hash.r0) to check for the validity of the peer's certificate.
++This option is not mandatory for setting up an EAP-TLS connection.
++Also see the \fBcrl\fR option.
++.TP
+ .B debug
+ Enables connection debugging facilities.
+ If this option is given, pppd will log the contents of all
+@@ -561,6 +585,12 @@ transmitted packets be printed.  On most
+ the kernel are logged by syslog(1) to a file as directed in the
+ /etc/syslog.conf configuration file.
+ .TP
++.B key \fIkeyfile
++(EAP-TLS) Use the file \fIkeyfile\fR as the private key file (in PEM
++format), needed for setting up an EAP-TLS connection. This option is
++used on the client-side in conjunction with the \fBca\fR and 
++\fBcert\fR options.
++.TP
+ .B ktune
+ Enables pppd to alter kernel settings as appropriate.  Under Linux,
+ pppd will enable IP forwarding (i.e. set /proc/sys/net/ipv4/ip_forward
+@@ -724,6 +754,9 @@ name to \fIname\fR.)
+ Disable Address/Control compression in both directions (send and
+ receive).
+ .TP
++.B need-peer-eap
++(EAP-TLS) Require the peer to verify our authentication credentials.
++.TP
+ .B noauth
+ Do not require the peer to authenticate itself.  This option is
+ privileged.
+Index: b/pppd/pppd.h
+===================================================================
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -338,6 +338,11 @@ extern bool	dump_options;	/* print out o
+ extern bool	dryrun;		/* check everything, print options, exit */
+ extern int	child_wait;	/* # seconds to wait for children at end */
+ 
++#ifdef USE_EAPTLS
++extern char	*crl_dir;
++extern char	*crl_file;
++#endif /* USE_EAPTLS */
++
+ #ifdef MAXOCTETS
+ extern unsigned int maxoctets;	     /* Maximum octetes per session (in bytes) */
+ extern int       maxoctets_dir;      /* Direction :
+@@ -758,6 +763,10 @@ extern int (*chap_check_hook) __P((void)
+ extern int (*chap_passwd_hook) __P((char *user, char *passwd));
+ extern void (*multilink_join_hook) __P((void));
+ 
++#ifdef USE_EAPTLS
++extern int (*eaptls_passwd_hook) __P((char *user, char *passwd));
++#endif
++
+ /* Let a plugin snoop sent and received packets.  Useful for L2TP */
+ extern void (*snoop_recv_hook) __P((unsigned char *p, int len));
+ extern void (*snoop_send_hook) __P((unsigned char *p, int len));
diff -Nru ppp-2.4.7/debian/patches/series ppp-2.4.7/debian/patches/series
--- ppp-2.4.7/debian/patches/series	2015-12-04 09:23:37.000000000 +0100
+++ ppp-2.4.7/debian/patches/series	2015-12-04 17:42:23.000000000 +0100
@@ -33,3 +33,7 @@
 zzz_config
 secure-card-interpreter-fix
 rc_mksid-no-buffer-overflow
+
+# ubuntu
+load_ppp_generic_if_needed
+ppp-2.4.6-eaptls-mppe-0.997.patch
diff -Nru ppp-2.4.7/debian/ppp.preinst ppp-2.4.7/debian/ppp.preinst
--- ppp-2.4.7/debian/ppp.preinst	2015-12-04 09:23:37.000000000 +0100
+++ ppp-2.4.7/debian/ppp.preinst	2015-12-04 17:42:22.000000000 +0100
@@ -3,6 +3,10 @@
 
 case "$1" in
     install|upgrade)
+    if dpkg --compare-versions "$2" lt "2.4.6-3ubuntu1"; then
+	update-rc.d pppd-dns remove
+    fi
+
     if dpkg --compare-versions "$2" le "2.4.5-4"; then
 
     if dpkg --compare-versions "$2" le "2.4.4b1-1"; then
Download as text