-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable-redis.5
152 lines (152 loc) · 5.39 KB
/
table-redis.5
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
.\" Copyright (c) 2015 Emmanuel Vadot <[email protected]>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\"
.Dd $Mdocdate: April 21 2024 $
.Dt TABLE_REDIS 5
.Os
.Sh NAME
.Nm table_redis
.Nd format description for smtpd redis tables
.Sh DESCRIPTION
This manual page documents the file format of redis tables used by the
.Xr smtpd 8
mail daemon.
.Pp
The format described here applies to tables as defined in
.Xr smtpd.conf 5 .
.Sh REDIS TABLE
A Redis table allows the storing of usernames, passwords, aliases, and domains
in a redis server.
.Pp
The table is used by
.Xr smtpd 8
when authenticating a user, when user information such as user-id and/or
home directory is required for a delivery, when a domain lookup may be required,
and/or when looking for an alias.
.Pp
A Redis table consists of one Redis Databases with one or more keys.
.Pp
If the table is used for authentication, the password should be
encrypted using the
.Xr crypt 3
function.
Such passwords can be generated using the
.Xr encrypt 1
utility or
.Xr smtpctl 8
encrypt command.
.Sh REDIS TABLE CONFIG FILE
.Bl -tag -width query_credentials
.It Cm master
This is the IP of the master redis server.
To connect via an unix socket use unix:/path/to/sock
The default is 127.0.0.1
.It Cm master_port
This is the port used to connect to the master redis server.
The default is 6379
.It Cm slave
This is the IP of the slave redis server, if any.
To connect via an unix socket use unix:/path/to/sock
.It Cm slave_port
This is the port used to connect to the slave redis server if any.
.It Cm database
The database number to use.
The default is 0.
.It Cm password
The password to use to authenticate to the redis server if any.
.It Cm query_domain
This is used to provide a query for a domain query call.
All the '%s' are replaced
with the appropriate data, in this case it would be the right hand side of
the SMTP address.
This expects one string to be returned with a matching domain name.
.It Cm query_userinfo
This is used to provide a query for looking up user information.
All the '%s' are replaced with the appropriate data, in this case it
would be the left hand side of the SMTP address.
This expects three fields to be returned an int containing a UID, an int
containing a GID
and a string containing the home directory for the user.
.It Cm query_credentials
This is used to provide a query for looking up credentials.
All the '%s' are replaced
with the appropriate data, in this case it would be the left hand side of
the SMTP address.
the query expects that there are two strings returned one with a
user name one with a password in encrypted format.
.It Cm query_alias
This is used to provide a query to look up aliases.
All the '%s' are replaced with the appropriate data, in this case it would
be the left hand side of the SMTP address.
This expects one string to be returned with the user name the alias resolves to.
If the query returns an array, all the data will be concatenated into one
string with ',' as a separator
.It Cm query_mailaddr
This is used to provide a query to check if a mail address exists.
All the '%s' are replaced with the appropriate data, in this case it would
be the SMTP address.
This expects an integer as a reply, 0 = false and 1 = true
.El
.Sh EXAMPLES
Due to the nature of redis, multiple schemas can be used.
Those provided here a known to work.
.Bl -tag -width 1
.It Cm domain
Using a set for the domains:
.Dl # redis-cli sadd domains example.net
in the redis table configuration file:
.Dl query_domain SISMEMBER domains %s
.It Cm userinfo
Hash works well for users
.Dl # redis-cli HSET user:foo uid 1001
.Dl # redis-cli HSET user:foo gid 1001
.Dl # redis-cli HSET user:foo maildir "/mail/foo"
in the redis table configuration file :
.Dl query_userinfo HMGET user:%s uid gid maildir
.It Cm credentials
We can extend the hash for our user to put credential in it
.Dl # redis-cli HSET user:foo login foo
.Dl # redis-cli HSET user:foo passwd encrypted_password
in the redis table configuration file:
.Dl query_credentials HMGET user:%s login passwd
.It Cm alias
Using redis sorted list:
.Dl # redis-cli LPUSH aliases:[email protected] foo
.Dl # redis-cli LPUSH aliases:[email protected] foo
in the redis table configuration file:
.Dl query_alias LRANGE aliases:%s 0 -1
.It Cm mailaddr
Using a set for the addresses:
.Dl # redis-cli sadd mailaddr [email protected]
in the redis table configuration file:
.Dl query_mailaddr SISMEMBER mailaddr %s
.El
.Sh SEE ALSO
.Xr encrypt 1 ,
.Xr smtpd.conf 5 ,
.Xr smtpctl 8 ,
.Xr smtpd 8
.Sh HISTORY
The first version of
.Nm
was written in 2015.
It was converted to the stdio protocol in 2024.
.Sh AUTHORS
.An -nosplit
.Nm
was initially written by
.An Emmanuel Vadot Aq Mt [email protected] .
The conversion to the stdio table protocol was done by
.An Omar Polo Aq Mt [email protected] .