Skip to main content

socketmap-sql

A socketmap script for interfacing with an SQL database.

Why?

I have a number of FreeBSD servers, with one intended to act as my primary mailserver (the current one and remaining one becoming secondary mailservers). The problem is that I’m using Postfix, and trying very hard to stick to precompiled packages rather than using ports, and Postfix on FreeBSD lacks bindings to databases. In my case, I wanted to be able to use an SQL database.

Configuration format

Configuration files are INI files containing two types of section.

First is the [database] section, which gives database connection details. The driver field specifies the driver to use; if omitted, its value defaults to sqlite3. The remaining fields are passed to the driver’s connect() function.

[database]
driver = sqlite3
database = /path/to/sqlite.db

Other sections start with table:, and denote virtual tables to be queried. There are two fields: transform (optional) and query (required).

The transform field gives the name of a transformation to apply to the query parameter before its use in the query the query. The default is to accept the parameter as-is (all). Other values can be a reference to a Python function in the form ‘module:function’, local for just the local part, domain for the domain part of the address, and split breaks an email address in two. It must return a list or tuple giving the postitional arguments to use in the query.

The query field give an SQL query to be used to generate the synthetic table. Use placeholders as specified by the database driver’s documentation.

Usage

Run with:

socketmap-sql --config /path/to/config.ini

If you don’t provide the –config flag, it defaults to /etc/socketmap-sql.ini.

Postfix

This script is intended to be executed by Postfix’s spawn mechanism, meaning it reads its input and writes its output to stdin and stdout respectively.

Assuming you’ve installed the script in /usr/local/libexec, add the following to master.cf:

sockmapd  unix  -      -       n       -       1       spawn
  user=nobody argv=/usr/local/libexec/socketmap-sql

Compatibility

The script only works on Python 3.8+.

Metadata

Release files for socketmap-sql 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for socketmap-sql 0.2.1
File Size Uploaded Provenance Actions
socketmap_sql-0.2.1.tar.gz 5.7 kB Without provenance Details for socketmap_sql-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for socketmap-sql 0.2.1
File Interpreter ABI Platform Actions
socketmap_sql-0.2.1-py3-none-any.whl Python 3 none any Details for socketmap_sql-0.2.1-py3-none-any.whl

Total release size: 11.7 kB

Release files / socketmap_sql-0.2.1.tar.gz

Download URL socketmap_sql-0.2.1.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d2959cdfe52fa0aa6f01f35f0f4e8d402d8769018ed37b7d1505abef1c38c7dc
BLAKE2b-256 checksum
How to use checksums
9fe4468a811b90a6692492eb4f9894019fccb10f3b7c8aaf1606f7d2a074a17f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / socketmap_sql-0.2.1-py3-none-any.whl

Download URL socketmap_sql-0.2.1-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
777565c7a5ba1204d7c6cbac9eafd7eb776a7299af704dae0183a5cab2e7c03f
BLAKE2b-256 checksum
How to use checksums
8ed9a284233c4ab6654b82c5c69d1254ea65a9a3df308d7991a49cf4df1c95ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for socketmap-sql 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page