Commit 98f645ab 98f645aba8c3dffe26996c1e5ba3974632c12549 by Sergey Poznyakoff

Bugfixes.

* doc/texinfo/programs.texi: Document Locking, ACL, and
Tcp-wrappers.
* mailbox/cfg_driver.c (mu_cfg_assert_value_type): Convert
MU_CFG_STRING to MU_CFG_ARRAY.
* mailbox/cfg_parser.y: Replace `tag: value' with `tag: vallist'.
This allows for constructs like `acl a b c {', which were
understood by the previous version.
* mailbox/version.c (mu_conf_opt): Add WITH_LIBWRAP.
1 parent c925d1da
1 2008-10-05 Sergey Poznyakoff <gray@gnu.org.ua>
2
3 * doc/texinfo/programs.texi: Document Locking, ACL, and
4 Tcp-wrappers.
5 * mailbox/cfg_driver.c (mu_cfg_assert_value_type): Convert
6 MU_CFG_STRING to MU_CFG_ARRAY.
7 * mailbox/cfg_parser.y: Replace `tag: value' with `tag: vallist'.
8 This allows for constructs like `acl a b c {', which were
9 understood by the previous version.
10 * mailbox/version.c (mu_conf_opt): Add WITH_LIBWRAP.
11
1 2008-09-29 Sergey Poznyakoff <gray@gnu.org.ua> 12 2008-09-29 Sergey Poznyakoff <gray@gnu.org.ua>
2 13
3 * config/mailutils-config.c (main): Do not print flag descriptions 14 * config/mailutils-config.c (main): Do not print flag descriptions
......
...@@ -1018,7 +1018,6 @@ The default folder name is @samp{Mail/}. ...@@ -1018,7 +1018,6 @@ The default folder name is @samp{Mail/}.
1018 1018
1019 @node Locking Statement 1019 @node Locking Statement
1020 @subsection Locking Statement 1020 @subsection Locking Statement
1021 @UNREVISED
1022 @kwindex locking 1021 @kwindex locking
1023 @subheading Syntax 1022 @subheading Syntax
1024 @smallexample 1023 @smallexample
...@@ -1036,9 +1035,60 @@ locking @{ ...@@ -1036,9 +1035,60 @@ locking @{
1036 @} 1035 @}
1037 @end smallexample 1036 @end smallexample
1038 1037
1038 @subheading Description
1039 This block statement configures various parameters used when locking
1040 UNIX mailboxes in order to prevent simultaneous writes.
1041
1042 It is important to note, that locking applies only to maildrops in
1043 UNIX mailbox format. All other mailbox types do not require locking.
1044
1045 @deffn {Configuration} flags @var{string}
1046 Set locking flags. Argument is a string consisting of one or more of
1047 the following letters:
1048
1049 @table @asis
1050 @item E
1051 Use an external program to manage locks. The program is given by
1052 @code{external-locker} statement (see below).
1053
1054 @item R
1055 If the locking attempt failed, retry it. This is the default. The
1056 number of retries, and time interval between the two successive
1057 attempts is given by @code{retry-count} and @code{retry-timeout}
1058 statements, correspondingly.
1059
1060 @item T
1061 If a lock file exists, check its modification time and, if it is
1062 older than a predefined amount of time, remove the lock. The amount
1063 of time is specified by @code{expire-timeout} statement.
1064
1065 @item P
1066 Store the PID of the locking process in a lock file.
1067 @end table
1068 @end deffn
1069
1070 @deffn {Configuration} retry-count @var{number}
1071 Number of locking attemtps. The @samp{P} flag must be set for this to
1072 take effect.
1073 @end deffn
1074
1075 @deffn {Configuration} retry-timeout @var{seconds}
1076 Time interval, in seconds, between the two successive locking
1077 attempts. The @samp{P} flag must be set for this to take effect.
1078 @end deffn
1079
1080 @deffn {Configuration} expire-timeout @var{seconds}
1081 Remove existing lock file, if it is created more than this number of
1082 seconds ago. The @samp{T} flag must be set for this to take effect.
1083 @end deffn
1084
1085 @deffn {Configuration} external-locker @var{string}
1086 Set command line of an external locker program. The @samp{E} flag
1087 must be set for this to take effect.
1088 @end deffn
1089
1039 @node ACL Statement 1090 @node ACL Statement
1040 @subsection ACL Statement 1091 @subsection ACL Statement
1041 @UNREVISED
1042 @kwindex acl 1092 @kwindex acl
1043 @subheading Syntax 1093 @subheading Syntax
1044 @smallexample 1094 @smallexample
...@@ -1058,9 +1108,119 @@ acl @{ ...@@ -1058,9 +1108,119 @@ acl @{
1058 @} 1108 @}
1059 @end smallexample 1109 @end smallexample
1060 1110
1111 @subheading Description
1112 The ACL statement defines an @dfn{Access Control List}, a special
1113 structure that controls who can access the given Mailutils resource.
1114
1115 The @code{acl} block contains a list of access controls. Each control
1116 can be regarded as a function that returns a tree-state value:
1117 @samp{True}, @samp{False} and @samp{Don't know}. When a
1118 remote party connects to the server, each of controls is tried in
1119 turn. If a control returns @samp{False}, access is denied. If it
1120 retruns @samp{True}, access is allowed. If it returns @samp{Don't
1121 know}, then the next control is tried. It is unclear whether to allow
1122 access if the last control in list returned @samp{Don't know}. GNU
1123 Mailutils @value{VERSION} issues a warning message and allows access.
1124 This default may change in future versions. Users are advised to
1125 write their ACLs so that the last control returns a definitive answer
1126 (either @code{True} or @code{False}).
1127
1128 In the discussion below, wherever @var{ip} appears as an argument, it
1129 can be replaced by any of:
1130
1131 @itemize @bullet
1132 @item An IPv4 address in dotted-quad notation.
1133 @item A CIDR in the form @samp{@var{ip}/@var{mask}}, where @var{ip} is
1134 an IPv4 address, and @var{mask} is a decimal number in the range
1135 @samp{0--32}.
1136 @item A symbolic host name.
1137 @kwindex any
1138 @item A word @samp{any}, that stands for @samp{0.0.0.0/0}.
1139 @end itemize
1140
1141 The following controls are understood:
1142
1143 @deffn {Configuration} allow [from] @var{cidr}
1144 Allow connections from IP addresses matching this @var{cidr} block.
1145 @end deffn
1146
1147 @deffn {Configuration} deny [from] @var{cidr}
1148 Deny connections from IP addresses matching this @var{cidr} block.
1149 @end deffn
1150
1151 @deffn {Configuration} ifexec [from] @var{cidr} @var{program}
1152 When a connection from the @var{cidr} block is requested, execute
1153 the program @var{program}. If its exit code is @samp{0}, then allow
1154 connection. Otherwise, deny it.
1155 @end deffn
1156
1157 The following two controls are provided for logging purposes and as a
1158 means of extensions. They always return a @samp{Don't know} answer,
1159 and therefore should not be used at the end of an ACL:
1160
1161 @deffn {Configuration} log [from] @var{cidr} [@var{string}]
1162 Log connections from addresses in this @var{cidr}. The
1163 @code{MU_DIAG_INFO} channel is used. If the logging goes to syslog,
1164 it is translated to the @code{LOG_INFO} priority.
1165
1166 If @var{string} is not given, the format of the log entry depends on
1167 the connection family, as described in the table below:
1168
1169 @table @asis
1170 @item @{AF_INET @var{ip}:@var{port}@}
1171 For inet IPv4 connections. The variables @var{ip} and @var{port} are
1172 replaced by the remote IP address and port number, correspondingly.
1173
1174 @item @{AF_UNIX@}
1175 For connections over UNIX sockets. The socket name, if available, may
1176 be printed before the closing curly brace.
1177 @end table
1178
1179 If the @var{string} is specified, it undergoes macro expansion and the
1180 result of it is used as the log entry. The following macro variables
1181 are expanded:
1182
1183 @table @code
1184 @item aclno
1185 Ordinal number of the control in the ACL. Numbers begin from
1186 @samp{0}.
1187
1188 @item family
1189 Connection family. Mailutils version @value{VERSION} supports two
1190 families: @samp{AF_INET} and @samp{AF_UNIX}.
1191
1192 @item address
1193 Remote IP address (for @samp{AF_INET}) or socket name (for
1194 @samp{AF_UNIX}). Notice that most Unices return empty string instead
1195 of the @samp{AF_UNIX} socket name, so do not rely on it.
1196
1197 @item port
1198 Remote port number (for @samp{AF_INET}).
1199 @end table
1200
1201 For example, the following ACL makes a Mailutils server log every
1202 incoming connection:
1203
1204 @smallexample
1205 acl @{
1206 log from any "Connect from $@{address@}";
1207 ...
1208 @}
1209 @end smallexample
1210
1211 This was the default behavior for the versions of Mailutils up to
1212 @samp{1.2}, so if you got used to its logs you might wish to add the
1213 above in your configuration files.
1214 @end deffn
1215
1216 @deffn {Configuration} exec [from] @var{cidr} @var{program}
1217 If a connection from the @var{cidr} block is requested, execute
1218 the given @var{program}. Do not wait for it to teminate, and ignore
1219 its exit code.
1220 @end deffn
1221
1061 @node Tcp-wrappers Statement 1222 @node Tcp-wrappers Statement
1062 @subsection Tcp-wrappers Statement 1223 @subsection Tcp-wrappers Statement
1063 @UNREVISED
1064 @kwindex tcp-wrappers 1224 @kwindex tcp-wrappers
1065 @subheading Syntax 1225 @subheading Syntax
1066 @smallexample 1226 @smallexample
...@@ -1080,6 +1240,55 @@ tcp-wrappers @{ ...@@ -1080,6 +1240,55 @@ tcp-wrappers @{
1080 @} 1240 @}
1081 @end smallexample 1241 @end smallexample
1082 1242
1243 @subsection Description
1244 The @code{tcp-wrappers} statements provides an alternative way to
1245 control accesses to the resources served by GNU Mailutils. This
1246 statement is enabled if Mailutils is compiled with TCP wrappers
1247 library @command{libwrap}.
1248
1249 Access control using TCP wrappers is based on two files, called
1250 @dfn{tables}, containing access rules. There are two tables: the
1251 @dfn{allow table}, usually stored in file @file{/etc/hosts.allow}, and
1252 the @dfn{deny table}, kept in file @file{/etc/hosts.deny}. The rules
1253 in each table begin with an identifier called @dfn{daemon name}. Each
1254 utility wishing to verify a connection, select the entries having
1255 its daemon name from the allow table. A connection is allowed if it
1256 matches any of these entries. Otherwise, the utility retrieves all
1257 entries with its daemon name from the deny table. If any of these
1258 matches the connection, then it is refused. Otherwise, if neither
1259 table contains matching entries, the connection is allowed.
1260
1261 Description of a TCP wrapper table format lies outside the scope of
1262 this document. Please, see @cite{man 5 hosts_access} for details.
1263
1264 @deffn {Configuration} enable @var{bool}
1265 Enable access control using TCP wrappers. It is on by default.
1266 @end deffn
1267
1268 @deffn {Configuration} daemon @var{name}
1269 Set daemon name for TCP wrapper lookups. By default, the name of the
1270 utility is used. E.g. @command{imap4d} uses @samp{imap4d} as the
1271 daemon name.
1272 @end deffn
1273
1274 @deffn {Configuration} allow-table @var{file}
1275 Use @var{file} as allow table. By default, @file{/etc/hosts.allow} is
1276 used.
1277 @end deffn
1278
1279 @deffn {Configuration} deny-table @var{file}
1280 Use @var{file} as negative table. By default, @file{/etc/hosts.deny}
1281 is used.
1282 @end deffn
1283
1284 @deffn {Configuration} allow-syslog-priority @var{prio};
1285 Log allowed accesses using syslog priority @var{prio}.
1286 @end deffn
1287
1288 @deffn {Configuration} deny-syslog-priority @var{prio};
1289 Log denied accesses using syslog priority @var{prio}.
1290 @end deffn
1291
1083 @node Server Settings 1292 @node Server Settings
1084 @subsection Server Settings 1293 @subsection Server Settings
1085 @UNREVISED 1294 @UNREVISED
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
37 #include <mailutils/iterator.h> 37 #include <mailutils/iterator.h>
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 41
41 42
42 static mu_assoc_t section_tab; 43 static mu_assoc_t section_tab;
...@@ -677,6 +678,18 @@ mu_cfg_assert_value_type (mu_config_value_t *val, int type, mu_debug_t debug) ...@@ -677,6 +678,18 @@ mu_cfg_assert_value_type (mu_config_value_t *val, int type, mu_debug_t debug)
677 return 1; 678 return 1;
678 } 679 }
679 680
681 if (type == MU_CFG_ARRAY)
682 {
683 if (val->type == MU_CFG_STRING)
684 {
685 mu_config_value_t *arr = mu_calloc (1, sizeof arr[0]);
686 arr[0] = *val;
687 val->v.arg.c = 1;
688 val->v.arg.v = arr;
689 val->type = MU_CFG_ARRAY;
690 }
691 }
692
680 if (val->type != type) 693 if (val->type != type)
681 { 694 {
682 /* FIXME */ 695 /* FIXME */
......
...@@ -238,10 +238,7 @@ tag : /* empty */ ...@@ -238,10 +238,7 @@ tag : /* empty */
238 { 238 {
239 $$ = NULL; 239 $$ = NULL;
240 } 240 }
241 | value 241 | vallist
242 {
243 $$ = config_value_dup (&$1);
244 }
245 ; 242 ;
246 243
247 vallist : vlist 244 vallist : vlist
......
...@@ -93,6 +93,9 @@ static struct mu_conf_option mu_conf_option[] = { ...@@ -93,6 +93,9 @@ static struct mu_conf_option mu_conf_option[] = {
93 #ifdef WITH_LDAP 93 #ifdef WITH_LDAP
94 { "WITH_LDAP", }, 94 { "WITH_LDAP", },
95 #endif 95 #endif
96 #ifdef WITH_LIBWRAP
97 { "WITH_LIBWRAP", N_("Support for TCP wrappers") },
98 #endif
96 #ifdef ENABLE_VIRTUAL_DOMAINS 99 #ifdef ENABLE_VIRTUAL_DOMAINS
97 { "ENABLE_VIRTUAL_DOMAINS", N_("Support for virtual mail domains") }, 100 { "ENABLE_VIRTUAL_DOMAINS", N_("Support for virtual mail domains") },
98 #endif 101 #endif
......