TABLE_REDIS(5)

πŸ“¦
version 1.0.1 Β· 2 versions
, in alpine 3.24, debian trixie, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ TABLE_REDIS(5) ✨

okay so this is the table_redis page from the File Formats Manual, and bestie, if you're setting up smtpd(8) tables backed by redis, this is literally your roman empire. let's get into it πŸ’…


🌸 NAME 🌸

table_redis β€” the format description for smtpd redis tables. that's it, that's the name, she's iconic and she knows it ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

This manual page documents the file format of redis tables used by the smtpd(8) mail daemon. no cap.

The format described here applies to tables as defined in smtpd.conf(5). iykyk.


πŸ’– REDIS TABLE πŸ’–

A Redis table lets you store usernames, passwords, aliases, and domains in a redis server. it's giving organized queen energy πŸ‘‘

The table is used by 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.

A Redis table consists of one Redis Databases with one or more keys. (yes, the original says "one Redis Databases" β€” we don't edit the source material, we respect the source material 🫢)

🚨 important glow-up check: If the table is used for authentication, the password should be encrypted using the crypt(3) function. Such passwords can be generated using the encrypt(1) utility or smtpctl(8) encrypt command. do not be out here storing plaintext passwords, i am begging 😭

πŸŽ€ REDIS TABLE CONFIG FILE πŸŽ€

these are the config keys, and every single one of them matters, so no skipping:

  • 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.
  • master_port β€” This is the port used to connect to the master redis server. The default is 6379.
  • slave β€” This is the IP of the slave redis server, if any. To connect via an unix socket use unix:/path/to/sock.
  • slave_port β€” This is the port used to connect to the slave redis server if any.
  • database β€” The database number to use. The default is 0.
  • password β€” The password to use to authenticate to the redis server if any.
  • 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.
  • 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.
  • 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.
  • 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.
  • 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.

🌈 EXAMPLES 🌈

Due to the nature of redis, multiple schemas can be used. Those provided here a known to work. (again β€” not our typo to fix, we're just the messenger πŸ’€)

πŸ“ domain

Using a set for the domains:

# redis-cli sadd domains example.net

in the redis table configuration file:

query_domain SISMEMBER domains %s

🧚 userinfo

Hash works well for users:

# redis-cli HSET user:foo uid 1001
# redis-cli HSET user:foo gid 1001
# redis-cli HSET user:foo maildir /mail/foo

in the redis table configuration file :

query_userinfo HMGET user:%s uid gid maildir

πŸ’œ credentials

We can extend the hash for our user to put credential in it:

# redis-cli HSET user:foo login foo
# redis-cli HSET user:foo passwd encrypted_password

in the redis table configuration file:

query_credentials HMGET user:%s login passwd

⭐ alias

Using redis sorted list:

# redis-cli LPUSH aliases:foo@example.net foo
# redis-cli LPUSH aliases:bar@example.net foo

in the redis table configuration file:

query_alias LRANGE aliases:%s 0 -1

πŸ”₯ mailaddr

Using a set for the addresses:

# redis-cli sadd mailaddr foo@example.net

in the redis table configuration file:

query_mailaddr SISMEMBER mailaddr %s

πŸ‘‘ SEE ALSO πŸ‘‘

encrypt(1), smtpd.conf(5), smtpctl(8), smtpd(8)

go read them, bestie, they're all part of the lore πŸ“š


πŸ•°οΈ HISTORY πŸ•°οΈ

The first version of table_redis was written in 2015. It was converted to the stdio protocol in 2024. glow-up of the decade, honestly ✨


πŸ’Œ AUTHORS πŸ’Œ

table_redis was initially written by Emmanuel Vadot <elbarto@bocal.org>. The conversion to the stdio table protocol was done by Omar Polo <op@openbsd.org>. legends, both of them 🫢


and that's the whole page! this gem is from the Debian edition, dated April 21, 2024, and it's giving certified classic. now go forth and configure your redis tables, you absolute main character πŸ’…πŸ’–