-.\" $OpenBSD: table.5,v 1.13 2023/12/27 11:29:56 op Exp $
+.\" $OpenBSD: table.5,v 1.14 2024/05/02 18:14:33 op Exp $
.\"
.\" Copyright (c) 2013 Eric Faurot <eric@openbsd.org>
.\" Copyright (c) 2013 Gilles Chehade <gilles@poolp.org>
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\"
-.Dd $Mdocdate: December 27 2023 $
+.Dd $Mdocdate: May 2 2024 $
.Dt TABLE 5
.Os
.Sh NAME
A netaddr table can contain exact addresses or netmasks, and looks as follow:
.Bd -literal -offset indent
192.168.1.1
-::1
-ipv6:::1
+[::1]
192.168.1.0/24
.Ed
+.Pp
+IPv6 addresses must be enclosed in square brackets.
.Ss Userinfo tables
Userinfo tables are used in rule context to specify an alternate userbase,
mapping virtual users to local system users by UID, GID and home directory.
.Bd -literal -offset indent
192.168.1.2
192.168.1.3
-::1
-::2
-ipv6:::3
-ipv6:::4
+[::1]
+[::2]
.Ed
+.Pp
+IPv6 address must be enclosed in square brackets.
.Ss Mailaddr tables
Mailaddr tables are lists of email addresses.
They can be used in the following contexts:
.Pp
The format is a mapping from inet4 or inet6 addresses to hostnames:
.Bd -literal -offset indent
-::1 localhost
+[::1] localhost
127.0.0.1 localhost
88.190.23.165 www.opensmtpd.org
.Ed
+.Pp
+IPv6 addresses must be enclosed in square brackets.
.Sh SEE ALSO
.Xr smtpd.conf 5 ,
.Xr makemap 8 ,
-/* $OpenBSD: util.c,v 1.156 2024/02/11 09:24:26 op Exp $ */
+/* $OpenBSD: util.c,v 1.157 2024/05/02 18:14:33 op Exp $ */
/*
* Copyright (c) 2000,2001 Markus Friedl. All rights reserved.
parse_table_line(FILE *fp, char **line, size_t *linesize,
int *type, char **key, char **val, int *malformed)
{
- char *keyp, *valp, *p;
+ char *keyp, *valp;
ssize_t linelen;
*key = NULL;
return 0;
}
- if (*type == T_NONE) {
- for (p = keyp; *p; p++) {
- if (*p == ' ' || *p == '\t' || *p == ':') {
- *type = T_HASH;
- break;
- }
+ if (*keyp == '[') {
+ if ((valp = strchr(keyp, ']')) == NULL) {
+ *malformed = 1;
+ return (0);
}
- if (*type == T_NONE)
- *type = T_LIST;
- }
+ valp++;
+ } else
+ valp = keyp + strcspn(keyp, " \t:");
+
+ if (*type == T_NONE)
+ *type = (*valp == '\0') ? T_LIST : T_HASH;
if (*type == T_LIST) {
*key = keyp;
}
/* T_HASH */
- valp = keyp;
- strsep(&valp, " \t:");
- if (valp) {
- while (*valp) {
- if (!isspace((unsigned char)*valp) &&
- !(*valp == ':' &&
- isspace((unsigned char)*(valp + 1))))
- break;
- ++valp;
- }
- if (*valp == '\0')
- valp = NULL;
+ if (*valp != '\0') {
+ *valp++ = '\0';
+ valp += strspn(valp, " \t");
}
- if (valp == NULL)
+ if (*valp == '\0')
*malformed = 1;
*key = keyp;