Fix docs. Change argument of the field-map configuration statement
The field-map statement (.ldap.field-map & .sql.field-map) takes a list of mappings as argument. For compatibility and for internal purposes, a string is still allowed. * doc/texinfo/programs.texi: Update. * include/mailutils/cfg.h (mu_cfg_field_map): New proto. * include/mailutils/sql.h (mu_password_type): Rename. (mu_sql_module_config) <positional>: Remove. (mu_sql_decode_password_type): Remove prototype. * libmailutils/base/mutil.c (mu_sql_decode_password_type): Remove function. * libmailutils/cfg/driver.c (mu_cfg_field_map): New function. * libmu_auth/ldap.c (cb_field_map): Use mu_cfg_field_map. (module_init): Fix default filter. * libmu_auth/sql.c (cb_field_map): Use mu_cfg_field_map. (mu_sql_param): Rename "password-type" statement to "password-encryption". Remove the "positional" statement.
Showing
9 changed files
with
558 additions
and
215 deletions
... | @@ -231,7 +231,7 @@ Don't load site-wide and user configuration files. | ... | @@ -231,7 +231,7 @@ Don't load site-wide and user configuration files. |
231 | 231 | ||
232 | @xopindex{set, introduced} | 232 | @xopindex{set, introduced} |
233 | @item --set=@var{path}=@var{value} | 233 | @item --set=@var{path}=@var{value} |
234 | Set configuration variable. | 234 | Set configuration variable. @xref{the --set option}. |
235 | @end table | 235 | @end table |
236 | 236 | ||
237 | @node configuration | 237 | @node configuration |
... | @@ -292,12 +292,10 @@ following warning will be issued: | ... | @@ -292,12 +292,10 @@ following warning will be issued: |
292 | 292 | ||
293 | Client utilities, such as @command{frm} or @command{sieve}, look in | 293 | Client utilities, such as @command{frm} or @command{sieve}, look in |
294 | the user home directory for a file named @samp{.@var{prog}}, where | 294 | the user home directory for a file named @samp{.@var{prog}}, where |
295 | @var{prog} is the name of the utility. If it is present, it will be | 295 | @var{prog} is the name of the utility. If present, this file will be |
296 | loaded after loading the site-wide configuration file. This file | 296 | loaded after loading the site-wide configuration file. For example, |
297 | allows users to customize such utilities. | 297 | the per-user configuration file for @command{sieve} utility is named |
298 | 298 | @file{.sieve}. | |
299 | For example, the per-user configuration file for @command{sieve} | ||
300 | utility is named @file{.sieve}. | ||
301 | 299 | ||
302 | @xopindex{no-user-config, described} | 300 | @xopindex{no-user-config, described} |
303 | Loading of per-user configuration file is disabled by | 301 | Loading of per-user configuration file is disabled by |
... | @@ -320,40 +318,42 @@ case, default configuration files are not used at all. | ... | @@ -320,40 +318,42 @@ case, default configuration files are not used at all. |
320 | 318 | ||
321 | @xopindex{config-verbose, described} | 319 | @xopindex{config-verbose, described} |
322 | Neither site-wide nor user configuration files are required to | 320 | Neither site-wide nor user configuration files are required to |
323 | exist. If any or both of them are absent, GNU Mailutils does not | 321 | exist. If any or both of them are absent, GNU Mailutils won't |
324 | complain, and the utility falls back to its default settings. To make | 322 | complain -- the utility will silently fall back to its default |
325 | configuration processing more verbose, use the | 323 | settings. |
324 | |||
325 | To make configuration processing more verbose, use the | ||
326 | @option{--config-verbose} command line option. Here is an example of | 326 | @option{--config-verbose} command line option. Here is an example of |
327 | what you might get using this option: | 327 | what you might get using this option: |
328 | 328 | ||
329 | @example | 329 | @example |
330 | imap4d: Info: parsing file `/etc/mailutils.rc' | 330 | imap4d: parsing file `/etc/mailutils.conf' |
331 | imap4d: Info: finished parsing file `/etc/mailutils.rc' | 331 | imap4d: finished parsing file `/etc/mailutils.conf' |
332 | @end example | 332 | @end example |
333 | 333 | ||
334 | Specifying this option more than once adds more verbosity to this | 334 | Specifying this option more than once adds more verbosity to this |
335 | output. If this option is given two times, GNU Mailutils will print | 335 | output. If this option is given two times, GNU Mailutils will print |
336 | any configuration file statement it parsed, along with the exact | 336 | each configuration file statement it parsed, along with the exact |
337 | location where it occurred (the exact meaning of each statement will | 337 | location where it occurred (the exact meaning of each statement will |
338 | be described later in this chapter): | 338 | be described later in this chapter): |
339 | 339 | ||
340 | @example | 340 | @example |
341 | imap4d: Info: parsing file `/etc/mailutils.rc' | 341 | imap4d: parsing file `/etc/mailutils.conf' |
342 | @hashchar{} 1 "/etc/mailutils.rc" | 342 | @hashchar{} 1 "/etc/mailutils.conf" |
343 | mailbox @{ | 343 | mailbox @{ |
344 | @hashchar{} 2 "/etc/mailutils.rc" | 344 | @hashchar{} 2 "/etc/mailutils.conf" |
345 | mailbox-pattern maildir:/var/spool/mail;type=index;param=2;user=$@{user@}; | 345 | mailbox-pattern maildir:/var/spool/mail;type=index;param=2;user=$@{user@}; |
346 | @hashchar{} 3 "/etc/mailutils.rc" | 346 | @hashchar{} 3 "/etc/mailutils.conf" |
347 | mailbox-type maildir; | 347 | mailbox-type maildir; |
348 | @}; | 348 | @}; |
349 | @hashchar{} 6 "/etc/mailutils.rc" | 349 | @hashchar{} 6 "/etc/mailutils.conf" |
350 | include /etc/mailutils.d; | 350 | include /etc/mailutils.d; |
351 | imap4d: Info: parsing file `/etc/mailutils.d/imap4d' | 351 | imap4d: parsing file `/etc/mailutils.d/imap4d' |
352 | ... | 352 | ... |
353 | @end example | 353 | @end example |
354 | 354 | ||
355 | @xopindex{config-lint, described} | 355 | @xopindex{config-lint, described} |
356 | To test configuration file without actually starting the utility, | 356 | To test configuration file without actually running the utility, |
357 | use the @option{--config-lint} command line option. With this option, | 357 | use the @option{--config-lint} command line option. With this option, |
358 | any Mailutils utility exits after finishing parsing of the | 358 | any Mailutils utility exits after finishing parsing of the |
359 | configuration files. Any errors occurred during parsing are displayed | 359 | configuration files. Any errors occurred during parsing are displayed |
... | @@ -368,11 +368,11 @@ configuration file. For example, the simplest way to write a | ... | @@ -368,11 +368,11 @@ configuration file. For example, the simplest way to write a |
368 | configuration file for, say, @command{imap4d} is to run | 368 | configuration file for, say, @command{imap4d} is to run |
369 | 369 | ||
370 | @example | 370 | @example |
371 | $ imap4d --config-help > imap4d.rc | 371 | $ imap4d --config-help > imap4d.conf |
372 | @end example | 372 | @end example |
373 | 373 | ||
374 | @noindent | 374 | @noindent |
375 | and to edit the @file{imap4d.rc} file with your editor of choice. | 375 | and to edit the @file{imap4d.conf} file with your editor of choice. |
376 | 376 | ||
377 | The order in which configuration files are loaded defines the | 377 | The order in which configuration files are loaded defines the |
378 | precedence of their settings. Thus, for client utilities, settings | 378 | precedence of their settings. Thus, for client utilities, settings |
... | @@ -391,7 +391,8 @@ following: | ... | @@ -391,7 +391,8 @@ following: |
391 | $ imap4d --set .logging.syslog=no | 391 | $ imap4d --set .logging.syslog=no |
392 | @end example | 392 | @end example |
393 | 393 | ||
394 | Configuration pathnames are discussed in detail in @ref{Paths}. | 394 | Configuration pathnames are discussed in detail in @ref{Paths}. For a |
395 | detailed description of this option, @ref{the --set option}. | ||
395 | 396 | ||
396 | The @option{--set} options are processed after loading all | 397 | The @option{--set} options are processed after loading all |
397 | configuration files. | 398 | configuration files. |
... | @@ -716,6 +717,76 @@ component separator, e.g.: | ... | @@ -716,6 +717,76 @@ component separator, e.g.: |
716 | .program="a.out".bar.baz | 717 | .program="a.out".bar.baz |
717 | @end example | 718 | @end example |
718 | 719 | ||
720 | @anchor{the --set option} | ||
721 | The @option{--set} command line option allows you to set configuration | ||
722 | variables from the command line. Its argument consists of the | ||
723 | statement path and value, separated by a single equals sign (no | ||
724 | whitespace is permitted at either side of it). For example, the | ||
725 | following option: | ||
726 | |||
727 | @example | ||
728 | --set .logging.facility=mail | ||
729 | @end example | ||
730 | |||
731 | @noindent | ||
732 | has the same effect as the following statement in the configuration | ||
733 | file: | ||
734 | |||
735 | @example | ||
736 | logging @{ | ||
737 | facility mail; | ||
738 | @} | ||
739 | @end example | ||
740 | |||
741 | Values set using this option override those set in the configuration | ||
742 | files. This provides a convenient way for temporarily changing | ||
743 | configuration without altering configuration files. | ||
744 | |||
745 | Notice, that when using @option{--set}, the @samp{=} sign has two | ||
746 | purposes: first it separates statement path from the value, thus | ||
747 | forming an assignment, and secondly it can be used within the path | ||
748 | itself to introduce a tag. To illustrate this, let's assume you have | ||
749 | the following statement in your configuration file: | ||
750 | |||
751 | @example | ||
752 | @group | ||
753 | program pop3d @{ | ||
754 | logging @{ | ||
755 | facility mail; | ||
756 | @} | ||
757 | server 0.0.0.0 @{ | ||
758 | transcript no; | ||
759 | @} | ||
760 | @} | ||
761 | @end group | ||
762 | @end example | ||
763 | |||
764 | Now assume you wish to temporarily change logging facility to | ||
765 | @samp{local1}. The following option will do this: | ||
766 | |||
767 | @example | ||
768 | --set .program=pop3d.logging.facility=local1 | ||
769 | @end example | ||
770 | |||
771 | When splitting the argument to @option{--set}, the option parser | ||
772 | always looks for the rightmost equals sign. Everything to the right | ||
773 | of it is the value, and everything to the left of it - the path. | ||
774 | |||
775 | If the tag contains dots (as the @code{server} statement in the | ||
776 | example above), you should either escape them with slashes or change | ||
777 | the pathname separator to some other character, e.g.: | ||
778 | |||
779 | @example | ||
780 | --set .program=pop3d.server='0\.0\.0\.0'.transcript=yes | ||
781 | @end example | ||
782 | |||
783 | @noindent | ||
784 | or | ||
785 | |||
786 | @example | ||
787 | --set /program=pop3d/server="0.0.0.0"/transcript=yes | ||
788 | @end example | ||
789 | |||
719 | @node Variables | 790 | @node Variables |
720 | @subsection Configuration Variables | 791 | @subsection Configuration Variables |
721 | @cindex variable expansion | 792 | @cindex variable expansion |
... | @@ -767,15 +838,16 @@ each configuration statement. | ... | @@ -767,15 +838,16 @@ each configuration statement. |
767 | @anchor{Include} @c for backward-compatibility | 838 | @anchor{Include} @c for backward-compatibility |
768 | @cindex include statement, configuration file | 839 | @cindex include statement, configuration file |
769 | @kwindex include | 840 | @kwindex include |
770 | The @dfn{include statement} is a special statement that causes | 841 | A special statement is provided that causes inclusion of the named |
771 | inclusion of the named file. It has the following syntax: | 842 | file. It has the following syntax: |
772 | 843 | ||
773 | @example | 844 | @example |
774 | include @var{file}; | 845 | include @var{file}; |
775 | @end example | 846 | @end example |
776 | 847 | ||
777 | The effect of this statement is that the contents of this @var{file} is | 848 | When reading the configuration file, this statement is effectively |
778 | included in this point. | 849 | replaced with the content of @var{file}. It is an error if @var{file} |
850 | does not exist. | ||
779 | 851 | ||
780 | In site-wide configuration file, @var{file} can be a directory name. | 852 | In site-wide configuration file, @var{file} can be a directory name. |
781 | In this case, Mailutils will search this directory for a file with the | 853 | In this case, Mailutils will search this directory for a file with the |
... | @@ -815,11 +887,10 @@ temporary storage are processed. | ... | @@ -815,11 +887,10 @@ temporary storage are processed. |
815 | 887 | ||
816 | Notice the difference between this statement and a per-program | 888 | Notice the difference between this statement and a per-program |
817 | configuration file loaded via an @code{include} statement. No matter | 889 | configuration file loaded via an @code{include} statement. No matter |
818 | where in the file the @command{program} statement is, it is always | 890 | where in the file the @command{program} statement is, its content will |
819 | processed after the entire configuraion file is processed. In the | 891 | be processed after the content of the enclosing file. In the |
820 | contrast, the per-program configuration file loaded via @code{include} | 892 | contrast, the per-program configuration file loaded via @code{include} |
821 | with the directory name as its argument is processed right where it is | 893 | is processed right where it is encountered. |
822 | encountered. | ||
823 | 894 | ||
824 | @node logging statement | 895 | @node logging statement |
825 | @subsection The @code{logging} Statement | 896 | @subsection The @code{logging} Statement |
... | @@ -966,19 +1037,16 @@ favor of @code{mailbox-pattern} statement. | ... | @@ -966,19 +1037,16 @@ favor of @code{mailbox-pattern} statement. |
966 | The @code{mailbox-pattern} statement is a preferred way of configuring | 1037 | The @code{mailbox-pattern} statement is a preferred way of configuring |
967 | mailbox locations. It supersedes @code{mail-spool} statement. | 1038 | mailbox locations. It supersedes @code{mail-spool} statement. |
968 | 1039 | ||
969 | The @var{url} is valid mailbox URL (@pxref{Mailbox}), which | 1040 | The @var{url} must be a valid mailbox URL (@pxref{Mailbox}), which |
970 | may contain references to the @samp{user} variable | 1041 | may contain references to the @samp{user} variable |
971 | (@pxref{Variables}). This variable will be expanded to the actual | 1042 | (@pxref{Variables}). This variable will be expanded to the actual |
972 | user name. | 1043 | user name. |
973 | 1044 | ||
974 | @anchor{local URL parameters} | 1045 | @anchor{local URL parameters} |
975 | Optional URL parameters can be used to configure indexed directory | ||
976 | structure. | ||
977 | |||
978 | @cindex directory indexing | 1046 | @cindex directory indexing |
979 | An @dfn{indexed directory structure} is a special way of storing | 1047 | Optional URL parameters can be used to configure @dfn{indexed directory |
980 | mailboxes, which allows for faster access in case of very large | 1048 | structure}. Such structure is a special way of storing mailboxes, |
981 | number of users. | 1049 | which allows for faster access in case of very large number of users. |
982 | 1050 | ||
983 | By default, all user mailboxes are stored in a single directory and | 1051 | By default, all user mailboxes are stored in a single directory and |
984 | are named after user login names. To find the mailbox for a given | 1052 | are named after user login names. To find the mailbox for a given |
... | @@ -999,7 +1067,8 @@ user mailbox is determined using the following algorithm: | ... | @@ -999,7 +1067,8 @@ user mailbox is determined using the following algorithm: |
999 | @enumerate 1 | 1067 | @enumerate 1 |
1000 | @item Take the first letter of the user name. | 1068 | @item Take the first letter of the user name. |
1001 | @item Map it to a lower-case letter using @dfn{index mapping} | 1069 | @item Map it to a lower-case letter using @dfn{index mapping} |
1002 | table. The result gives sub-directory name. | 1070 | table. The result gives the name of a sub-directory where the mailbox |
1071 | is located. | ||
1003 | @item Descend into this directory. | 1072 | @item Descend into this directory. |
1004 | @end enumerate | 1073 | @end enumerate |
1005 | 1074 | ||
... | @@ -1041,7 +1110,7 @@ arguments: | ... | @@ -1041,7 +1110,7 @@ arguments: |
1041 | @table @asis | 1110 | @table @asis |
1042 | @kwindex type | 1111 | @kwindex type |
1043 | @item type=@var{value} | 1112 | @item type=@var{value} |
1044 | Specifies type of indexing. Valid values are @samp{index}, for direct | 1113 | Specifies the type of indexing. Valid values are @samp{index}, for direct |
1045 | indexed structure, @samp{rev-index} for reverse indexing, and | 1114 | indexed structure, @samp{rev-index} for reverse indexing, and |
1046 | @samp{hash} for hashed structure. | 1115 | @samp{hash} for hashed structure. |
1047 | 1116 | ||
... | @@ -1085,22 +1154,22 @@ If neither @code{mailbox-pattern} nor @code{mail-spool} are given, the | ... | @@ -1085,22 +1154,22 @@ If neither @code{mailbox-pattern} nor @code{mail-spool} are given, the |
1085 | mailbox names are determined using the following algorithm: | 1154 | mailbox names are determined using the following algorithm: |
1086 | 1155 | ||
1087 | @enumerate 1 | 1156 | @enumerate 1 |
1088 | @item If environment variable @env{FOLDER} its value is used. | 1157 | @item If environment variable @env{FOLDER} is set, use its value. |
1089 | @item Otherwise, if environment variable @env{MAIL} is set, its value | 1158 | @item Otherwise, if environment variable @env{MAIL} is set, use its |
1090 | is used. | 1159 | value. |
1091 | @item If neither of these is set, the mailbox name is constructed by | 1160 | @item If neither of these is set, construct the mailbox name by |
1092 | concatenating the built-in mail spool directory name, a directory | 1161 | concatenating the built-in mail spool directory name, a directory |
1093 | separator, and the user name. | 1162 | separator, and the user name. |
1094 | 1163 | ||
1095 | The built-in mail spool directory name is determined at compile | 1164 | The built-in mail spool directory name is determined at compile |
1096 | time, using @samp{_PATH_MAILDIR} define from the include file | 1165 | time, using the @samp{_PATH_MAILDIR} define from the include file |
1097 | @file{paths.h}. If this value is not defined, @file{/var/mail} or | 1166 | @file{paths.h}. If this value is not defined, @file{/var/mail} or |
1098 | @file{/usr/spool/mail} is used. | 1167 | @file{/usr/spool/mail} is used. |
1099 | @end enumerate | 1168 | @end enumerate |
1100 | 1169 | ||
1101 | @deffn {Configuration} mailbox-type @var{type} | 1170 | @deffn {Configuration} mailbox-type @var{type} |
1102 | @vrindex MU_DEFAULT_SCHEME | 1171 | @vrindex MU_DEFAULT_SCHEME |
1103 | Specifies type of mailboxes. By default, @samp{mbox} (UNIX mailbox) | 1172 | Specifies the type of mailboxes. By default, @samp{mbox} (UNIX mailbox) |
1104 | is assumed. This can be changed while configuring the package by | 1173 | is assumed. This can be changed while configuring the package by |
1105 | setting @code{MU_DEFAULT_SCHEME} configuration variable. The default | 1174 | setting @code{MU_DEFAULT_SCHEME} configuration variable. The default |
1106 | value can be verified by running @command{mailutils info scheme}. | 1175 | value can be verified by running @command{mailutils info scheme}. |
... | @@ -1157,7 +1226,7 @@ the following letters: | ... | @@ -1157,7 +1226,7 @@ the following letters: |
1157 | 1226 | ||
1158 | @table @asis | 1227 | @table @asis |
1159 | @item E | 1228 | @item E |
1160 | Use an external program to manage locks. The program is given by | 1229 | Use an external program to manage locks. The program is given by the |
1161 | @code{external-locker} statement (see below). | 1230 | @code{external-locker} statement (see below). |
1162 | 1231 | ||
1163 | @item R | 1232 | @item R |
... | @@ -1192,8 +1261,9 @@ seconds ago. The @samp{T} flag must be set for this to take effect. | ... | @@ -1192,8 +1261,9 @@ seconds ago. The @samp{T} flag must be set for this to take effect. |
1192 | @end deffn | 1261 | @end deffn |
1193 | 1262 | ||
1194 | @deffn {Configuration} external-locker @var{string} | 1263 | @deffn {Configuration} external-locker @var{string} |
1195 | Set command line of an external locker program. The @samp{E} flag | 1264 | Determines the external locker program to use. The @var{string} |
1196 | must be set for this to take effect. | 1265 | argument is the valid command line, starting with the full program |
1266 | name. The @samp{E} flag must be set for this to take effect. | ||
1197 | @end deffn | 1267 | @end deffn |
1198 | 1268 | ||
1199 | @node mailer statement | 1269 | @node mailer statement |
... | @@ -1429,15 +1499,15 @@ Access control using TCP wrappers is based on two files, called | ... | @@ -1429,15 +1499,15 @@ Access control using TCP wrappers is based on two files, called |
1429 | @dfn{tables}, containing access rules. There are two tables: the | 1499 | @dfn{tables}, containing access rules. There are two tables: the |
1430 | @dfn{allow table}, usually stored in file @file{/etc/hosts.allow}, and | 1500 | @dfn{allow table}, usually stored in file @file{/etc/hosts.allow}, and |
1431 | the @dfn{deny table}, kept in file @file{/etc/hosts.deny}. The rules | 1501 | the @dfn{deny table}, kept in file @file{/etc/hosts.deny}. The rules |
1432 | in each table begin with an identifier called @dfn{daemon name}. Each | 1502 | in each table begin with an identifier called @dfn{daemon name}. A |
1433 | utility wishing to verify a connection, select the entries having | 1503 | utility that wishes to verify a connection, selects the entries having |
1434 | its daemon name from the allow table. A connection is allowed if it | 1504 | its daemon name from the allow table. A connection is allowed if it |
1435 | matches any of these entries. Otherwise, the utility retrieves all | 1505 | matches any of these entries. Otherwise, the utility retrieves all |
1436 | entries with its daemon name from the deny table. If any of these | 1506 | entries with its daemon name from the deny table. If any of these |
1437 | matches the connection, then it is refused. Otherwise, if neither | 1507 | matches the connection, then it is refused. Otherwise, if neither |
1438 | table contains matching entries, the connection is allowed. | 1508 | table contains matching entries, the connection is allowed. |
1439 | 1509 | ||
1440 | Description of a TCP wrapper table format lies outside the scope of | 1510 | The description of a TCP wrapper table format lies outside the scope of |
1441 | this document. Please, see @ref{ACCESS CONTROL FILES,,ACCESS CONTROL FILES, | 1511 | this document. Please, see @ref{ACCESS CONTROL FILES,,ACCESS CONTROL FILES, |
1442 | hosts_access(5), hosts_access(5) man page}, for details. | 1512 | hosts_access(5), hosts_access(5) man page}, for details. |
1443 | 1513 | ||
... | @@ -1562,7 +1632,7 @@ After startup, store the PID of the main server process in | ... | @@ -1562,7 +1632,7 @@ After startup, store the PID of the main server process in |
1562 | @var{file}. When the process terminates, the file is removed. As of | 1632 | @var{file}. When the process terminates, the file is removed. As of |
1563 | version @value{VERSION}, GNU Mailutils servers make no further use of | 1633 | version @value{VERSION}, GNU Mailutils servers make no further use of |
1564 | this file. It is intended for use by automated startup scripts and | 1634 | this file. It is intended for use by automated startup scripts and |
1565 | controlling programs (@FIXME-pxref{mention pies}). | 1635 | controlling programs (e.g. @pxref{Top, GNU pies,, pies, GNU Pies Manual}). |
1566 | @end deffn | 1636 | @end deffn |
1567 | 1637 | ||
1568 | @deffn {Configuration} port @var{portspec}; | 1638 | @deffn {Configuration} port @var{portspec}; |
... | @@ -1646,7 +1716,7 @@ in debugging. They should be turned off on most production servers. | ... | @@ -1646,7 +1716,7 @@ in debugging. They should be turned off on most production servers. |
1646 | @end deffn | 1716 | @end deffn |
1647 | 1717 | ||
1648 | @deffn {Configuration} timeout @var{time}; | 1718 | @deffn {Configuration} timeout @var{time}; |
1649 | Set idle timeout for this server. This overrides global timeout | 1719 | Set idle timeout for this server. This overrides the global timeout |
1650 | settings (@pxref{General Server Configuration, timeout}). | 1720 | settings (@pxref{General Server Configuration, timeout}). |
1651 | @end deffn | 1721 | @end deffn |
1652 | 1722 | ||
... | @@ -1779,13 +1849,18 @@ database. @xref{ldap statement}, for an information on how to | ... | @@ -1779,13 +1849,18 @@ database. @xref{ldap statement}, for an information on how to |
1779 | configure it. | 1849 | configure it. |
1780 | @end table | 1850 | @end table |
1781 | 1851 | ||
1782 | @FIXME{This may be inaccurate:} | ||
1783 | Unless overridden by @code{authorization} statement, | 1852 | Unless overridden by @code{authorization} statement, |
1784 | the default list of authorization modules is: | 1853 | the default list of authorization modules is: |
1785 | 1854 | ||
1786 | @example | 1855 | @enumerate 1 |
1787 | (system, sql, virtdomains) | 1856 | @item generic |
1788 | @end example | 1857 | @item system |
1858 | @item pam | ||
1859 | @item sql | ||
1860 | @item virtual | ||
1861 | @item radius | ||
1862 | @item ldap | ||
1863 | @end enumerate | ||
1789 | @end deffn | 1864 | @end deffn |
1790 | 1865 | ||
1791 | @deffn {Configuration} authentication @var{module-list} | 1866 | @deffn {Configuration} authentication @var{module-list} |
... | @@ -1816,19 +1891,24 @@ server. @xref{radius statement}. | ... | @@ -1816,19 +1891,24 @@ server. @xref{radius statement}. |
1816 | The user is authenticated using @acronym{LDAP}. @xref{ldap statement}. | 1891 | The user is authenticated using @acronym{LDAP}. @xref{ldap statement}. |
1817 | @end table | 1892 | @end table |
1818 | 1893 | ||
1819 | @FIXME{This list is inaccurate:} | ||
1820 | Unless overridden by @code{authentication} statement, | 1894 | Unless overridden by @code{authentication} statement, |
1821 | the list of authentication modules is: | 1895 | the list of authentication modules is the same as for |
1896 | @code{authorization}, i.e.: | ||
1822 | 1897 | ||
1823 | @example | 1898 | @enumerate 1 |
1824 | (generic, system, pam, sql) | 1899 | @item generic |
1825 | @end example | 1900 | @item system |
1901 | @item pam | ||
1902 | @item sql | ||
1903 | @item virtual | ||
1904 | @item radius | ||
1905 | @item ldap | ||
1906 | @end enumerate | ||
1826 | @end deffn | 1907 | @end deffn |
1827 | 1908 | ||
1828 | @node pam statement | 1909 | @node pam statement |
1829 | @subsection PAM Statement | 1910 | @subsection PAM Statement |
1830 | @anchor{PAM Statement} | 1911 | @anchor{PAM Statement} |
1831 | @UNREVISED | ||
1832 | @kwindex pam | 1912 | @kwindex pam |
1833 | @subheading Syntax | 1913 | @subheading Syntax |
1834 | @example | 1914 | @example |
... | @@ -1853,7 +1933,6 @@ This statement takes effect only if @samp{pam} is listed in | ... | @@ -1853,7 +1933,6 @@ This statement takes effect only if @samp{pam} is listed in |
1853 | @node virtdomain statement | 1933 | @node virtdomain statement |
1854 | @subsection The @code{virtdomain} Statement | 1934 | @subsection The @code{virtdomain} Statement |
1855 | @anchor{Virtdomain Statement} | 1935 | @anchor{Virtdomain Statement} |
1856 | @UNREVISED | ||
1857 | @kwindex virtdomain | 1936 | @kwindex virtdomain |
1858 | @subheading Syntax | 1937 | @subheading Syntax |
1859 | @example | 1938 | @example |
... | @@ -1880,8 +1959,8 @@ latter is set using @code{passwd-dir} statement. | ... | @@ -1880,8 +1959,8 @@ latter is set using @code{passwd-dir} statement. |
1880 | Set virtual domain password directory. | 1959 | Set virtual domain password directory. |
1881 | @end deffn | 1960 | @end deffn |
1882 | 1961 | ||
1883 | For example, when authenticating user @samp{smith@@domain.tld}, | 1962 | For example, when authenticating user @samp{smith@@example.com}, |
1884 | the server will use password file named @file{@var{dir}/domain.tld}. | 1963 | the server will use password file named @file{@var{dir}/example.com}. |
1885 | This file must be in UNIX passwd format (@pxref{password | 1964 | This file must be in UNIX passwd format (@pxref{password |
1886 | file,,,passwd(5), passwd(5) man page}), with encrypted passwords | 1965 | file,,,passwd(5), passwd(5) man page}), with encrypted passwords |
1887 | stored in it (as of GNU Mailutils version @value{VERSION}, there is no | 1966 | stored in it (as of GNU Mailutils version @value{VERSION}, there is no |
... | @@ -1911,7 +1990,6 @@ file. | ... | @@ -1911,7 +1990,6 @@ file. |
1911 | @node radius statement | 1990 | @node radius statement |
1912 | @subsection The @code{radius} Statement | 1991 | @subsection The @code{radius} Statement |
1913 | @anchor{Radius Statement} | 1992 | @anchor{Radius Statement} |
1914 | @UNREVISED | ||
1915 | @kwindex radius | 1993 | @kwindex radius |
1916 | @subheading Syntax | 1994 | @subheading Syntax |
1917 | @example | 1995 | @example |
... | @@ -2043,7 +2121,7 @@ The attributes @code{GNU-MU-Mailbox} and @code{GNU-MU-Quota} are | ... | @@ -2043,7 +2121,7 @@ The attributes @code{GNU-MU-Mailbox} and @code{GNU-MU-Quota} are |
2043 | optional. | 2121 | optional. |
2044 | 2122 | ||
2045 | If @code{GNU-MU-Mailbox} is present, it must contain a | 2123 | If @code{GNU-MU-Mailbox} is present, it must contain a |
2046 | valid mailbox @acronym{URL} (@FIXME-pxref{urls}). If | 2124 | valid mailbox @acronym{URL} (@pxref{Mailbox, URL}). If |
2047 | @code{GNU-MU-Mailbox} is not present, Mailutils constructs the | 2125 | @code{GNU-MU-Mailbox} is not present, Mailutils constructs the |
2048 | mailbox name using the settings from the @code{mailbox} configuration | 2126 | mailbox name using the settings from the @code{mailbox} configuration |
2049 | statement (@pxref{Mailbox Statement}), or built-in defaults, if it is | 2127 | statement (@pxref{Mailbox Statement}), or built-in defaults, if it is |
... | @@ -2071,7 +2149,6 @@ request (see above). | ... | @@ -2071,7 +2149,6 @@ request (see above). |
2071 | @node sql statement | 2149 | @node sql statement |
2072 | @subsection The @code{sql} Statement | 2150 | @subsection The @code{sql} Statement |
2073 | @anchor{SQL Statement} | 2151 | @anchor{SQL Statement} |
2074 | @UNREVISED | ||
2075 | @kwindex sql | 2152 | @kwindex sql |
2076 | @subheading Syntax | 2153 | @subheading Syntax |
2077 | @example | 2154 | @example |
... | @@ -2091,7 +2168,7 @@ sql @{ | ... | @@ -2091,7 +2168,7 @@ sql @{ |
2091 | # @r{Type of password returned by getpass query.} | 2168 | # @r{Type of password returned by getpass query.} |
2092 | password-type @samp{plain | hash | scrambled}; | 2169 | password-type @samp{plain | hash | scrambled}; |
2093 | # @r{Set a field-map for parsing SQL replies.} | 2170 | # @r{Set a field-map for parsing SQL replies.} |
2094 | field-map @var{map}; | 2171 | field-map @var{list}; |
2095 | # @r{SQL query returning the user's password.} | 2172 | # @r{SQL query returning the user's password.} |
2096 | getpass @var{query}; | 2173 | getpass @var{query}; |
2097 | # @r{SQL query to use for getpwnam requests.} | 2174 | # @r{SQL query to use for getpwnam requests.} |
... | @@ -2155,10 +2232,101 @@ Name of the database. | ... | @@ -2155,10 +2232,101 @@ Name of the database. |
2155 | Password to access the database. | 2232 | Password to access the database. |
2156 | @end deffn | 2233 | @end deffn |
2157 | 2234 | ||
2235 | @deffn {Configuration} password-encryption @var{arg}; | ||
2236 | Defines type of encryption used by the password returned by | ||
2237 | @code{getpass} query (see below). Possible arguments are: | ||
2238 | |||
2239 | @table @asis | ||
2240 | @item plain | ||
2241 | Password is in plain text. | ||
2242 | |||
2243 | @item crypt | ||
2244 | @itemx hash | ||
2245 | Password is encrypted by system @code{crypt} function | ||
2246 | (@pxref{crypt,,,crypt(3), crypt(3) man page}). | ||
2247 | |||
2248 | @item scrambled | ||
2249 | Password is encrypted by MySQL @code{password} function. | ||
2250 | @end table | ||
2251 | @end deffn | ||
2252 | |||
2253 | @deffn {Configuration} getpwnam @var{query} | ||
2254 | Defines SQL query that returns information about the given user. The | ||
2255 | @var{query} is subject to variable expansion (@pxref{Variables}). The | ||
2256 | only variable defined is @samp{$user}, which expands to the user name. | ||
2257 | |||
2258 | @anchor{getpw column names} | ||
2259 | The query should return a single row with the following columns: | ||
2260 | |||
2261 | @table @asis | ||
2262 | @item name | ||
2263 | User name. | ||
2264 | @item passwd | ||
2265 | User password. | ||
2266 | @item uid | ||
2267 | UID of the user. | ||
2268 | @item gid | ||
2269 | GID of the primary group. | ||
2270 | @item gecos | ||
2271 | Textual description of the user. | ||
2272 | @item dir | ||
2273 | User's home directory | ||
2274 | @item shell | ||
2275 | User's shell program. | ||
2276 | @end table | ||
2277 | |||
2278 | The following columns are optional: | ||
2279 | |||
2280 | @table @asis | ||
2281 | @item mailbox | ||
2282 | Full pathname of the user's mailbox. If not returned or NULL, the | ||
2283 | mailbox is determined using the default algorithm (@pxref{Mailbox}). | ||
2284 | @item quota | ||
2285 | Upper limit on the size of the mailbox. The value is either an | ||
2286 | integer number optionally followed by one of the usual size suffixes: | ||
2287 | @samp{K}, @samp{M}, @samp{G}, or @samp{T} (case-insensitive). | ||
2288 | @end table | ||
2289 | @end deffn | ||
2290 | |||
2291 | @deffn {Configuration} getpwuid @var{query} | ||
2292 | Defines SQL query that returns information about the given UID. The | ||
2293 | @var{query} is subject to variable expansion (@pxref{Variables}). The | ||
2294 | only variable defined is @samp{$user}, which expands to the UID. | ||
2295 | |||
2296 | The query should return a single row, as described for @code{getpwnam}. | ||
2297 | @end deffn | ||
2298 | |||
2299 | @deffn {Configuration} getpass @var{query} | ||
2300 | Defines SQL query that returns the password of the given user. The | ||
2301 | @var{query} is subject to variable expansion (@pxref{Variables}). The | ||
2302 | only variable defined is @samp{$user}, which expands to the user name. | ||
2303 | |||
2304 | The query should return a row with a single column, which gives the | ||
2305 | password. The password can be encrypted as specified by the | ||
2306 | @code{password-encryption} statement. | ||
2307 | @end deffn | ||
2308 | |||
2309 | @deffn {Configuration} field-map @var{list} | ||
2310 | Defines a translation map for column names. The @var{list} is a | ||
2311 | list of mappings. Each mapping is a string | ||
2312 | @samp{@var{name}=@var{column}}, where @var{name} is one of the names | ||
2313 | described in @ref{getpw column names}, and @var{column} is the name of | ||
2314 | the column in the returned row that should be used instead. The effect of | ||
2315 | this statement is similar to that of SQL @code{AS} keyword. E.g. the | ||
2316 | statement | ||
2317 | |||
2318 | @example | ||
2319 | field-map (uid=user_id); | ||
2320 | @end example | ||
2321 | |||
2322 | @noindent | ||
2323 | has the same effect as using @samp{SELECT user_id AS uid} in the SQL | ||
2324 | statement. | ||
2325 | @end deffn | ||
2326 | |||
2158 | @node ldap statement | 2327 | @node ldap statement |
2159 | @subsection The @code{ldap} Statement | 2328 | @subsection The @code{ldap} Statement |
2160 | @anchor{LDAP Statement} | 2329 | @anchor{LDAP Statement} |
2161 | @WRITEME | ||
2162 | @kwindex ldap | 2330 | @kwindex ldap |
2163 | @subheading Syntax | 2331 | @subheading Syntax |
2164 | @example | 2332 | @example |
... | @@ -2178,18 +2346,107 @@ ldap @{ | ... | @@ -2178,18 +2346,107 @@ ldap @{ |
2178 | # @r{Set LDAP debugging level.} | 2346 | # @r{Set LDAP debugging level.} |
2179 | debug @var{number}; | 2347 | debug @var{number}; |
2180 | # @r{Set a field-map for parsing LDAP replies.} | 2348 | # @r{Set a field-map for parsing LDAP replies.} |
2181 | field-map @var{map}; | 2349 | field-map @var{list}; |
2182 | # @r{LDAP filter to use for getpwnam requests.} | 2350 | # @r{LDAP filter to use for getpwnam requests.} |
2183 | getpwnam @var{string}; | 2351 | getpwnam @var{string}; |
2184 | # @r{LDAP filter to use for getpwuid requests.} | 2352 | # @r{LDAP filter to use for getpwuid requests.} |
2185 | getpwuid @var{filter}; | 2353 | getpwuid @var{filter}; |
2186 | @} | 2354 | @} |
2187 | @end example | 2355 | @end example |
2356 | @subheading Description | ||
2357 | The @code{ldap} statement configures the use of LDAP for authentication. | ||
2358 | |||
2359 | @deffn {Configuration} enable @var{bool} | ||
2360 | Enables LDAP lookups. If absent, @samp{enable On} is assumed. | ||
2361 | @end deffn | ||
2362 | |||
2363 | @deffn {Configuration} url @var{url} | ||
2364 | Sets the URL of the LDAP server. | ||
2365 | @end deffn | ||
2366 | |||
2367 | @deffn {Configuration} base @var{string} | ||
2368 | Defines base DN for LDAP lookups. | ||
2369 | @end deffn | ||
2370 | |||
2371 | @deffn {Configuration} binddn @var{string} | ||
2372 | Defines the DN for accessing LDAP database. | ||
2373 | @end deffn | ||
2374 | |||
2375 | @deffn {Configuration} passwd @var{string} | ||
2376 | Password for use when binding to the database. | ||
2377 | @end deffn | ||
2378 | |||
2379 | @deffn {Configuration} tls @var{bool} | ||
2380 | Enable the use of TLS when connecting to the server. | ||
2381 | @end deffn | ||
2382 | |||
2383 | @deffn {Configuration} debug @var{number} | ||
2384 | Set LDAP debug level. Please refer to the OpenLDAP documentation, for | ||
2385 | allowed @var{number} values and their meaning. | ||
2386 | @end deffn | ||
2387 | |||
2388 | @deffn {Configuration} field-map @var{map} | ||
2389 | Defines a map for parsing LDAP replies. The @var{map} is a list | ||
2390 | of mappings@footnote{For backward compatibility, @var{map} can be a | ||
2391 | string containing colon-delimited list of mappings. Such usage is, | ||
2392 | however, deprecated.}. Each mapping is @samp{@var{field}=@var{attr}}, where | ||
2393 | @var{attr} is the name of the LDAP attribute and @var{field} is a | ||
2394 | field name that declares what information that attribute carries. | ||
2395 | Available values for @var{field} are: | ||
2396 | |||
2397 | @table @asis | ||
2398 | @item name | ||
2399 | User name. | ||
2400 | @item passwd | ||
2401 | User password. | ||
2402 | @item uid | ||
2403 | UID of the user. | ||
2404 | @item gid | ||
2405 | GID of the primary group. | ||
2406 | @item gecos | ||
2407 | Textual description of the user. | ||
2408 | @item dir | ||
2409 | User's home directory | ||
2410 | @item shell | ||
2411 | User's shell program. | ||
2412 | @end table | ||
2413 | |||
2414 | The default mapping is | ||
2415 | |||
2416 | @example | ||
2417 | @group | ||
2418 | ("name=uid", | ||
2419 | "passwd=userPassword", | ||
2420 | "uid=uidNumber", | ||
2421 | "gid=gidNumber", | ||
2422 | "gecos=gecos", | ||
2423 | "dir=homeDirectory", | ||
2424 | "shell=loginShell") | ||
2425 | @end group | ||
2426 | @end example | ||
2427 | @end deffn | ||
2428 | |||
2429 | @deffn {Configuration} getpwnam @var{string} | ||
2430 | Defines the LDAP filter to use for @samp{getpwnam} requests. The | ||
2431 | default is: | ||
2432 | |||
2433 | @example | ||
2434 | (&(objectClass=posixAccount) (uid=$user)) | ||
2435 | @end example | ||
2436 | @end deffn | ||
2437 | |||
2438 | @deffn {Configuration} getpwuid @var{string} | ||
2439 | Defines the LDAP filter to use for @samp{getpwuid} requests. The | ||
2440 | default filter is: | ||
2441 | |||
2442 | @example | ||
2443 | (&(objectClass=posixAccount) (uidNumber=$user)) | ||
2444 | @end example | ||
2445 | @end deffn | ||
2188 | 2446 | ||
2189 | @node tls statement | 2447 | @node tls statement |
2190 | @subsection The @code{tls} Statement | 2448 | @subsection The @code{tls} Statement |
2191 | @anchor{TLS Statement} | 2449 | @anchor{TLS Statement} |
2192 | @WRITEME | ||
2193 | @kwindex tls | 2450 | @kwindex tls |
2194 | @subheading Syntax | 2451 | @subheading Syntax |
2195 | @example | 2452 | @example |
... | @@ -2197,13 +2454,80 @@ tls @{ | ... | @@ -2197,13 +2454,80 @@ tls @{ |
2197 | # @r{Enable TLS support.} | 2454 | # @r{Enable TLS support.} |
2198 | enable @var{bool}; | 2455 | enable @var{bool}; |
2199 | # @r{Specify SSL certificate file.} | 2456 | # @r{Specify SSL certificate file.} |
2200 | ssl-cert @var{bool}; | 2457 | ssl-cert @var{string}; |
2201 | # @r{Specify SSL certificate key file.} | 2458 | # @r{Specify SSL certificate key file.} |
2202 | ssl-key @var{file}; | 2459 | ssl-key @var{file}; |
2203 | # @r{Specify trusted CAs file.} | 2460 | # @r{Specify trusted CAs file.} |
2204 | ssl-cafile @var{file}; | 2461 | ssl-cafile @var{file}; |
2462 | # @r{Set the priorities to use on the ciphers, methods, etc.} | ||
2463 | ssl-priorities @var{string}; | ||
2464 | # @r{Configure safety checks for SSL key file.} | ||
2465 | key-file-safety-checks @var{list}; | ||
2466 | # @r{Configure safety checks for SSL certificate.} | ||
2467 | cert-file-safety-checks @var{list}; | ||
2468 | # @r{Configure safety checks for SSL CA file.} | ||
2469 | ca-file-safety-checks @var{list}; | ||
2205 | @} | 2470 | @} |
2206 | @end example | 2471 | @end example |
2472 | @subheading Description | ||
2473 | |||
2474 | @deffn {Configuration} enable @var{bool} | ||
2475 | Enable TLS support. If absent, @samp{enable On} is assumed. | ||
2476 | @end deffn | ||
2477 | |||
2478 | @deffn {Configuration} ssl-cert @var{string} | ||
2479 | Specify SSL certificate file. | ||
2480 | @end deffn | ||
2481 | |||
2482 | @deffn {Configuration} ssl-key @var{file} | ||
2483 | Specify SSL certificate key file. | ||
2484 | @end deffn | ||
2485 | |||
2486 | @deffn {Configuration} ssl-cafile @var{file} | ||
2487 | Specify the trusted certificate authorities file. | ||
2488 | @end deffn | ||
2489 | |||
2490 | @deffn {Configuration} ssl-priorities @var{string} | ||
2491 | Set the priorities to use on the ciphers, key exchange methods, MACs | ||
2492 | and compression methods. | ||
2493 | @end deffn | ||
2494 | |||
2495 | @deffn {Configuration} key-file-safety-checks @var{list} | ||
2496 | Configure safety checks for SSL key file. Elements of the @var{list} are | ||
2497 | names of individual checks, optionally prefixed with @samp{+} to enable or | ||
2498 | @samp{-} to disable the corresponding check. Valid check names are: | ||
2499 | |||
2500 | @table @asis | ||
2501 | @item none | ||
2502 | Disable all checks. | ||
2503 | @item all | ||
2504 | Enable all checks. | ||
2505 | @item gwrfil | ||
2506 | Forbid group writable files. | ||
2507 | @item awrfil | ||
2508 | Forbid world writable files. | ||
2509 | @item grdfil | ||
2510 | Forbid group readable files. | ||
2511 | @item ardfil | ||
2512 | Forbid world writable files. | ||
2513 | @item linkwrdir | ||
2514 | Forbid symbolic links in group or world writable directories. | ||
2515 | @item gwrdir | ||
2516 | Forbid files in group writable directories. | ||
2517 | @item awrdir | ||
2518 | Forbid files in world writable directories, | ||
2519 | @end table | ||
2520 | @end deffn | ||
2521 | |||
2522 | @deffn {Configuration} cert-file-safety-checks @var{list} | ||
2523 | Configure safety checks for SSL certificate. See | ||
2524 | @code{key-file-safety-checks} for a description of @var{list}. | ||
2525 | @end deffn | ||
2526 | |||
2527 | @deffn {Configuration} ca-file-safety-checks @var{list} | ||
2528 | Configure safety checks for SSL CA file. See | ||
2529 | @code{key-file-safety-checks} for a description of @var{list}. | ||
2530 | @end deffn | ||
2207 | 2531 | ||
2208 | @node gsasl statement | 2532 | @node gsasl statement |
2209 | @subsection The @code{gsasl} Statement | 2533 | @subsection The @code{gsasl} Statement |
... | @@ -8226,13 +8550,13 @@ optional @var{col} is the column number in that file. | ... | @@ -8226,13 +8550,13 @@ optional @var{col} is the column number in that file. |
8226 | For example, the following invocation: | 8550 | For example, the following invocation: |
8227 | 8551 | ||
8228 | @example | 8552 | @example |
8229 | mailutils logger --locus mailutils.rc:34 Suspicious statement | 8553 | mailutils logger --locus mailutils.conf:34 Suspicious statement |
8230 | @end example | 8554 | @end example |
8231 | 8555 | ||
8232 | will send the following to the log: | 8556 | will send the following to the log: |
8233 | 8557 | ||
8234 | @example | 8558 | @example |
8235 | mu-logger: mailutils.rc:34: Suspicious statement | 8559 | mu-logger: mailutils.conf:34: Suspicious statement |
8236 | @end example | 8560 | @end example |
8237 | 8561 | ||
8238 | @node mailutils pop | 8562 | @node mailutils pop | ... | ... |
... | @@ -243,7 +243,7 @@ retrieve_password (Gsasl *ctx, Gsasl_session *sctx) | ... | @@ -243,7 +243,7 @@ retrieve_password (Gsasl *ctx, Gsasl_session *sctx) |
243 | } | 243 | } |
244 | 244 | ||
245 | #ifdef USE_SQL | 245 | #ifdef USE_SQL |
246 | if (mu_sql_module_config.password_type == password_plaintext) | 246 | if (mu_sql_module_config.password_encryption == mu_sql_password_plaintext) |
247 | { | 247 | { |
248 | char *passwd; | 248 | char *passwd; |
249 | int status = mu_sql_getpass (*username, &passwd); | 249 | int status = mu_sql_getpass (*username, &passwd); | ... | ... |
... | @@ -297,6 +297,10 @@ int mu_cfg_create_subtree (const char *path, mu_cfg_node_t **pnode); | ... | @@ -297,6 +297,10 @@ int mu_cfg_create_subtree (const char *path, mu_cfg_node_t **pnode); |
297 | int mu_cfg_parse_config (mu_cfg_tree_t **ptree, | 297 | int mu_cfg_parse_config (mu_cfg_tree_t **ptree, |
298 | struct mu_cfg_parse_hints *hints); | 298 | struct mu_cfg_parse_hints *hints); |
299 | 299 | ||
300 | int mu_cfg_field_map (struct mu_config_value const *val, mu_assoc_t *passoc, | ||
301 | char **err_term); | ||
302 | |||
303 | |||
300 | #ifdef __cplusplus | 304 | #ifdef __cplusplus |
301 | } | 305 | } |
302 | #endif | 306 | #endif | ... | ... |
... | @@ -20,11 +20,11 @@ | ... | @@ -20,11 +20,11 @@ |
20 | #define _MAILUTILS_SQL_H | 20 | #define _MAILUTILS_SQL_H |
21 | 21 | ||
22 | /* Configuration */ | 22 | /* Configuration */ |
23 | enum mu_password_type | 23 | enum mu_sql_password_encryption |
24 | { | 24 | { |
25 | password_plaintext, /* Plaintext passwords */ | 25 | mu_sql_password_plaintext, /* Plaintext passwords */ |
26 | password_scrambled, /* Scrambled MySQL (>=3.21) password */ | 26 | mu_sql_password_scrambled, /* Scrambled MySQL (>=3.21) password */ |
27 | password_hash, /* MD5 (or DES or whatever) hash */ | 27 | mu_sql_password_hash, /* MD5 (or DES or whatever) hash */ |
28 | }; | 28 | }; |
29 | 29 | ||
30 | struct mu_sql_module_config | 30 | struct mu_sql_module_config |
... | @@ -38,8 +38,7 @@ struct mu_sql_module_config | ... | @@ -38,8 +38,7 @@ struct mu_sql_module_config |
38 | char *passwd; | 38 | char *passwd; |
39 | char *db; | 39 | char *db; |
40 | int port; | 40 | int port; |
41 | enum mu_password_type password_type; | 41 | enum mu_sql_password_encryption password_encryption; |
42 | int positional; | ||
43 | mu_assoc_t field_map; | 42 | mu_assoc_t field_map; |
44 | }; | 43 | }; |
45 | 44 | ||
... | @@ -143,6 +142,4 @@ extern int mu_sql_getpass (const char *username, char **passwd); | ... | @@ -143,6 +142,4 @@ extern int mu_sql_getpass (const char *username, char **passwd); |
143 | extern int mu_check_mysql_scrambled_password (const char *scrambled, | 142 | extern int mu_check_mysql_scrambled_password (const char *scrambled, |
144 | const char *message); | 143 | const char *message); |
145 | 144 | ||
146 | int mu_sql_decode_password_type (const char *arg, enum mu_password_type *t); | ||
147 | |||
148 | #endif | 145 | #endif | ... | ... |
... | @@ -118,21 +118,6 @@ mutil_parse_field_map (const char *map, mu_assoc_t *passoc_tab, int *perr) | ... | @@ -118,21 +118,6 @@ mutil_parse_field_map (const char *map, mu_assoc_t *passoc_tab, int *perr) |
118 | return rc; | 118 | return rc; |
119 | } | 119 | } |
120 | 120 | ||
121 | /* FIXME: should it be here? */ | ||
122 | int | ||
123 | mu_sql_decode_password_type (const char *arg, enum mu_password_type *t) | ||
124 | { | ||
125 | if (strcmp (arg, "plain") == 0) | ||
126 | *t = password_plaintext; | ||
127 | else if (strcmp (arg, "hash") == 0) | ||
128 | *t = password_hash; | ||
129 | else if (strcmp (arg, "scrambled") == 0) | ||
130 | *t = password_scrambled; | ||
131 | else | ||
132 | return 1; | ||
133 | return 0; | ||
134 | } | ||
135 | |||
136 | int | 121 | int |
137 | mu_stream_flags_to_mode (int flags, int isdir) | 122 | mu_stream_flags_to_mode (int flags, int isdir) |
138 | { | 123 | { | ... | ... |
... | @@ -38,7 +38,7 @@ | ... | @@ -38,7 +38,7 @@ |
38 | #include <mailutils/stream.h> | 38 | #include <mailutils/stream.h> |
39 | #include <mailutils/assoc.h> | 39 | #include <mailutils/assoc.h> |
40 | #include <mailutils/alloc.h> | 40 | #include <mailutils/alloc.h> |
41 | 41 | #include <mailutils/cstr.h> | |
42 | 42 | ||
43 | static mu_assoc_t section_tab; | 43 | static mu_assoc_t section_tab; |
44 | 44 | ||
... | @@ -587,3 +587,92 @@ mu_cfg_string_value_cb (mu_config_value_t *val, | ... | @@ -587,3 +587,92 @@ mu_cfg_string_value_cb (mu_config_value_t *val, |
587 | } | 587 | } |
588 | return rc; | 588 | return rc; |
589 | } | 589 | } |
590 | |||
591 | struct mapping_closure | ||
592 | { | ||
593 | mu_assoc_t assoc; | ||
594 | char *err_term; | ||
595 | int err; | ||
596 | }; | ||
597 | |||
598 | static int | ||
599 | parse_mapping (void *item, void *data) | ||
600 | { | ||
601 | struct mapping_closure *clos = data; | ||
602 | char *str = item; | ||
603 | size_t len; | ||
604 | char *key, *val; | ||
605 | |||
606 | len = strcspn (str, "="); | ||
607 | if (str[len] == 0) | ||
608 | { | ||
609 | clos->err_term = mu_strdup (str); | ||
610 | return MU_ERR_PARSE; | ||
611 | } | ||
612 | key = mu_alloc (len + 1); | ||
613 | memcpy (key, str, len); | ||
614 | key[len] = 0; | ||
615 | val = mu_strdup (str + len + 1); | ||
616 | if (!val) | ||
617 | return ENOMEM; | ||
618 | clos->err = mu_assoc_install (clos->assoc, key, &val); | ||
619 | free (key); | ||
620 | if (clos->err) | ||
621 | return 1; | ||
622 | return 0; | ||
623 | } | ||
624 | |||
625 | static void | ||
626 | assoc_str_free (void *data) | ||
627 | { | ||
628 | free (data); | ||
629 | } | ||
630 | |||
631 | int | ||
632 | mu_cfg_field_map (struct mu_config_value const *val, mu_assoc_t *passoc, | ||
633 | char **err_term) | ||
634 | { | ||
635 | int rc; | ||
636 | struct mapping_closure clos; | ||
637 | mu_list_t list = NULL; | ||
638 | |||
639 | rc = mu_assoc_create (&clos.assoc, sizeof(char*), 0); | ||
640 | if (rc) | ||
641 | return rc; | ||
642 | mu_assoc_set_free (clos.assoc, assoc_str_free); | ||
643 | clos.err_term = NULL; | ||
644 | |||
645 | switch (val->type) | ||
646 | { | ||
647 | case MU_CFG_STRING: | ||
648 | mu_list_create (&list); | ||
649 | mu_list_set_destroy_item (list, mu_list_free_item); | ||
650 | rc = mu_string_split (val->v.string, ":", list); | ||
651 | if (rc == 0) | ||
652 | rc = mu_list_foreach (list, parse_mapping, &clos); | ||
653 | mu_list_destroy (&list); | ||
654 | break; | ||
655 | |||
656 | case MU_CFG_LIST: | ||
657 | rc = mu_list_foreach (val->v.list, parse_mapping, &clos); | ||
658 | break; | ||
659 | |||
660 | case MU_CFG_ARRAY: | ||
661 | rc = EINVAL; | ||
662 | } | ||
663 | |||
664 | if (rc) | ||
665 | { | ||
666 | if (err_term) | ||
667 | *err_term = clos.err_term; | ||
668 | else | ||
669 | free (clos.err_term); | ||
670 | mu_assoc_destroy (&clos.assoc); | ||
671 | } | ||
672 | else | ||
673 | *passoc = clos.assoc; | ||
674 | |||
675 | return rc; | ||
676 | } | ||
677 | |||
678 | ... | ... |
... | @@ -39,12 +39,8 @@ | ... | @@ -39,12 +39,8 @@ |
39 | #include <gsasl.h> | 39 | #include <gsasl.h> |
40 | 40 | ||
41 | struct mu_gsasl_module_data mu_gsasl_module_data = { | 41 | struct mu_gsasl_module_data mu_gsasl_module_data = { |
42 | 1, | 42 | .enable = 1, |
43 | NULL, | 43 | .cram_md5_pwd = SITE_CRAM_MD5_PWD |
44 | NULL, | ||
45 | NULL, | ||
46 | NULL, | ||
47 | SITE_CRAM_MD5_PWD | ||
48 | }; | 44 | }; |
49 | 45 | ||
50 | static struct mu_cfg_param mu_gsasl_param[] = { | 46 | static struct mu_cfg_param mu_gsasl_param[] = { | ... | ... |
... | @@ -61,23 +61,21 @@ const char *default_field_map = | ... | @@ -61,23 +61,21 @@ const char *default_field_map = |
61 | 61 | ||
62 | static struct mu_ldap_module_config ldap_param; | 62 | static struct mu_ldap_module_config ldap_param; |
63 | 63 | ||
64 | |||
65 | |||
66 | static int | 64 | static int |
67 | _cb2_field_map (const char *arg, void *data) | 65 | cb_field_map (void *data, mu_config_value_t *val) |
68 | { | 66 | { |
69 | int err; | 67 | char *err_term; |
70 | int rc = mutil_parse_field_map (arg, &ldap_param.field_map, &err); | 68 | int rc = mu_cfg_field_map (val, &ldap_param.field_map, &err_term); |
69 | |||
71 | if (rc) | 70 | if (rc) |
72 | /* FIXME: this message can be misleading */ | 71 | { |
73 | mu_error (_("error near element %d: %s"), err, mu_strerror (rc)); | 72 | if (err_term) |
74 | return 0; | 73 | mu_error (_("error near %s: %s"), err_term, mu_strerror (rc)); |
75 | } | 74 | else |
75 | mu_error ("%s", mu_strerror (rc)); | ||
76 | } | ||
76 | 77 | ||
77 | static int | 78 | return rc; |
78 | cb_field_map (void *data, mu_config_value_t *val) | ||
79 | { | ||
80 | return mu_cfg_string_value_cb (val, _cb2_field_map, NULL); | ||
81 | } | 79 | } |
82 | 80 | ||
83 | static struct mu_cfg_param mu_ldap_param[] = { | 81 | static struct mu_cfg_param mu_ldap_param[] = { |
... | @@ -140,14 +138,18 @@ module_init (void *ptr) | ... | @@ -140,14 +138,18 @@ module_init (void *ptr) |
140 | if (ldap_param.enable) | 138 | if (ldap_param.enable) |
141 | { | 139 | { |
142 | if (!ldap_param.getpwnam_filter) | 140 | if (!ldap_param.getpwnam_filter) |
143 | ldap_param.getpwnam_filter = "(&(objectClass=posixAccount) (uid=%u))"; | 141 | ldap_param.getpwnam_filter = |
142 | "(&(objectClass=posixAccount) (uid=$user))"; | ||
144 | if (!ldap_param.getpwuid_filter) | 143 | if (!ldap_param.getpwuid_filter) |
145 | ldap_param.getpwuid_filter = | 144 | ldap_param.getpwuid_filter = |
146 | "&(objectClass=posixAccount) (uidNumber=%u))"; | 145 | "(&(objectClass=posixAccount) (uidNumber=$user))"; |
147 | if (!ldap_param.field_map) | 146 | if (!ldap_param.field_map) |
148 | { | 147 | { |
149 | int d; | 148 | struct mu_config_value val; |
150 | mutil_parse_field_map (default_field_map, &ldap_param.field_map, &d); | 149 | val.type = MU_CFG_STRING; |
150 | val.v.string = default_field_map; | ||
151 | if (mu_cfg_field_map (&val, &ldap_param.field_map, NULL)) | ||
152 | abort (); | ||
151 | } | 153 | } |
152 | } | 154 | } |
153 | } | 155 | } | ... | ... |
... | @@ -51,38 +51,53 @@ | ... | @@ -51,38 +51,53 @@ |
51 | #include <mailutils/cstr.h> | 51 | #include <mailutils/cstr.h> |
52 | #include <mailutils/wordsplit.h> | 52 | #include <mailutils/wordsplit.h> |
53 | #include <mailutils/cli.h> | 53 | #include <mailutils/cli.h> |
54 | #include <mailutils/kwd.h> | ||
54 | #include "sql.h" | 55 | #include "sql.h" |
55 | 56 | ||
56 | #ifdef USE_SQL | 57 | #ifdef USE_SQL |
57 | 58 | ||
58 | struct mu_sql_module_config mu_sql_module_config; | 59 | struct mu_sql_module_config mu_sql_module_config; |
60 | |||
59 | /* Resource file configuration */ | 61 | /* Resource file configuration */ |
62 | |||
63 | static struct mu_kwd password_encryption[] = { | ||
64 | { "plain", mu_sql_password_plaintext }, | ||
65 | { "scrambled", mu_sql_password_scrambled }, | ||
66 | { "hash", mu_sql_password_hash }, | ||
67 | { "crypt", mu_sql_password_hash }, | ||
68 | { NULL } | ||
69 | }; | ||
70 | |||
60 | static int | 71 | static int |
61 | cb_password_type (void *data, mu_config_value_t *val) | 72 | cb_password_encryption (void *data, mu_config_value_t *val) |
62 | { | 73 | { |
74 | int res; | ||
75 | |||
63 | if (mu_cfg_assert_value_type (val, MU_CFG_STRING)) | 76 | if (mu_cfg_assert_value_type (val, MU_CFG_STRING)) |
64 | return 1; | 77 | return 1; |
65 | 78 | ||
66 | if (mu_sql_decode_password_type (val->v.string, &mu_sql_module_config.password_type)) | 79 | if (mu_kwd_xlat_name (password_encryption, val->v.string, &res)) |
67 | mu_error (_("unknown password type `%s'"), val->v.string); | 80 | mu_error ("%s", _("unrecognized password encryption")); |
81 | else | ||
82 | mu_sql_module_config.password_encryption = res; | ||
68 | return 0; | 83 | return 0; |
69 | } | 84 | } |
70 | 85 | ||
71 | static int | 86 | static int |
72 | _cb2_field_map (const char *arg, void *data) | 87 | cb_field_map (void *data, mu_config_value_t *val) |
73 | { | 88 | { |
74 | int err; | 89 | char *err_term; |
75 | int rc = mutil_parse_field_map (arg, &mu_sql_module_config.field_map, &err); | 90 | int rc = mu_cfg_field_map (val, &mu_sql_module_config.field_map, &err_term); |
91 | |||
76 | if (rc) | 92 | if (rc) |
77 | /* FIXME: this message may be misleading */ | 93 | { |
78 | mu_error (_("error near element %d: %s"), err, mu_strerror (rc)); | 94 | if (err_term) |
79 | return 0; | 95 | mu_error (_("error near %s: %s"), err_term, mu_strerror (rc)); |
80 | } | 96 | else |
97 | mu_error ("%s", mu_strerror (rc)); | ||
98 | } | ||
81 | 99 | ||
82 | static int | 100 | return rc; |
83 | cb_field_map (void *data, mu_config_value_t *val) | ||
84 | { | ||
85 | return mu_cfg_string_value_cb (val, _cb2_field_map, NULL); | ||
86 | } | 101 | } |
87 | 102 | ||
88 | static int | 103 | static int |
... | @@ -124,12 +139,10 @@ static struct mu_cfg_param mu_sql_param[] = { | ... | @@ -124,12 +139,10 @@ static struct mu_cfg_param mu_sql_param[] = { |
124 | N_("SQL server port.") }, | 139 | N_("SQL server port.") }, |
125 | { "db", mu_c_string, &mu_sql_module_config.db, 0, NULL, | 140 | { "db", mu_c_string, &mu_sql_module_config.db, 0, NULL, |
126 | N_("Database name.") }, | 141 | N_("Database name.") }, |
127 | { "password-type", mu_cfg_callback, NULL, 0, cb_password_type, | 142 | { "password-encryption", mu_cfg_callback, NULL, 0, cb_password_encryption, |
128 | N_("Type of password returned by getpass query."), | 143 | N_("Type of password returned by getpass query."), |
129 | /* TRANSLATORS: Words to the right of : are keywords - do not translate */ | 144 | /* TRANSLATORS: Words to the right of : are keywords - do not translate */ |
130 | N_("arg: plain|hash|scrambled") }, | 145 | N_("arg: plain|hash|crypt|scrambled") }, |
131 | { "positional", mu_c_bool, &mu_sql_module_config.positional, 0, NULL, | ||
132 | N_("Use positional (v1.0 compatible) field interface.") }, | ||
133 | { "field-map", mu_cfg_callback, NULL, 0, cb_field_map, | 146 | { "field-map", mu_cfg_callback, NULL, 0, cb_field_map, |
134 | N_("Set a field-map for parsing SQL replies. The map is a " | 147 | N_("Set a field-map for parsing SQL replies. The map is a " |
135 | "column-separated list of definitions. Each definition has the " | 148 | "column-separated list of definitions. Each definition has the " |
... | @@ -208,63 +221,6 @@ mu_sql_expand_query (const char *query, const char *ustr) | ... | @@ -208,63 +221,6 @@ mu_sql_expand_query (const char *query, const char *ustr) |
208 | return res; | 221 | return res; |
209 | } | 222 | } |
210 | 223 | ||
211 | |||
212 | static int | ||
213 | decode_tuple_v1_0 (mu_sql_connection_t conn, int n, | ||
214 | struct mu_auth_data **return_data) | ||
215 | { | ||
216 | int rc; | ||
217 | char *mailbox_name = NULL; | ||
218 | char *name; | ||
219 | |||
220 | if (mu_sql_get_column (conn, 0, 0, &name)) | ||
221 | return MU_ERR_FAILURE; | ||
222 | |||
223 | if (n == 7) | ||
224 | { | ||
225 | char *tmp; | ||
226 | if (mu_sql_get_column (conn, 0, 6, &tmp)) | ||
227 | return MU_ERR_FAILURE; | ||
228 | if (tmp && (mailbox_name = strdup (tmp)) == NULL) | ||
229 | return ENOMEM; | ||
230 | } | ||
231 | else if (mu_construct_user_mailbox_url (&mailbox_name, name)) | ||
232 | return MU_ERR_FAILURE; | ||
233 | |||
234 | if (mailbox_name) | ||
235 | { | ||
236 | char *passwd, *suid, *sgid, *dir, *shell; | ||
237 | |||
238 | if (mu_sql_get_column (conn, 0, 1, &passwd) | ||
239 | || !passwd | ||
240 | || mu_sql_get_column (conn, 0, 2, &suid) | ||
241 | || !suid | ||
242 | || mu_sql_get_column (conn, 0, 3, &sgid) | ||
243 | || !sgid | ||
244 | || mu_sql_get_column (conn, 0, 4, &dir) | ||
245 | || !dir | ||
246 | || mu_sql_get_column (conn, 0, 5, &shell) | ||
247 | || !shell) | ||
248 | return MU_ERR_FAILURE; | ||
249 | |||
250 | rc = mu_auth_data_alloc (return_data, | ||
251 | name, | ||
252 | passwd, | ||
253 | atoi (suid), | ||
254 | atoi (sgid), | ||
255 | "SQL User", | ||
256 | dir, | ||
257 | shell, | ||
258 | mailbox_name, | ||
259 | 1); | ||
260 | } | ||
261 | else | ||
262 | rc = MU_ERR_AUTH_FAILURE; | ||
263 | |||
264 | free (mailbox_name); | ||
265 | return rc; | ||
266 | } | ||
267 | |||
268 | static int | 224 | static int |
269 | get_field (mu_sql_connection_t conn, const char *id, char **ret, int mandatory) | 225 | get_field (mu_sql_connection_t conn, const char *id, char **ret, int mandatory) |
270 | { | 226 | { |
... | @@ -292,7 +248,7 @@ get_field (mu_sql_connection_t conn, const char *id, char **ret, int mandatory) | ... | @@ -292,7 +248,7 @@ get_field (mu_sql_connection_t conn, const char *id, char **ret, int mandatory) |
292 | } | 248 | } |
293 | 249 | ||
294 | static int | 250 | static int |
295 | decode_tuple_new (mu_sql_connection_t conn, int n, | 251 | decode_tuple (mu_sql_connection_t conn, int n, |
296 | struct mu_auth_data **return_data) | 252 | struct mu_auth_data **return_data) |
297 | { | 253 | { |
298 | int rc; | 254 | int rc; |
... | @@ -403,16 +359,6 @@ decode_tuple_new (mu_sql_connection_t conn, int n, | ... | @@ -403,16 +359,6 @@ decode_tuple_new (mu_sql_connection_t conn, int n, |
403 | } | 359 | } |
404 | 360 | ||
405 | static int | 361 | static int |
406 | decode_tuple (mu_sql_connection_t conn, int n, | ||
407 | struct mu_auth_data **return_data) | ||
408 | { | ||
409 | if (mu_sql_module_config.field_map || !mu_sql_module_config.positional) | ||
410 | return decode_tuple_new (conn, n, return_data); | ||
411 | else | ||
412 | return decode_tuple_v1_0 (conn, n, return_data); | ||
413 | } | ||
414 | |||
415 | static int | ||
416 | mu_auth_sql_by_name (struct mu_auth_data **return_data, | 362 | mu_auth_sql_by_name (struct mu_auth_data **return_data, |
417 | const void *key, | 363 | const void *key, |
418 | void *func_data MU_ARG_UNUSED, | 364 | void *func_data MU_ARG_UNUSED, |
... | @@ -723,9 +669,9 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED, | ... | @@ -723,9 +669,9 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED, |
723 | if ((rc = mu_sql_getpass (auth_data->name, &sql_pass))) | 669 | if ((rc = mu_sql_getpass (auth_data->name, &sql_pass))) |
724 | return rc; | 670 | return rc; |
725 | 671 | ||
726 | switch (mu_sql_module_config.password_type) | 672 | switch (mu_sql_module_config.password_encryption) |
727 | { | 673 | { |
728 | case password_hash: | 674 | case mu_sql_password_hash: |
729 | crypt_pass = crypt (pass, sql_pass); | 675 | crypt_pass = crypt (pass, sql_pass); |
730 | if (!crypt_pass) | 676 | if (!crypt_pass) |
731 | rc = 1; | 677 | rc = 1; |
... | @@ -733,7 +679,7 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED, | ... | @@ -733,7 +679,7 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED, |
733 | rc = strcmp (sql_pass, crypt_pass); | 679 | rc = strcmp (sql_pass, crypt_pass); |
734 | break; | 680 | break; |
735 | 681 | ||
736 | case password_scrambled: | 682 | case mu_sql_password_scrambled: |
737 | /* FIXME: Should this call be implementation-independent? I mean, | 683 | /* FIXME: Should this call be implementation-independent? I mean, |
738 | should we have mu_sql_check_scrambled() that will match the | 684 | should we have mu_sql_check_scrambled() that will match the |
739 | password depending on the exact type of the underlying database, | 685 | password depending on the exact type of the underlying database, |
... | @@ -745,7 +691,7 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED, | ... | @@ -745,7 +691,7 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED, |
745 | #endif | 691 | #endif |
746 | break; | 692 | break; |
747 | 693 | ||
748 | case password_plaintext: | 694 | case mu_sql_password_plaintext: |
749 | rc = strcmp (sql_pass, pass); | 695 | rc = strcmp (sql_pass, pass); |
750 | break; | 696 | break; |
751 | } | 697 | } | ... | ... |
-
Please register or sign in to post a comment