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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML
><HEAD
><link rel='stylesheet' type='text/css' href='manpage.css'>
<!-- $Id: authlib.sgml,v 1.2 2004/07/12 22:55:59 mrsam Exp $ -->
<!-- Copyright 1998 - 2001 Double Precision, Inc. See COPYING for -->
<!-- distribution information. -->
<meta name="MSSmartTagsPreventParsing" content="TRUE">
<link rel="icon" href="icon.gif" type="image/gif" />
<TITLE
>authlib</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"></HEAD
><BODY
CLASS="REFENTRY"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><H1
><A
NAME="AUTHLIB"
></A
>authlib</H1
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN10"
></A
><H2
>Name</H2
>authlib -- Courier Authentication Library</DIV
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN13"
></A
><H2
>Synopsis</H2
><P
><B
CLASS="COMMAND"
>authpam</B
> {<VAR
CLASS="REPLACEABLE"
>command</VAR
>} [<VAR
CLASS="REPLACEABLE"
>arg</VAR
>...]</P
><P
><B
CLASS="COMMAND"
>authpwd</B
> {<VAR
CLASS="REPLACEABLE"
>command</VAR
>} [<VAR
CLASS="REPLACEABLE"
>arg</VAR
>...]</P
><P
><B
CLASS="COMMAND"
>authshadow</B
> {<VAR
CLASS="REPLACEABLE"
>command</VAR
>} [<VAR
CLASS="REPLACEABLE"
>arg</VAR
>...]</P
><P
><B
CLASS="COMMAND"
>authuserdb</B
> {<VAR
CLASS="REPLACEABLE"
>command</VAR
>} [<VAR
CLASS="REPLACEABLE"
>arg</VAR
>...]</P
><P
><B
CLASS="COMMAND"
>authvchkpw</B
> {<VAR
CLASS="REPLACEABLE"
>command</VAR
>} [<VAR
CLASS="REPLACEABLE"
>arg</VAR
>...]</P
><P
><B
CLASS="COMMAND"
>authcram</B
> {<VAR
CLASS="REPLACEABLE"
>command</VAR
>} [<VAR
CLASS="REPLACEABLE"
>arg</VAR
>...]</P
><P
><B
CLASS="COMMAND"
>authmysql</B
> {<VAR
CLASS="REPLACEABLE"
>command</VAR
>} [<VAR
CLASS="REPLACEABLE"
>arg</VAR
>...]</P
><P
><B
CLASS="COMMAND"
>authpgsql</B
> {<VAR
CLASS="REPLACEABLE"
>command</VAR
>} [<VAR
CLASS="REPLACEABLE"
>arg</VAR
>...]</P
><P
><B
CLASS="COMMAND"
>authldap</B
> {<VAR
CLASS="REPLACEABLE"
>command</VAR
>} [<VAR
CLASS="REPLACEABLE"
>arg</VAR
>...]</P
><P
><B
CLASS="COMMAND"
>authdaemon</B
> {<VAR
CLASS="REPLACEABLE"
>command</VAR
>} [<VAR
CLASS="REPLACEABLE"
>arg</VAR
>...]</P
><P
><B
CLASS="COMMAND"
>authcustom</B
> {<VAR
CLASS="REPLACEABLE"
>command</VAR
>} [<VAR
CLASS="REPLACEABLE"
>arg</VAR
>...]</P
><P
><B
CLASS="COMMAND"
>authdaemond</B
> [start | stop | restart]</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN86"
></A
><H2
>DESCRIPTION</H2
><P
>This library is used for two purposes:</P
><P
>1. Read an E-mail address that is supposed to be for a local account.
Determine the local account's home directory, and system userid and
groupid.</P
><P
>2. Read a login id and a password.
If valid, determine the account's home directory, system userid, and
groupid.</P
><P
>The term "authentication" is used in the following documentation to refer
to either one of these two functions.
The library contains several alternative authentication implementations,
that may be selected at runtime.</P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>authdaemon</TT
></DT
><DD
><P
>authenticates through a background daemon proxy.
This is now the installation default.
Unless otherwise specified, the <TT
CLASS="LITERAL"
>authdaemon</TT
>
module will always be installed.
<TT
CLASS="LITERAL"
>authdaemon</TT
> is installed instead of the other
authentication modules.
Those modules are instead compiled into a separate executable program,
<TT
CLASS="LITERAL"
>authdaemond</TT
> that is initialized at system start, and runs
in the background.
The <TT
CLASS="LITERAL"
>authdaemon</TT
> authentication module forwards the
authentication requests to <TT
CLASS="LITERAL"
>authdaemond</TT
>, which forwards
the authentication request to the real authentication module, and the
result of the request is eventually returned back to the application.
Because the real authentication process runs as a persistent background
process, it is possible for the authentication process to open and hold
permanent connections to the back-end authentication database (be it an
LDAP directory, a MySQL or a PostgreSQL server), instead of connecting
and disconnecting for every request.
Obviously, this tremendously improves the authentication performance.</P
></DD
><DT
><TT
CLASS="LITERAL"
>authpam</TT
></DT
><DD
><P
>authenticates using the system's PAM library
(pluggable authentication module).
This is, essentially, a way to use existing PAM modules for authentication
functionality.
Note, however, that the authenticated account's home directory, userid and
groupid are still read from the <TT
CLASS="FILENAME"
>/etc/passwd</TT
> file,
since PAM functionality is limited to validating account passwords.</P
></DD
><DT
><TT
CLASS="LITERAL"
>authpwd</TT
></DT
><DD
><P
>authenticates from the
<TT
CLASS="FILENAME"
>/etc/passwd</TT
> file.</P
></DD
><DT
><TT
CLASS="LITERAL"
>authshadow</TT
></DT
><DD
><P
>like <TT
CLASS="LITERAL"
>authpwd</TT
> except passwords
are read from <TT
CLASS="FILENAME"
>/etc/shadow</TT
>.</P
></DD
><DT
><TT
CLASS="LITERAL"
>authuserdb</TT
></DT
><DD
><P
>authenticates against the
<A
HREF="userdb.html"
TARGET="_top"
><SPAN
CLASS="CITEREFENTRY"
><SPAN
CLASS="REFENTRYTITLE"
>userdb</SPAN
>(8)</SPAN
></A
> database.</P
></DD
><DT
><TT
CLASS="LITERAL"
>authvchkpw</TT
></DT
><DD
><P
>supports existing <TT
CLASS="LITERAL"
>vpopmail/vchkpw</TT
>
virtual domains.</P
></DD
><DT
><TT
CLASS="LITERAL"
>authcram</TT
></DT
><DD
><P
>authenticates against the
<A
HREF="userdb.html"
TARGET="_top"
><SPAN
CLASS="CITEREFENTRY"
><SPAN
CLASS="REFENTRYTITLE"
>userdb</SPAN
>(8)</SPAN
></A
> database using the
challenge/response authentication mechanism (CRAM), instead of the traditional
userid/password.</P
></DD
><DT
><TT
CLASS="LITERAL"
>authmysql</TT
></DT
><DD
><P
>authenticates against a list of mail accounts
stored in an external MySQL database.
The <TT
CLASS="FILENAME"
>@authmysqlrc@</TT
> configuration file defines the
particular details regarding the MySQL database and the schema of the
mail account list table.</P
></DD
><DT
><TT
CLASS="LITERAL"
>authpgsql</TT
></DT
><DD
><P
>authenticates against a list of mail accounts
stored in an external PostgreSQL database.
The <TT
CLASS="FILENAME"
>authpgsqlrc</TT
> configuration file defines the
particular details regarding the PostgreSQL database and the schema of the
mail account list table.</P
></DD
><DT
><TT
CLASS="LITERAL"
>authldap</TT
></DT
><DD
><P
>authenticates against a list of mail accounts
stored in an external LDAP directory.
The <TT
CLASS="FILENAME"
>@authldaprc@</TT
> configuration file defines the
particular details regarding the LDAP directory layout.</P
></DD
><DT
><TT
CLASS="LITERAL"
>authcustom</TT
></DT
><DD
><P
>this is a stub where custom authentication code
can be added.
This authentication module is just a stub that doesn't really do anything.
It's purpose is to serve as a placeholder where custom authentication code
can be easily added.</P
></DD
></DL
></DIV
><P
>This is a complete list of available authentication modules.
The actual installed authentication modules are determined by the resources
on the server.
For example, the <TT
CLASS="LITERAL"
>authmysql</TT
> authentication module will
be installed only if the system provides MySQL support libraries.</P
><DIV
CLASS="REFSECT2"
><A
NAME="AEN171"
></A
><H3
><TT
CLASS="LITERAL"
>authdaemon</TT
> authentication module</H3
><P
>The following command must be executed from the system startup script
in order for the <TT
CLASS="LITERAL"
>authdaemon</TT
> module to work (and remember
that <TT
CLASS="LITERAL"
>authdaemon</TT
> is installed by default:</P
><A
NAME="AEN177"
></A
><BLOCKQUOTE
CLASS="BLOCKQUOTE"
><DIV
CLASS="INFORMALEXAMPLE"
><P
></P
><A
NAME="AEN178"
></A
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>@libexecdir@/authlib/authdaemond start</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
></BLOCKQUOTE
><P
>"<B
CLASS="COMMAND"
>authdaemond stop</B
>" should also be added to the system
shutdown script.</P
><P
>The <TT
CLASS="FILENAME"
>@authdaemonvar@</TT
> subdirectory must be created in
advance.
This directory will have the filesystem socket used for
interprocess communication between
<TT
CLASS="LITERAL"
>authdaemon</TT
> and <TT
CLASS="LITERAL"
>authdaemond</TT
>.
It goes without saying that
the underlying filesystem for <TT
CLASS="FILENAME"
>@authdaemonvar@</TT
> must support
filesystem domain sockets. This pretty much excludes all network filesystems,
so this directory should reside on a local disk.</P
><P
><TT
CLASS="FILENAME"
>@authdaemonvar@</TT
>
MUST NOT HAVE any world-readable, executable
or writable permissions! Under NO circumstances should this be allowed to
happen. The exact permissions and ownership of
<TT
CLASS="FILENAME"
>@authdaemonvar@</TT
> varies. For the standalone versions of
<SPAN
CLASS="PRODUCTNAME"
>Courier-IMAP</SPAN
> and
<SPAN
CLASS="PRODUCTNAME"
>SqWebMail</SPAN
>,
<TT
CLASS="FILENAME"
>@authdaemonvar@</TT
> should be owned by root, and have no
group or
world permissions.
For the <SPAN
CLASS="PRODUCTNAME"
>Courier mail server</SPAN
>,
<TT
CLASS="FILENAME"
>@authdaemonvar@</TT
>
should be owned by the userid that Courier is installed under, and it must be
readable and writable by the Courier user and group (but no world
permissions).</P
></DIV
><DIV
CLASS="REFSECT2"
><A
NAME="AEN195"
></A
><H3
>Configuring <TT
CLASS="LITERAL"
>authdaemond</TT
></H3
><P
>The <TT
CLASS="FILENAME"
>@authdaemonrc@</TT
> configuration file sets several
operational parameters for the <TT
CLASS="FILENAME"
>authdaemond</TT
> process. See
the comments in the
default file installed for more information. Currently,
<TT
CLASS="FILENAME"
>@authdaemonrc@</TT
> sets two parameters: number of daemon
processes,
and authentication modules/process that will be used.</P
><P
>Although <TT
CLASS="FILENAME"
>authdaemond</TT
> might include several
authentication modules, not all of them may be used.
This makes it possible to install the same
<B
CLASS="COMMAND"
>authdaemond</B
> build on multiple
systems with different authentication needs. The default module list specified
in <TT
CLASS="FILENAME"
>@authdaemonrc@</TT
> would be a list of all the available
authentication modules.</P
><P
><B
CLASS="COMMAND"
>@libexecdir@/authlib/authdaemond</B
> is actually a very short
shell script that executes the real <B
CLASS="COMMAND"
>authdaemond</B
> program.
The available programs are <B
CLASS="COMMAND"
>authdaemond.plain</B
>,
<B
CLASS="COMMAND"
>authdaemond.ldap</B
>,
<B
CLASS="COMMAND"
>authdaemond.mysql</B
>, and
<B
CLASS="COMMAND"
>authdaemond.pgsql</B
>.
The "plain" program contains all the authentication modules except for
<TT
CLASS="LITERAL"
>authldap</TT
>,
<TT
CLASS="LITERAL"
>authmysql</TT
>, and
<TT
CLASS="LITERAL"
>authpgsql</TT
>.
The "ldap" program includes all the authentication modules in "plain",
plus <TT
CLASS="LITERAL"
>authldap</TT
>
Ditto for the "mysql" and "pgsql" processes.</P
><P
>This arrangement allows convenient creation of pre-configured binary
packages.
The <B
CLASS="COMMAND"
>authdaemond</B
> shell script runs
<B
CLASS="COMMAND"
>authdaemond.plain</B
> only if none of the other processes
are installed on the system.
First, it checks if
<B
CLASS="COMMAND"
>authdaemond.ldap</B
>,
<B
CLASS="COMMAND"
>authdaemond.mysql</B
>, or
<B
CLASS="COMMAND"
>authdaemond.pgsql</B
> is installed.
If not, <B
CLASS="COMMAND"
>authdaemond.plain</B
> is brought up.
This makes it possible to prepare a basic binary package that provides
only basic authentication services and does not require either LDAP,
MySQL, or PostgreSQL runtime support on the server.
If either of these authentication requirements are needed, a separate
binary sub-package will load the appropriate <B
CLASS="COMMAND"
>authdaemond</B
>
process.</P
><P
>Note that it is not possible to use both LDAP and MySQL, for example,
authentication at the same time.
That's because their support is in different
<B
CLASS="COMMAND"
>authdaemond</B
> processes, and only one
<B
CLASS="COMMAND"
>authdaemond</B
> process can run at the same time.
If both (or all three non-plain processes) are installed, the
<B
CLASS="COMMAND"
>authdaemond</B
> script picks either the first one it finds,
or whatever is explicitly specified in the
<TT
CLASS="FILENAME"
>@authdaemonrc@</TT
> configuration file.</P
><P
>The number of <B
CLASS="COMMAND"
>authdaemond</B
> processes is also set in this
configuration file. The more processes that are started, the more
authentication requests can be handled. If
<B
CLASS="COMMAND"
>authdaemon</B
> does not
receive an answer within a moderate amount of time, it will declare an
authentication failure, and abort. Try increasing the number of processes if
you start seeing random authentication failures. However, that should only be
used as a stop-gap measure. If the default number of
<B
CLASS="COMMAND"
>authdaemond</B
>
processes proves to be insufficient, it is far more likely that more resources
are needed for the server: more RAM, a faster disk, or a faster CPU, at least
in the humble opinion of the author. Increasing the number of processes should
only be used as a stop-gap measure, until a more thorough analysis on the
bottleneck can be made.</P
><A
NAME="AEN234"
></A
><BLOCKQUOTE
CLASS="BLOCKQUOTE"
><DIV
CLASS="INFORMALEXAMPLE"
><P
></P
><A
NAME="AEN235"
></A
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>@libexecdir@/authlib/authdaemond restart</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
></BLOCKQUOTE
><P
>Run the above command after making any changes to
<TT
CLASS="FILENAME"
>@authdaemonrc@</TT
>.
"<B
CLASS="COMMAND"
>authdaemond restart</B
>"
is required for any changes to take effect.</P
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN240"
></A
><H2
>AUTHENTICATION PROTOCOL</H2
><P
>The rest of this documentation describes the internal protocol used by
this authentication library.
It is only of interest to developers who wish to extend the authentication
library to support a custom authentication module,
or a derived extension to an existing module.</P
><P
>The original implementation of this authentication library used small,
self-contained, binary programs, named for their authentication module:
<TT
CLASS="LITERAL"
>authldap</TT
>,
<TT
CLASS="LITERAL"
>authpam</TT
>, and others.
Later, the <TT
CLASS="LITERAL"
>authdaemon</TT
> module came about, which wrapped
the other authentication modules into a separate background daemon
process, which communicated with the <TT
CLASS="LITERAL"
>authdaemon</TT
> module.
The <TT
CLASS="LITERAL"
>authdaemon</TT
> module is now always enabled by default,
but it is still possible to build and install each authentication module
as a self-contained binary program.
Note, however, that applications such as
<A
HREF="http://www.courier-mta.org/sqwebmail/"
TARGET="_top"
><TT
CLASS="APPLICATION"
>SqWebMail</TT
></A
>,
and
<A
HREF="http://www.courier-mta.org/"
TARGET="_top"
><TT
CLASS="APPLICATION"
>Courier</TT
></A
>
link directly with all the authentication modules, and will not use external
modules for authentication.</P
><P
><TT
CLASS="LITERAL"
>authdaemon</TT
> came about as a direct result of technical
issues that prevented <TT
CLASS="APPLICATION"
>SqWebMail</TT
> and
<TT
CLASS="APPLICATION"
>Courier</TT
> from using external binary modules.
<TT
CLASS="LITERAL"
>authdaemond</TT
> is really nothing more than
a simple application that
links directly with the authentication modules, and talks to the
<TT
CLASS="LITERAL"
>authdaemon</TT
> authentication module that follows this
authentication protocol.</P
><DIV
CLASS="REFSECT2"
><A
NAME="AEN259"
></A
><H3
>Stand-alone authentication modules</H3
><P
>This section describes the authentication protocol for self-contained
authentication modules.
Although the default configuration no longer uses self-contained modules,
the stand-alone protocol serves as a foundation for the protocol used by
authentication modules as part of the <TT
CLASS="LITERAL"
>authdaemond</TT
>
authentication process, or when they are linked directly with the application
that uses this authentication library.</P
><P
>Here's the typical way that stand-alone authentication modules are used:</P
><P
>1. A list of authentication modules are read from a configuration file.
Multiple authentication modules could be available, but not all of them
are required in most situations.</P
><P
>2. The application executes the following command:</P
><A
NAME="AEN266"
></A
><BLOCKQUOTE
CLASS="BLOCKQUOTE"
><DIV
CLASS="INFORMALEXAMPLE"
><P
></P
><A
NAME="AEN267"
></A
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>LOGIN AUTHMODULE1 AUTHMODULE2 ... APP</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
></BLOCKQUOTE
><P
><TT
CLASS="LITERAL"
>LOGIN</TT
> is a full pathname to an application that reads
the authentication information, such as the userid and a password.
Arguments to <TT
CLASS="LITERAL"
>LOGIN</TT
> are full pathnames to each
authentication module (if there are more than one), followed by a full
pathname to the main application.</P
><P
>3. <TT
CLASS="LITERAL"
>LOGIN</TT
> reads the userid and password, then runs
the program specified by its first argument, which is the first
authentication module.
The remaining arguments are passed to the new process.
The mechanism by which the authentication information is passed to the
authentication module is described later.</P
><P
>4. Each authentication module reads the authentication information, and
determines if the previous authentication module succesfully processed
the authentication request.
If not, the module attempts to authenticate it itself.
In any event, the module runs the next program specified by its first
argument, and the remaining arguments are passed along to the next
program.
If any previous authentication module succesfully processed the
authentication request, the next program is run immediately without
any further processing.</P
><P
>5. Eventually, <TT
CLASS="LITERAL"
>APP</TT
> runs,
<TT
CLASS="LITERAL"
>APP</TT
> reads the authentication information and
determines whether any authentication module managed to succesfully
process the authentication request.
If so, <TT
CLASS="LITERAL"
>APP</TT
> runs normally.
Otherwise, <TT
CLASS="LITERAL"
>APP</TT
> runs <TT
CLASS="LITERAL"
>LOGIN</TT
> with its
original arguments in order to return an error message ("Password invalid",
or something similar) and read the next authentication request.</P
><P
>Daisy-chaining authentication modules, in this fashion, makes it possible
to have hybrid systems that use multiple authentication modules.
Example: using <TT
CLASS="LITERAL"
>authpam</TT
> to authenticate system accounts,
and <TT
CLASS="LITERAL"
>authmysql</TT
> to authentication virtual mailboxes without
a corresponding system account.</P
><P
>Here's a more detailed description of the overall process:</P
><DIV
CLASS="REFSECT3"
><A
NAME="AEN285"
></A
><H4
>The <TT
CLASS="LITERAL"
>LOGIN</TT
> process</H4
><P
>The <TT
CLASS="LITERAL"
>LOGIN</TT
> process checks if the <TT
CLASS="LITERAL"
>AUTHARGC</TT
>
environment variable is set. If not, this is the first time the
<TT
CLASS="LITERAL"
>LOGIN</TT
> process comes up, and <TT
CLASS="LITERAL"
>LOGIN</TT
>
displays the initial login prompt. Additionally, the command line arguments
to <TT
CLASS="LITERAL"
>LOGIN</TT
> are
literal copied to the <TT
CLASS="LITERAL"
>AUTHARGC</TT
>
and <TT
CLASS="LITERAL"
>AUTHARGVn</TT
> environment variables.
That is: the number of command line arguments is saved in
<TT
CLASS="LITERAL"
>AUTHARGC</TT
>; the zeroth command line argument is saved in
<TT
CLASS="LITERAL"
>AUTHARGV0</TT
>; the remaining command line arguments are saved
in <TT
CLASS="LITERAL"
>AUTHARGV1</TT
>, <TT
CLASS="LITERAL"
>AUTHARGV2</TT
>,
and so on.</P
><P
>After obtaining the authentication information (such as the userid and
password), <TT
CLASS="LITERAL"
>LOGIN</TT
> creates a pipe, and arranges for the
output end of the pipe to be located on file descriptor #3.
The <TT
CLASS="LITERAL"
>LOGIN</TT
> process forks; the original process then
executes the first authentication module, in the manner described earlier;
the child process writes the authentication record to the pipe, then
terminates.</P
><P
>The authentication record is a chunk of data in the following
format:</P
><A
NAME="AEN304"
></A
><BLOCKQUOTE
CLASS="BLOCKQUOTE"
><P
> <SAMP
CLASS="COMPUTEROUTPUT"
><VAR
CLASS="REPLACEABLE"
>SERVICE</VAR
><SPAN
CLASS="TOKEN"
><NEWLINE></SPAN
><VAR
CLASS="REPLACEABLE"
>AUTHTYPE</VAR
><SPAN
CLASS="TOKEN"
><NEWLINE></SPAN
><VAR
CLASS="REPLACEABLE"
>AUTHDATA</VAR
></SAMP
>
</P
></BLOCKQUOTE
><P
>Each occurence of <SPAN
CLASS="TOKEN"
><NEWLINE></SPAN
> represents an ASCII linefeed
character (#10).
"<TT
CLASS="LITERAL"
>SERVICE</TT
>" identifies the service that originates the
authentication request, such as "imap", or "webmail".
Authentication module may use this identifier, or ignore it.</P
><P
>"<TT
CLASS="LITERAL"
>AUTHTYPE</TT
>" identifies the format of the authentication
request.
Everything after the second <SPAN
CLASS="TOKEN"
><NEWLINE></SPAN
> is an opaque blob
of data, whose format is determined by <TT
CLASS="LITERAL"
>AUTHTYPE</TT
>.</P
><DIV
CLASS="NOTE"
><P
></P
><TABLE
CLASS="NOTE"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
>NOTE:</TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>There's a theoretical upper limit on the maximum size of the authentication
record. It is high enough not to matter in most situations
(the total number of characters allowed cannot be
more than 8189 characters on a typical GNU/Linux system).</P
></TD
></TR
></TABLE
></DIV
><P
>The following <TT
CLASS="LITERAL"
>AUTHTYPE</TT
> formats are currently defined:</P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
><TT
CLASS="LITERAL"
>login</TT
></DT
><DD
><P
>A typical userid/password authentication request. <TT
CLASS="LITERAL"
>AUTHDATA</TT
> contains the following data:
<VAR
CLASS="REPLACEABLE"
>userid</VAR
><SPAN
CLASS="TOKEN"
><NEWLINE></SPAN
><VAR
CLASS="REPLACEABLE"
>password</VAR
><SPAN
CLASS="TOKEN"
><NEWLINE></SPAN
>.</P
></DD
><DT
><TT
CLASS="LITERAL"
>cram-md5</TT
></DT
><DD
><P
>Specifies the <TT
CLASS="LITERAL"
>CRAM-MD5</TT
>
authentication request.
<TT
CLASS="LITERAL"
>AUTHDATA</TT
> contains the following data:
<VAR
CLASS="REPLACEABLE"
>challenge</VAR
><SPAN
CLASS="TOKEN"
><NEWLINE></SPAN
><VAR
CLASS="REPLACEABLE"
>response</VAR
><SPAN
CLASS="TOKEN"
><NEWLINE></SPAN
>.
The "<SPAN
CLASS="TOKEN"
>challenge</SPAN
>" and "<SPAN
CLASS="TOKEN"
>response</SPAN
>" strings are
base64-encoded.</P
></DD
><DT
><TT
CLASS="LITERAL"
>cram-sha1</TT
></DT
><DD
><P
>Specifies the <TT
CLASS="LITERAL"
>CRAM-SHA1</TT
>
authentication request, instead of CRAM-MD5, and uses the same format for
<TT
CLASS="LITERAL"
>AUTHDATA</TT
>.</P
></DD
></DL
></DIV
></DIV
><DIV
CLASS="REFSECT3"
><A
NAME="AEN354"
></A
><H4
>The authentication module</H4
><P
>The first thing an authentication module does is check if the environment
variable <TT
CLASS="LITERAL"
>AUTHENTICATED</TT
> is set to a non-empty string.
If so, it means that a previous authentication module has handled the
authentication request, so this module simply runs the next program,
specified by the first argument to this authentication module.</P
><P
>Otherwise, the authentication module reads the authentication record from
file descriptor #3, and determines whether it wants to try this
authentication record.
If not, the module creates a new pipe, arranges the output of the pipe
to be on file descriptor #3, forks, the parent process runs the next
authentication module, and the child process writes the authentication
record to the pipe, then exits.</P
><P
>There are two ways to handle an authentication request:
1) Use the <TT
CLASS="LITERAL"
>AUTHARGC</TT
> and <TT
CLASS="LITERAL"
>AUTHARGVn</TT
>
variables to restart the entire authentication process - this is used
in the event it is determined that the authentication request must be
failed, or 2) run the next daisy-changed module, in the manner described
previously, when it is determined that another authentication module can
attempt to try to handle this request.</P
><P
>The following action occurs when
the authentication module succesfully validates an authentication request:</P
><P
>1. The authenticated login ID is saved in the <TT
CLASS="LITERAL"
>AUTHENTICATED</TT
>
environment variable.</P
><P
>2. The process's userid and groupid are reset to the corresponding
userid and groupid of the authenticated login id, and the current directory
is set to the process's defined home directory.</P
><P
>3. Some additional environment variables may also be initialized:
<TT
CLASS="LITERAL"
>AUTHFULLNAME</TT
> - the login ID's full name;
<TT
CLASS="LITERAL"
>MAILDIR</TT
> - the login ID's default maildir mailbox;
<TT
CLASS="LITERAL"
>MAILDIRQUOTA</TT
> - the requested maildir quota.</P
></DIV
><DIV
CLASS="REFSECT3"
><A
NAME="AEN370"
></A
><H4
>The application process</H4
><P
>Eventually, <TT
CLASS="LITERAL"
>APP</TT
> runs.
The process closes file descriptor #3 (if it's open, and ignores the error
if file descriptor #3 does not exist).
If the <TT
CLASS="LITERAL"
>AUTHENTICATED</TT
> environment variable is set,
it must mean that an authentication module was able to handle this
authentication request, so <TT
CLASS="LITERAL"
>APP</TT
> starts up and runs normally.
Otherwise the
original command is reconstructed from the
<TT
CLASS="LITERAL"
>AUTHARGC</TT
> and <TT
CLASS="LITERAL"
>AUTHARGVn</TT
>
variables, and the initial login process runs again.</P
></DIV
><DIV
CLASS="REFSECT3"
><A
NAME="AEN378"
></A
><H4
>Library functions</H4
><P
>This authentication library provides several convenient functions which
can be used to quickly create a compliant login process, and its
corresponding application.
The login process should be structured as follows:</P
><A
NAME="AEN381"
></A
><BLOCKQUOTE
CLASS="BLOCKQUOTE"
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN382"
></A
><P
><B
>Example 1. A sample LOGIN process</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>int main(int argc, char **argv)
{
if (authmoduser(argc, argv, TIMEOUT, ERR_TIMEOUT))
{
/* Print initial greeting here */
}
else
{
/* Error: invalid userid/password */
}
/* read userid and password */
authmod(argc-1, argv+1, SERVICE, AUTHTYPE, AUTHDATA);
}</PRE
></TD
></TR
></TABLE
></DIV
></BLOCKQUOTE
><P
>The <TT
CLASS="FUNCTION"
>authmoduser</TT
> function takes care of copying
the command line parameters to their corresponding environment variables,
and checking whether or not this is the initial time this process runs,
or if it is running again after a failed authentication process.
<TT
CLASS="LITERAL"
>TIMEOUT</TT
> specifies the absolute login timeout,
<TT
CLASS="FUNCTION"
>authmoduser</TT
> quietly terminates the process if it
runs due to a failed authentication request and at least
<TT
CLASS="LITERAL"
>TIMEOUT</TT
> seconds have elapsed since the first time
<TT
CLASS="FUNCTION"
>authmoduser</TT
> was run.
<TT
CLASS="LITERAL"
>ERR_TIMEOUT</TT
> specifies the number of seconds that
<TT
CLASS="FUNCTION"
>authmoduser</TT
> will sleep after a failed
authentication request.</P
><P
>The <TT
CLASS="LITERAL"
>SERVICE</TT
>, <TT
CLASS="LITERAL"
>AUTHTYPE</TT
>, and
<TT
CLASS="LITERAL"
>AUTHDATA</TT
> arguments to <TT
CLASS="FUNCTION"
>authmod</TT
>
are null-terminated character strings that form the authentication request.
<TT
CLASS="FUNCTION"
>authmod</TT
> takes care of setting up the pipe to the
first authentication module, and runs it.</P
><P
>The application process is even simpler:</P
><A
NAME="AEN400"
></A
><BLOCKQUOTE
CLASS="BLOCKQUOTE"
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN401"
></A
><P
><B
>Example 2. A sample APP process</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>int main(int argc, char **argv)
{
const char *loginid=authmodclient();
/* Application begins normally */
}</PRE
></TD
></TR
></TABLE
></DIV
></BLOCKQUOTE
><P
>The <TT
CLASS="FUNCTION"
>authmodclient</TT
> function returns the authenticated
login ID.
If the authentication request failed, <TT
CLASS="FUNCTION"
>authmodclient</TT
>
reruns the original login process, and doesn't return.</P
></DIV
></DIV
><DIV
CLASS="REFSECT2"
><A
NAME="AEN407"
></A
><H3
>Inside an authentication modules</H3
><P
>An authentication module needs to define the following structure:</P
><A
NAME="AEN410"
></A
><BLOCKQUOTE
CLASS="BLOCKQUOTE"
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN411"
></A
><P
><B
>Example 3. struct authstaticinfo</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>struct authstaticinfo {
const char *auth_name;
char * (*auth_func)(const char *, const char *, char *, int,
void (*)(struct authinfo *, void *),
void *);
int (*auth_prefunc)(const char *, const char *,
int (*)(struct authinfo *, void *),
void *);
void (*auth_cleanupfunc)();
int (*auth_changepwd)(const char *, /* service */
const char *, /* userid */
const char *, /* oldpassword */
const char *); /* new password */
} ;</PRE
></TD
></TR
></TABLE
></DIV
></BLOCKQUOTE
><P
><TT
CLASS="FUNCTION"
>auth_func</TT
> points to a function that handles the
authentication request.
If succesful, <TT
CLASS="FUNCTION"
>auth_func</TT
> is responsible for resetting
the userid and groupid, changing to the authentication account's home
directory, and setting up the necessary environment variables.
The first three arguments to <TT
CLASS="FUNCTION"
>auth_func</TT
> will be
<TT
CLASS="LITERAL"
>SERVICE</TT
>, <TT
CLASS="LITERAL"
>AUTHTYPE</TT
>, and
<TT
CLASS="LITERAL"
>AUTHDATA</TT
>.
The next argument is a boolean flag which is non-zero if the authentication
code is being called in the context of a stand-alone authentication module,
or zero if the authentication code is called directly by an application.
The fifth argument points is a callback function pointer, which
may be NULL.
If it's not null, <TT
CLASS="FUNCTION"
>auth_func</TT
> should not reset
the userid, groupid, or the home directory of this process, but
should instead initialize the <CODE
CLASS="STRUCTNAME"
>authinfo</CODE
>
structure, which is defined as follows:</P
><A
NAME="AEN423"
></A
><BLOCKQUOTE
CLASS="BLOCKQUOTE"
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN424"
></A
><P
><B
>Example 4. struct authinfo</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>struct authinfo {
const char *sysusername;
const uid_t *sysuserid;
gid_t sysgroupid;
const char *homedir;
const char *address; /* The E-mail address */
const char *fullname; /* gecos, etc... */
const char *maildir;
const char *quota;
const char *passwd;
const char *clearpasswd; /* For authldap */
unsigned staticindex; /* When statically-linked functions are
** called, this holds the index of the
** authentication module in authstaticlist */
} ;</PRE
></TD
></TR
></TABLE
></DIV
></BLOCKQUOTE
><P
>The
<CODE
CLASS="STRUCTFIELD"
>passwd</CODE
>,
<CODE
CLASS="STRUCTFIELD"
>clearpasswd</CODE
>, and
<CODE
CLASS="STRUCTFIELD"
>staticindex</CODE
> fields are not used by
<TT
CLASS="FUNCTION"
>auth_func</TT
>.
Either <CODE
CLASS="STRUCTFIELD"
>sysusername</CODE
> or
<CODE
CLASS="STRUCTFIELD"
>sysuserid</CODE
> must be a non-NULL pointer.
<CODE
CLASS="STRUCTFIELD"
>sysuserid</CODE
> specifies an explicit userid,
otherwise <CODE
CLASS="STRUCTFIELD"
>sysusername</CODE
> is looked up in the
password file.</P
><P
>The last argument to <TT
CLASS="FUNCTION"
>auth_func</TT
> is an opaque
pointer that gets passed as the second argument to the callback
function.</P
><P
><TT
CLASS="FUNCTION"
>auth_func</TT
>
should return a pointer to the authenticated loginid, in dynamic memory
(the memory should be <TT
CLASS="FUNCTION"
>free()</TT
>ed after user.
A NULL return indicates an authentication failure.
The authentication module should set <SPAN
CLASS="SYMBOL"
>errno</SPAN
> to
<TT
CLASS="LITERAL"
>EPERM</TT
> in the event that it the next authentication module
should have a chance to process the authentication request, or use
any other <SPAN
CLASS="SYMBOL"
>errno</SPAN
> value to immediately fail the authentication
request, and rerun the original login process.</P
></DIV
><DIV
CLASS="REFSECT2"
><A
NAME="AEN444"
></A
><H3
>Linked authentication modules</H3
><P
>The <TT
CLASS="FUNCTION"
>auth_prefunc</TT
>,
<TT
CLASS="FUNCTION"
>auth_cleanupfunc</TT
>,
and <TT
CLASS="FUNCTION"
>auth_changepwd</TT
> functions are not used by
stand-alone modules, but when the authentication module is directly
linked with an application.</P
><P
><TT
CLASS="FUNCTION"
>auth_prefunc</TT
> verifies that the requested userid
exists.
No passwords are validated, the first two arguments to
<TT
CLASS="FUNCTION"
>auth_prefunc</TT
> are the userid, and
<TT
CLASS="LITERAL"
>SERVICE</TT
>.
<TT
CLASS="FUNCTION"
>auth_prefunc</TT
> should initialize an
<CODE
CLASS="STRUCTNAME"
>authinfo</CODE
> structure, and run the
callback function, the third argument to
<TT
CLASS="FUNCTION"
>auth_prefunc</TT
>.
The callback function receives the fourth argument to
<TT
CLASS="FUNCTION"
>auth_prefunc</TT
> as an opaque pointer.</P
><P
><TT
CLASS="FUNCTION"
>auth_prefunc</TT
> should come back with the callback
function's return code, if the requested userid was found.
Otherwise,
<TT
CLASS="FUNCTION"
>auth_prefunc</TT
> should return a non-zero integer.
A positive integer should be return in the event that this authentication
request should be stopped, and a negative itneger if another authentication
module can be tried.
An application that links against this authentication library will run
each configured authentication module's
<TT
CLASS="FUNCTION"
>auth_prefunc</TT
>,
until some module is able to process the requested userid, or until
<TT
CLASS="FUNCTION"
>auth_prefunc</TT
> comes back with a non-zero positive
return code.</P
><P
><TT
CLASS="FUNCTION"
>auth_func</TT
> or
<TT
CLASS="FUNCTION"
>auth_prefunc</TT
> might allocate some internal resources,
which should be freed by calling
<TT
CLASS="FUNCTION"
>auth_cleanupfunc</TT
>.</P
><P
>The <TT
CLASS="FUNCTION"
>auth_changepwd</TT
>
function is called to implement the change password functionality.</P
></DIV
><DIV
CLASS="REFSECT2"
><A
NAME="AEN469"
></A
><H3
>Other authentication library function</H3
><P
>This authentication library contains several functions and macros that
can be helpful in building authentication modules.</P
><A
NAME="AEN472"
></A
><BLOCKQUOTE
CLASS="BLOCKQUOTE"
><DIV
CLASS="EXAMPLE"
><A
NAME="AEN473"
></A
><P
><B
>Example 5. Turning <TT
CLASS="FUNCTION"
>auth_func</TT
> into a module</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define MODULE auth_func
#include "mod.h"</PRE
></TD
></TR
></TABLE
></DIV
></BLOCKQUOTE
><P
><TT
CLASS="FILENAME"
>mod.h</TT
> contains template code that reads an authentication
request from the previous authentication module, call
<TT
CLASS="FUNCTION"
>auth_func</TT
>, in such a manner, and appropriately
run the next module in the authentication chain.</P
><P
>The <TT
CLASS="FILENAME"
>auth.h</TT
> header file also declares several useful
functions that authentication-related code may find convenient.</P
><DIV
CLASS="REFSECT3"
><A
NAME="AEN482"
></A
><H4
>Building <B
CLASS="COMMAND"
>authdaemond</B
></H4
><P
>This authentication library builds alternate versions of the
<B
CLASS="COMMAND"
>authdaemond</B
> background process.
Some authentication modules have dependencies on external libraries,
such as
<TT
CLASS="LITERAL"
>authldap</TT
>,
<TT
CLASS="LITERAL"
>authmysql</TT
>, and
<TT
CLASS="LITERAL"
>authpgsql</TT
>.
The authentication library prepares separate versions of
<B
CLASS="COMMAND"
>authdaemond</B
> for each authentication module with a
dependency.
Each one of these <B
CLASS="COMMAND"
>authdaemond</B
> versions will also include
all other authentication modules that do not have dependencies.</P
><P
>The authentication module configuration for each
<B
CLASS="COMMAND"
>authdaemond</B
>
is set in the
<TT
CLASS="FILENAME"
>authdaemond.versions</TT
> file.
A new authentication module will have to be added to
<TT
CLASS="FILENAME"
>authdaemond.versions</TT
> (potentially creating another
<B
CLASS="COMMAND"
>authdaemond</B
> build).
The <TT
CLASS="FILENAME"
>configure</TT
> script must be run after making any
changes to <TT
CLASS="FILENAME"
>authdaemond.versions</TT
>.</P
></DIV
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN499"
></A
><H2
>FILES</H2
><P
><TT
CLASS="FILENAME"
> @sysconfdir@/authmodulelist</TT
> - list of authentication
modules read by applications that directly link with
<TT
CLASS="FILENAME"
>authlib</TT
></P
><P
><TT
CLASS="FILENAME"
> @sysconfdir@/authdaemonrc</TT
> - <B
CLASS="COMMAND"
>authdaemond</B
> configuration file</P
><P
><TT
CLASS="FILENAME"
> @sysconfdir@/authldaprc</TT
> - <B
CLASS="COMMAND"
>authldap</B
> configuration file</P
><P
><TT
CLASS="FILENAME"
> @sysconfdir@/authmysqlrc</TT
> - <B
CLASS="COMMAND"
>authmysql</B
> configuration file</P
><P
><TT
CLASS="FILENAME"
> @sysconfdir@/authpgsqlrc</TT
> - <B
CLASS="COMMAND"
>authpgsql</B
> configuration file</P
></DIV
><DIV
CLASS="REFSECT1"
><A
NAME="AEN516"
></A
><H2
>SEE ALSO</H2
><P
><A
HREF="courier.html"
TARGET="_top"
><SPAN
CLASS="CITEREFENTRY"
><SPAN
CLASS="REFENTRYTITLE"
>courier</SPAN
>(8)</SPAN
></A
>,
<A
HREF="userdb.html"
TARGET="_top"
><SPAN
CLASS="CITEREFENTRY"
><SPAN
CLASS="REFENTRYTITLE"
>userdb</SPAN
>(8)</SPAN
></A
></P
></DIV
></BODY
></HTML
>
|