]> git.proxmox.com Git - pmg-api.git/log
pmg-api.git
3 years agoquarantine: self service: early return for limit check, consistent code
Thomas Lamprecht [Wed, 18 Nov 2020 16:25:44 +0000 (17:25 +0100)]
quarantine: self service: early return for limit check, consistent code

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoquarantine: drop unnecesarry use statements
Thomas Lamprecht [Wed, 18 Nov 2020 16:24:53 +0000 (17:24 +0100)]
quarantine: drop unnecesarry use statements

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoquarantine: self service rate limiting: use builtin time
Thomas Lamprecht [Wed, 18 Nov 2020 16:24:28 +0000 (17:24 +0100)]
quarantine: self service rate limiting: use builtin time

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi2/quarantine: add global sendlink api call
Dominik Csapak [Wed, 18 Nov 2020 10:59:36 +0000 (11:59 +0100)]
api2/quarantine: add global sendlink api call

this api call takes an email, checks it against the relay domains,
and prepares a custom quarantinelink for that email  and sends it there

this has to happen unauthenticated, since the idea is that the user
want to access the quarantine but has no current ticket (and no
old spam report with a ticket)

we rate limit the requests by allowing only a request per 5 seconds
(to prevent dos'ing the internal mail server) and only
one request per user/hour

this api call is disabled by default

if admins want even more ratelimiting, they can setup something
like fail2ban to block hosts hitting this api call often

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
3 years agoadd 'quarantinelink' to spamquar config
Dominik Csapak [Wed, 18 Nov 2020 10:59:35 +0000 (11:59 +0100)]
add 'quarantinelink' to spamquar config

to enable the 'Request Quarantine Link' button and api call

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
3 years agorefactor domain_regex to Utils
Dominik Csapak [Wed, 18 Nov 2020 10:59:34 +0000 (11:59 +0100)]
refactor domain_regex to Utils

we will need this somewhere else later

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
3 years agofix #3141: do not split on ', ' for returning the from header
Dominik Csapak [Wed, 18 Nov 2020 12:59:17 +0000 (13:59 +0100)]
fix #3141: do not split on ', ' for returning the from header

this is only used to display it in the gui, simply return the whole
from header instead of trying to find the first part

this was wrong in case someone sent an email with a from header like:

From: "Csapak, Dominik" <d.csapak@proxmox.com>

which would yield '"Csapak' as from part...

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
3 years agodo not create /cluster/<cid> unconditionally
Stoiko Ivanov [Wed, 18 Nov 2020 14:52:54 +0000 (15:52 +0100)]
do not create /cluster/<cid> unconditionally

while looking through the spooldir creation we noticed the mkdir call
on a relative path. This creates a '/cluster/<cid>/' directory on each system
which has a cluster.conf (<cid> being the node's clusterid). This is not used
since the spooldirs are in '/var/spool/pmg/cluster/'

Simply drop the mkdir call, since the spooldirs get created upon cluster
creation (PMG::API2::Cluster::create) and joining to an existing cluster.

Reported-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agofix clustersync after node-deletion
Stoiko Ivanov [Wed, 18 Nov 2020 14:52:53 +0000 (15:52 +0100)]
fix clustersync after node-deletion

This patch creates the spoolsdirs for a newly joining clusternode on the
master (/var/spool/pmg/cluster/<newnode-cid>/(spam|attachment|virus).

This is necessary in order to prevent a failing cluster-sync for nodes, joining
the cluster after that node has been deleted. (This happens if you remove
a node from the cluster and directly rejoin it to the same masternode):

On the first sync after a node was deleted (there is no section config for a
number < maxcid) each node tries to sync the quarantine for the deleted node
from the cluster (in order to be promotable to new master). This rsync
fails because the spooldir for that node never got created on the master.

The spooldir for a node gets created on the master on the first sync of a node
which can be 2 minutes after joining the cluster (and leaving it again).

Reported via our enterprise support portal.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agopbs: schedule: stop timer immediately on removal
Thomas Lamprecht [Wed, 18 Nov 2020 15:54:22 +0000 (16:54 +0100)]
pbs: schedule: stop timer immediately on removal

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: pbs: try to delete schedule on remote deletion
Thomas Lamprecht [Wed, 18 Nov 2020 15:48:59 +0000 (16:48 +0100)]
api: pbs: try to delete schedule on remote deletion

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobackup service template: update to new CLI
Thomas Lamprecht [Wed, 18 Nov 2020 15:40:51 +0000 (16:40 +0100)]
backup service template: update to new CLI

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: pbs schedule: return next-run
Thomas Lamprecht [Wed, 18 Nov 2020 15:30:44 +0000 (16:30 +0100)]
api: pbs schedule: return next-run

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agopbs: get_schedules: allow to filter by remote directly
Thomas Lamprecht [Wed, 18 Nov 2020 15:30:18 +0000 (16:30 +0100)]
pbs: get_schedules: allow to filter by remote directly

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agopbs: schema style fixes
Thomas Lamprecht [Wed, 18 Nov 2020 15:26:51 +0000 (16:26 +0100)]
pbs: schema style fixes

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agopmgbackup: fix missing semicolon leading to weird effects
Thomas Lamprecht [Wed, 18 Nov 2020 09:28:15 +0000 (10:28 +0100)]
pmgbackup: fix missing semicolon leading to weird effects

without as semicolon the code run at "compile" (initial parse) time,
not after that. Thus, every code error was attributed to an
compilation error, i.e., bad syntax or the like, not a runtime die.

This was visible as the program executed when using perl check
> # perl -wc src/bin/pmgbackup

which should normally not be the case

Originally-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agopmgbackup: rework CLI for pbs integration
Thomas Lamprecht [Wed, 18 Nov 2020 07:54:21 +0000 (08:54 +0100)]
pmgbackup: rework CLI for pbs integration

Update to new params.

The job is something different than the snapshots itself, so keep
that split.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoreinject_email: fix connecting for ipv6-only hosts
Stoiko Ivanov [Thu, 29 Oct 2020 17:49:16 +0000 (18:49 +0100)]
reinject_email: fix connecting for ipv6-only hosts

When configuring PMG only with ipv6 addresses, reinject_email after processing
fails to connect to the postfix/smtpd instance (with EINVAL).

Setting the host to '::FFFF:127.0.0.1' fixes the issue.

Tested with:
* an ipv6only host (no ipv4 configured)
* a host with ipv6 disabled via sysctl:
```
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1
```
* a host with dual-stack setup

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agobackup: add SA custom score file to backup
Stoiko Ivanov [Tue, 10 Nov 2020 17:56:35 +0000 (18:56 +0100)]
backup: add SA custom score file to backup

/etc/mail/spamassassin/pmg-scores.cf contains the custom scores users can
set via GUI. It should be included in the backup (and restored if present).

Reported via our community forum:
https://forum.proxmox.com/threads/backup-restore-bug.78605/

Tested on my local setup by creating a bogus score, creating a backup,
removing the pmg-scores file and restoring the backup.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agofix #3098: DKIM: sort domains by length first
Daniel Berteaud [Wed, 28 Oct 2020 10:20:15 +0000 (11:20 +0100)]
fix #3098: DKIM: sort domains by length first

So if we have a sub domain and its parent in the list, the correct
one will be returned

Signed-off-by: Daniel Berteaud <daniel@firewall-services.com>
[pmg-devel] [PATCH v2 pmg-api 1_1] [pmg-api] fix #3098 sort domains
by length first

3 years agoapi: pbs: rework api paths, more flexibility with foreign backups
Thomas Lamprecht [Tue, 17 Nov 2020 16:51:09 +0000 (17:51 +0100)]
api: pbs: rework api paths, more flexibility with foreign backups

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: pbs/get backup restore: adapt to abi changes
Thomas Lamprecht [Tue, 17 Nov 2020 13:46:18 +0000 (14:46 +0100)]
api: pbs/get backup restore: adapt to abi changes

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: pbs/get backup create: adapt to abi changes
Thomas Lamprecht [Tue, 17 Nov 2020 13:46:01 +0000 (14:46 +0100)]
api: pbs/get backup create: adapt to abi changes

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: pbs/get snapshots: adapt to abi change, code cleanup
Thomas Lamprecht [Tue, 17 Nov 2020 13:45:42 +0000 (14:45 +0100)]
api: pbs/get snapshots: adapt to abi change, code cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: pbs job: fix some schema meta errors
Thomas Lamprecht [Tue, 17 Nov 2020 13:44:43 +0000 (14:44 +0100)]
api: pbs job: fix some schema meta errors

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: pbs backup: only say we prune if actually setup
Thomas Lamprecht [Tue, 17 Nov 2020 13:44:02 +0000 (14:44 +0100)]
api: pbs backup: only say we prune if actually setup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: pbs job: whitespace indentation cleanup
Thomas Lamprecht [Tue, 17 Nov 2020 13:43:08 +0000 (14:43 +0100)]
api: pbs job: whitespace indentation cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoadd /etc/pmg/pbs to cluster-sync
Stoiko Ivanov [Mon, 16 Nov 2020 11:01:15 +0000 (12:01 +0100)]
add /etc/pmg/pbs to cluster-sync

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agoadd scheduled backup to PBS remotes
Stoiko Ivanov [Mon, 16 Nov 2020 11:01:14 +0000 (12:01 +0100)]
add scheduled backup to PBS remotes

PMG::PBSSchedule contains methods for creating/deleting systemd-timer units,
which will run a backup to a configured PBS remote.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agopbs-integration: add CLI calls to pmgbackup
Stoiko Ivanov [Mon, 16 Nov 2020 11:01:13 +0000 (12:01 +0100)]
pbs-integration: add CLI calls to pmgbackup

This patch adds to new categories for commands to pmgbackup:
* pmgbackup remote - for managing PBS instances' configuration, cluster-wide
* pmgbackup pbsjob - for managing backups, restores, pruning

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agoAdd API2 module for per-node backups to PBS
Stoiko Ivanov [Mon, 16 Nov 2020 11:01:12 +0000 (12:01 +0100)]
Add API2 module for per-node backups to PBS

The module adds API2 methods for:

* creating/restoring/listing/forgetting backups on a configured PBS remote

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agoapi/pbs remote: little code, indentation cleanup
Thomas Lamprecht [Tue, 17 Nov 2020 10:30:04 +0000 (11:30 +0100)]
api/pbs remote: little code, indentation cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoAdd API2 module for PBS configuration
Stoiko Ivanov [Mon, 16 Nov 2020 11:01:11 +0000 (12:01 +0100)]
Add API2 module for PBS configuration

The module provides the API methods for creating/updating/listing/deleting
PBS remotes

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agopbs config: whitespace and wording cleanups
Thomas Lamprecht [Tue, 17 Nov 2020 09:30:53 +0000 (10:30 +0100)]
pbs config: whitespace and wording cleanups

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoadd initial SectionConfig for PBS
Stoiko Ivanov [Mon, 16 Nov 2020 11:01:10 +0000 (12:01 +0100)]
add initial SectionConfig for PBS

add a SectionConfig definition to hold information about PBS-remotes used
for backing up PMG.

Mostly adapted from the PBSPlugin.pm in pve-storage.

This commit needs a versioned dependency on pve-common

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agodebian: drop duplicate ', ' in dependencies
Stoiko Ivanov [Mon, 16 Nov 2020 11:01:09 +0000 (12:01 +0100)]
debian: drop duplicate ', ' in dependencies

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agodebian: add dependency on proxmox-backup-client
Stoiko Ivanov [Wed, 28 Oct 2020 18:54:23 +0000 (19:54 +0100)]
debian: add dependency on proxmox-backup-client

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agoBackup: push restore options to PMG::Backup
Stoiko Ivanov [Wed, 28 Oct 2020 18:54:22 +0000 (19:54 +0100)]
Backup: push restore options to PMG::Backup

that way they can be reused for the PBS restore API call

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agopmg_restore: make sure restore directory is empty
Dietmar Maurer [Fri, 30 Oct 2020 06:25:44 +0000 (07:25 +0100)]
pmg_restore: make sure restore directory is empty

3 years agoRestore: optionally restore from directory
Stoiko Ivanov [Wed, 28 Oct 2020 18:54:21 +0000 (19:54 +0100)]
Restore: optionally restore from directory

In preparation for integrating PMG with PBS decide based on the type of the
provided filename, whether or not to untar:
* if it's a directory skip untarring (PBS)
* if it's a filename untar (local backup)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agopmg_backup: cleanup - remove useless mkdir
Dietmar Maurer [Fri, 30 Oct 2020 06:20:15 +0000 (07:20 +0100)]
pmg_backup: cleanup - remove useless mkdir

3 years agoBackup: split backup creation and creating tar
Stoiko Ivanov [Wed, 28 Oct 2020 18:54:20 +0000 (19:54 +0100)]
Backup: split backup creation and creating tar

In preparation for integrating PMG with PBS split the current creation of
a PMG backup into 2 methods:
* create all files in a backup in a target directory
* create a tarball from a backup in a temporary directory

use the changed method in the backup API call.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agodrop left-over commented out code
Stoiko Ivanov [Wed, 28 Oct 2020 18:54:19 +0000 (19:54 +0100)]
drop left-over commented out code

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agobump version to 6.2-6
Thomas Lamprecht [Wed, 23 Sep 2020 07:04:07 +0000 (09:04 +0200)]
bump version to 6.2-6

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoadd logging to disclaimer action
Stoiko Ivanov [Thu, 18 Jun 2020 11:33:17 +0000 (13:33 +0200)]
add logging to disclaimer action

the disclaimer action currently does not log, if a disclaimer got added or not.
given that there are a few not directly obvious cases where a disclaimer does
not get added (e.g. it depends on the mail's encoding) - logging success or
failure should help in debugging

Tested by sending mails, where adding the disclaimer works, and where it fails.
verified that the log-tracker also adds those lines to its output.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agoprefix message-id in attachment-quarantine
Stoiko Ivanov [Wed, 17 Jun 2020 15:04:05 +0000 (17:04 +0200)]
prefix message-id in attachment-quarantine

This patch fixes #2785.

When using the attachment quarantine - the message is:
a) stored in the quarantine unaltered
b) sent on with the attachment removed

Currently we do not change the message in any other way - in particular
we do not change the message-id header of any of the 2 mails.

When a mail is released from the attachment quarantine it is sent by PMG
with the same message-id as the mail with the attachments removed.

This is a violation of RFC 5322 (see [0]), and additionally newer versions
of Exchange do accept 2 mails with the same message-id but silently discard
the second version, thus making the attachment quarantine unusable for
Exchange users.

This patch simply prefixes the message-id with 'pmg-aquar-$$' (where $$ is
the pid of the pmg-smtp-filter process) for the mail without attachment.

By keeping the original message-id in the headers tracing the mailflow should
be facilitated.

The Message-ID is left intact on the original message in order to keep DKIM
signatures valid (they are invalidated on the modified mail by the removal
of the attachment anyways).

[0] https://tools.ietf.org/html/rfc5322 (section 3.6.4)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agobump version to 6.2-5
Thomas Lamprecht [Thu, 4 Jun 2020 14:49:19 +0000 (16:49 +0200)]
bump version to 6.2-5

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agofix #1976: optionally sort postfix queue result
Stoiko Ivanov [Thu, 28 May 2020 08:04:58 +0000 (10:04 +0200)]
fix #1976: optionally sort postfix queue result

The PostfixMailQueue widget uses an Ext.data.BufferedStore, due to
the potential size of the resultset, which does only support remoteSorting [0]

By adding two optional parameters ('sortfield' and 'sortdir') we can use
them for sorting the mailq output accordingly.

The sorting is kept in PMG::API2::Postfix instead of PMG::Postfix, because
sorting (as opposed to filtering) needs to happen after the complete result
is known, and there is no gain in pushing it further down.

[0] only mentioned in the source-code - not in the referencedoc

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agod/postinst: avoid processing non existent '*' templates due to glob
Thomas Lamprecht [Wed, 3 Jun 2020 17:37:32 +0000 (19:37 +0200)]
d/postinst: avoid processing non existent '*' templates due to glob

if there's no file at all in that path the wildcard glob won't expand
and POSIX shell will use '*' as filename, which will then fail.

Avoid that.

Reported-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agosubscription: followup: use correct errno variable if unlink fails
Thomas Lamprecht [Wed, 3 Jun 2020 17:36:20 +0000 (19:36 +0200)]
subscription: followup: use correct errno variable if unlink fails

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: allow to remove subscription
Moayad Almalat [Thu, 28 May 2020 08:51:30 +0000 (10:51 +0200)]
api: allow to remove subscription

Signed-off-by: Moayad Almalat <m.almalat@proxmox.com>
3 years agomake API/regextest match case-insensitive
Stoiko Ivanov [Thu, 28 May 2020 11:03:09 +0000 (13:03 +0200)]
make API/regextest match case-insensitive

The regext test api route is used when editing the following objects in the
rulesystem:
* WhoRegex
* MatchField
* MatchFilename
* MatchArchiveFilename

(list compiled by grepping (-i) for regextest in pmg-gui)

all of those objects are matched case-insensitively when a mail is processed
so the testing should also match case-insensitively.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agodrop bogus comment part
Thomas Lamprecht [Mon, 18 May 2020 12:33:05 +0000 (14:33 +0200)]
drop bogus comment part

introduced in commit 3ef629651148fffaf52446e56176664b6c948efe highly
probably by mistake, drop that part again.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobump version to 6.2-4
Thomas Lamprecht [Thu, 14 May 2020 15:52:06 +0000 (17:52 +0200)]
bump version to 6.2-4

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapi: mail tracker: cleanup strang assginment of declaration pattern
Thomas Lamprecht [Wed, 13 May 2020 11:46:45 +0000 (13:46 +0200)]
api: mail tracker: cleanup strang assginment of declaration pattern

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoMailTracker: handle before queue status
Stoiko Ivanov [Thu, 30 Apr 2020 15:01:51 +0000 (17:01 +0200)]
MailTracker: handle before queue status

corresponding to the patch for pmg-log-tracker, we need to translate the
before queue status to 'Accept' + the status of the relayed mail.

Reviewed-By: Mira Limbeck <m.limbeck@proxmox.com>
Tested-By: Mira Limbeck <m.limbeck@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agobump version to 6.2-3
Thomas Lamprecht [Fri, 24 Apr 2020 17:31:55 +0000 (19:31 +0200)]
bump version to 6.2-3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agopmg-system-report: Add mailproxy whitelist
Stoiko Ivanov [Fri, 24 Apr 2020 17:01:02 +0000 (19:01 +0200)]
pmg-system-report: Add mailproxy whitelist

The pmg-system-report should report which objects are whitelisted during
the SMTP-dialog

the 3 files output contain all the information
(see PMG::Config::rewrite_postfix_whitelist) and should be faster than
opening and loading the Database

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agopmg-system-report: add apt sources
Stoiko Ivanov [Fri, 24 Apr 2020 17:01:01 +0000 (19:01 +0200)]
pmg-system-report: add apt sources

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agoAdd pmg-log-tracker to package versions
Stoiko Ivanov [Fri, 24 Apr 2020 17:01:00 +0000 (19:01 +0200)]
Add pmg-log-tracker to package versions

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agobump version to 6.2-3
Thomas Lamprecht [Fri, 24 Apr 2020 16:57:17 +0000 (18:57 +0200)]
bump version to 6.2-3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapi tracker: split and order modules
Thomas Lamprecht [Fri, 24 Apr 2020 16:54:58 +0000 (18:54 +0200)]
api tracker: split and order modules

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoapi tracker: raise parameter exception if endtime was older than starttime
Thomas Lamprecht [Fri, 24 Apr 2020 16:54:40 +0000 (18:54 +0200)]
api tracker: raise parameter exception if endtime was older than starttime

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoAdd logrotate config for pmgproxy.log
Stoiko Ivanov [Fri, 24 Apr 2020 10:06:28 +0000 (12:06 +0200)]
Add logrotate config for pmgproxy.log

to keep the log from growing without end. Rotate monthly and keep 12 logs,
since the logs should not be too large (e.g. a productive instance, with
~20 users using the quarantine and some configuration changes amounts to
108M over 2.5 years)

the logrotate snippet is placed in /etc/logrotate.d/pmg-api by
dh_installlogrotate(1).

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agopmgsync.service: really order before postfix@-.service
Thomas Lamprecht [Fri, 24 Apr 2020 06:59:19 +0000 (08:59 +0200)]
pmgsync.service: really order before postfix@-.service

followup for commit 0c4cf3f2cfa2b40d4fb1ded7501989b884c73eae
which assumed that we can order on templated base units, which we
cannot (at least under the systemd version of buster). So depend on
the actual instance of the main postfix template.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agobump version to 6.2-2
Thomas Lamprecht [Thu, 23 Apr 2020 19:30:22 +0000 (21:30 +0200)]
bump version to 6.2-2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agopmgbanner: don't die if getting addr fails but running in container
Thomas Lamprecht [Thu, 23 Apr 2020 19:27:52 +0000 (21:27 +0200)]
pmgbanner: don't die if getting addr fails but running in container

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agopmgsync.service: order before postfix@.service
Stoiko Ivanov [Thu, 23 Apr 2020 08:21:16 +0000 (10:21 +0200)]
pmgsync.service: order before postfix@.service

pmgsync.service updates the database-schema (pmgdb init) and generates and
updates configuration files from the templates and reloads the respective
services.

When first booting up after installation, it adapts the config from what's
shipped in the default debian packages for the first time.

The postfix configuration is also rendered, including settings where a
restart is necessary (listening on the internal port (26)).

While the unit already starts before postfix.service, the postfix service
files are designed to start multiple instances of postfix via instantiation
(by default postfix@-.service is the single instance (and the service file
which actually starts postfix)).

Since both pmgsync and postfix@- have no ordering relation between them, they
are started in parallel, which leads to postfix starting with the stock config
upon first boot.

Tested by running the installer in debug mode and applying this patch in the
last debug shell.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agobump version to 6.2-1
Thomas Lamprecht [Tue, 21 Apr 2020 18:01:21 +0000 (20:01 +0200)]
bump version to 6.2-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agotest_greylist: remove use of system
Stoiko Ivanov [Tue, 21 Apr 2020 10:43:30 +0000 (12:43 +0200)]
test_greylist: remove use of system

the pmgpolicy daemon started for the tests needs to be stopped (by sending
a SIGTERM).
Instead of resorting to system, use perl's builtin kill.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agoenable policy if greylist6 is enabled
Stoiko Ivanov [Tue, 21 Apr 2020 10:43:29 +0000 (12:43 +0200)]
enable policy if greylist6 is enabled

the usepolicy variable is used by the templateing system to decide whether
pmgpolicy should be asked by postfix and should also be enabled if greylisting
is only active for ipv6.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agobump version to 6.1-9
Thomas Lamprecht [Mon, 20 Apr 2020 15:37:14 +0000 (17:37 +0200)]
bump version to 6.1-9

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agod/control: bump versioned dependency for pmg-docs
Thomas Lamprecht [Mon, 20 Apr 2020 15:33:11 +0000 (17:33 +0200)]
d/control: bump versioned dependency for pmg-docs

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agopmgpolicy: greylist_value: improve indentation of statements
Thomas Lamprecht [Mon, 20 Apr 2020 15:31:19 +0000 (17:31 +0200)]
pmgpolicy: greylist_value: improve indentation of statements

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoadd tests for greylisting ipv6
Stoiko Ivanov [Mon, 20 Apr 2020 11:22:43 +0000 (13:22 +0200)]
add tests for greylisting ipv6

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agogreylist: make netmasks configurable
Stoiko Ivanov [Mon, 20 Apr 2020 11:22:42 +0000 (13:22 +0200)]
greylist: make netmasks configurable

Instead of hardcoding the netmask used for comparing greylistentries to
the current ip (24 for ipv4 and 64 for ipv6) - make them configurable in
pmg.conf

This should help with some cloud providers who send the same mail with
different ips from a large network - which all get greylisted separately.
In the worst case the sending cloud drops the mail, after it got defered
too often.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agopmgpolicy: add IPv6 support
Stoiko Ivanov [Mon, 20 Apr 2020 11:22:41 +0000 (13:22 +0200)]
pmgpolicy: add IPv6 support

adds a new configuration flag in the 'mail' configuration section to
selectively enable greylisting for IPv6 and leaves its default as false to
maintain backward compatibility.

this change also enables SPF verification of IPv6 addresses if 'spf' is set
in the 'mail' section as a side-effect

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agouse postgres inet functions for greylist matching
Stoiko Ivanov [Mon, 20 Apr 2020 11:22:40 +0000 (13:22 +0200)]
use postgres inet functions for greylist matching

In preparation for adding support for a configurable greylist netmask [0]
and greylisting for ipv6 hosts the width of the IPNet column of the cgreylist
table needs to be extended to 49 [1].

Instead of comparing the first 3 octets of a ipv4 address we store the
complete network definition (i.e. for 192.0.2.127/24 - 192.0.2.0/24)
The last octet is not saved, but written as 0 (the information is not
needed, and not used currently). The generation of the network is done
with postgresql's functions for the inet and cidr datatypes [2,3].

The change of the column width instead of using the inet datatype prevents
errors while syncing or downgrading, although older nodes in a cluster (or
downgraded nodes) will not match new records.

When syncing from a node with old-style data the rows are inserted in the
new format.

Upon upgrade (`pmgdb init` in the postinst script) the data is changed to
the new format and matched for duplicates (in case one node in the cluster
got upgraded and it's contents were synced we should not edit the data
again). This process does cause the Cgreylist table to be scanned, which
takes time linear in the number of rows (e.g. with a test-dataset of
~ 1 million rows the upgrade is blocked for ~50 seconds on an
average testinstallation).
Changing only the column datatype does not lock the table and is almost
instantenous [4].

[0] defining from which neighbors a mail is accepted on the second attempt
[1] INET6_ADDRSTRLEN is 46 + 4 for the netmask ('/128) - \0
[2] https://www.postgresql.org/docs/11/datatype-net-types.html
[3] https://www.postgresql.org/docs/11/functions-net.html
[4] Notes section of https://www.postgresql.org/docs/11/sql-altertable.html

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agotest_greylist: exit pmgpolicy on failed test
Stoiko Ivanov [Mon, 20 Apr 2020 11:22:39 +0000 (13:22 +0200)]
test_greylist: exit pmgpolicy on failed test

kill the pmgpolicy instance started for the tests before dying.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agoadd new What Object 'Match Archive Filename'
Dominik Csapak [Thu, 16 Apr 2020 08:59:40 +0000 (10:59 +0200)]
add new What Object 'Match Archive Filename'

This behaves like the 'ArchiveFilter' to 'ContentTypeFilter', in that
it matches the filenames in archives, as well as the filenames of
attachments (via filename property in the mime header).

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-By: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agocollect filenames on unpack
Dominik Csapak [Thu, 16 Apr 2020 08:59:39 +0000 (10:59 +0200)]
collect filenames on unpack

so that we can later match on them

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Reviewed-By: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agobump version to 6.1-8
Thomas Lamprecht [Tue, 14 Apr 2020 08:11:12 +0000 (10:11 +0200)]
bump version to 6.1-8

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofreshclam.conf.in: remove ReceiveTimeout option
Stoiko Ivanov [Fri, 3 Apr 2020 17:58:00 +0000 (19:58 +0200)]
freshclam.conf.in: remove ReceiveTimeout option

mirroring the changed default both in upstream [0] and debian [1].
Additionally since the upgrade to clamav 0.102.2 we had a number of reports
from users (both in forum and in our enterprise support), which noticed
that the upgrades don't work due to running into the timeout
(might be related to the use of libcurl in freshclam in 0.102.0)

absence of 'ReceiveTimeout' in freshclam.conf (5)  defaults to 0 (no timeout).

[0] https://blog.clamav.net/2020/02/clamav-01022-security-patch-released.html
[1] apt changelog clamav-freshclam (for version 0.102.2+dfsg-1)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agofreshclam.conf.in: make ScriptedUpdates a variable
Stoiko Ivanov [Fri, 3 Apr 2020 17:57:59 +0000 (19:57 +0200)]
freshclam.conf.in: make ScriptedUpdates a variable

The 'ScriptedUpdate' setting in freshclam.conf (5) defines whether signature
updates should be fetched incrementally or whether the whole database should
be downloaded.

Since the upgrade of clamav to 0.102.1 led to some problems when downloading
the complete file [0], and some users who switched to incremental updates
later had problems with that, it seems the most comfortable and futureproof
solution is to have a simple way for users to selectively switch to
whichever mechanism works. AFAIR signature downloads of clamav also had
similar problems in previous versions.

Additionally the rendered boolean value was changed from 'yes' to 'true',
to be a bit more consistent with the other booleans in our template.

[0] https://blog.clamav.net/2020/02/clamav-01022-security-patch-released.html

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
4 years agod/control: add dependecy to ucf
Thomas Lamprecht [Tue, 14 Apr 2020 08:29:33 +0000 (10:29 +0200)]
d/control: add dependecy to ucf

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoUse ucf to handle template overrides
Stoiko Ivanov [Wed, 8 Apr 2020 17:40:51 +0000 (19:40 +0200)]
Use ucf to handle template overrides

ucf(1) is a utility to track changes in config files which are not shipped in
the debian package (but e.g. get generated through the postinst script)

While the template overriding mechanism of PMG does not directly write those
config files - users who override a config-file currently need to manually
compare the templates shipped in '/var/lib/pmg/templates' on every upgrade.

By selectively registering the existing template overrides with ucf, users get
asked once upon the next upgrade regarding their changes, and then will
always get prompted when the shipped default template changes.

The alternative of unconditionally registering all templates with ucf, as done
by dh_ucf (1), would copy all templates to /etc/pmg/templates, which I deemed
less elegant.

The postrm script's check for the existance of 'ucf' only should be sufficient,
since the other ucf executables used ('ucfq' and 'ucfr' are all shipped with
the 'ucf' package)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
[ dropped some extra lines left over from v1 ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agoSkip writing default ports in spamreports
Stoiko Ivanov [Thu, 2 Apr 2020 17:51:45 +0000 (19:51 +0200)]
Skip writing default ports in spamreports

There is no need to explicitly add ':443' to the authority part of a
https URL (or a ':80' to a http one)..

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-By: Dominik Csapak <d.csapak@proxmox.com>
Tested-By: Dominik Csapak <d.csapak@proxmox.com>
4 years agopmgqm: remove unused variable
Stoiko Ivanov [Thu, 2 Apr 2020 17:51:44 +0000 (19:51 +0200)]
pmgqm: remove unused variable

noticed while looking over the code - no other occurence of lastref in
the repository - so can safely be dropped.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-By: Dominik Csapak <d.csapak@proxmox.com>
Tested-By: Dominik Csapak <d.csapak@proxmox.com>
4 years agoLDAPCache: combine ldaps/starttls branches for connect
Dominik Csapak [Fri, 3 Apr 2020 12:29:57 +0000 (14:29 +0200)]
LDAPCache: combine ldaps/starttls branches for connect

they are similar except the setting of the verify options, so
combine them as

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agofix #2661: reintroduce LDAPCache->ldap_connect
Dominik Csapak [Fri, 3 Apr 2020 07:16:27 +0000 (09:16 +0200)]
fix #2661: reintroduce LDAPCache->ldap_connect

this was removed and integrated into ldap_connect_and_bind, but
we used it outside in LDAPSet.pm

so reintroduce it again

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
4 years agoAdd tls options for lmtp to main.cf template
Stoiko Ivanov [Wed, 18 Mar 2020 10:23:46 +0000 (11:23 +0100)]
Add tls options for lmtp to main.cf template

With the addition of supporting lmtp as downstream server, we should also
set the relevant configuration options if TLS support is enabled.
(postfix does not use the smtp settings for lmtp)

Tested by sending a few mails to a downstream lmtp-server (dovecot)
and comparing the traffic with tcpdump/wireshark

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-By: Dominik Csapak <d.csapak@proxmox.com>
4 years agoTLSPolicy: rename domain to destination
Stoiko Ivanov [Wed, 18 Mar 2020 10:23:45 +0000 (11:23 +0100)]
TLSPolicy: rename domain to destination

TLS policies are applied to destinations - for the outbound case these are
domains. However when setting a policy for a next-hop destination the
property name 'domain' is misleading, and should be renamed to 'destination'

In order to maintain backward compatibility in the API, we need to keep the
'domain' property in all return defintions, and also accept it (or the new
'destination') for the create call (all other calls get the destination from
the path)

the create call warns of the deprecation  if the domain property is provided
(which ends up in the journal), but still works.

We can then get rid of the 'domain' property with the release of PMG 7.0

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-By: Dominik Csapak <d.csapak@proxmox.com>
4 years agofix #1948: allow setting TLS policy for transports
Stoiko Ivanov [Wed, 18 Mar 2020 10:23:44 +0000 (11:23 +0100)]
fix #1948: allow setting TLS policy for transports

As described in postfix TLS Readme [0] the key of the tls_policy table need
not be a destination domain - it can also contain an entry from the transport
table.

By adding a new format, which matches the current format of 'transport-domain'
and additionally the possible values for a smtp/lmtp next-hop (see `man smtp`)
users can now also set a stricter tls policy for their configured downstream
servers (e.g. to enforce TLS, or to disable it, if the downstream server's
TLS implementation is broken).

Tested locally by sending mails to a downstream server with policy 'may' set
(STARTTLS is used), and 'none' (mail goes unecrypted) - verified with tcpdump.

If a next-hop is provided it needs to be literally the same entry as present
in the transport table (w/o the 'smtp:' or 'lmtp:inet:' prefix) - i.e.
it is significant if the entry is enclosed in brackets, or if the (defacto
optional) 'ipv6:' prefix is present in the transport entry.

[0] http://www.postfix.org/TLS_README.html#client_tls_policy

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-By: Dominik Csapak <d.csapak@proxmox.com>
4 years agoallow for optional 'ipv6:' prefix in transports
Stoiko Ivanov [Wed, 18 Mar 2020 10:23:43 +0000 (11:23 +0100)]
allow for optional 'ipv6:' prefix in transports

according to the smtp(8) and transport(5) manuals literal ipv6 addresses must
be written as '[ipv6:2001:db8::ff]', in accordance with rfc2821 [0].

Postfix does work irrespective of this prefix (as it has been working until
now), but we should allow for administrators to enter the addresses with the
prefix present.

[0] http://www.postfix.org/IPV6_README.html

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-By: Dominik Csapak <d.csapak@proxmox.com>
4 years agoconfig write_transport_map: code cleanup
Thomas Lamprecht [Tue, 24 Mar 2020 12:29:54 +0000 (13:29 +0100)]
config write_transport_map: code cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 years agofix rendering of ipv(4|6) literal lmtp transports
Stoiko Ivanov [Wed, 18 Mar 2020 10:23:42 +0000 (11:23 +0100)]
fix rendering of ipv(4|6) literal lmtp transports

While reviewing support for lmtp as transport one thing I forgot to
test was adding a lmtp-transport pointing to an IPv6 address.

Using the use_mx flag (which only makes sense for domain-names) to
provide the information of whether the next-hop/hostname should be
written out in square brackets or not is a bit confusing, and leads
to ambiguous results when providing ipv6 literal addresses:
> host: 2001:db8:25::25
> port: 24
> gets rendered as
> lmtp:inet:2001:db8:25::25:24

Which postfix oddly enough parses 'correctly'; postfix splits on ':'
and uses the last part as port. For ip4 literals and dns-names this
works for ip6 literals it only works if you provide a port so it
makes more sense to always write ip(4|6) literals in brackets

By introducing a explicit flag "$bracket_host" and reordering the
conditions lmtp and smtp entries get rendered correctly (see `man
smtp`).

Additionally fixes an indentation glitch in read_transport_map.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-By: Dominik Csapak <d.csapak@proxmox.com>
4 years agopmgspamreport: purge before sending reports
Stoiko Ivanov [Thu, 19 Mar 2020 13:02:27 +0000 (14:02 +0100)]
pmgspamreport: purge before sending reports

By cleaning the quarantine (database and files in spool directory), before
trying to send out mail we can prevent the file-system and database from
filling up because of an unrelated problem in sending out mails.

Originally discovered while analyzing why the quarantine spooldir on a
non-master node fills up, while being limted in size on the master-node:
the call to send out the reports errored out, because the node was not master.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-By: Dominik Csapak <d.csapak@proxmox.com>
4 years agopmgqm: warn if not running on master
Stoiko Ivanov [Thu, 19 Mar 2020 13:02:26 +0000 (14:02 +0100)]
pmgqm: warn if not running on master

pmgqm should exit when running on a non-master node (instead of e.g. sending
out spam report mails multiple times).
However this condition should not be an error - a warning printed should
suffice.

changing the die to warn + return in the calls for 'status' and 'send'
achieves this effect.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-By: Dominik Csapak <d.csapak@proxmox.com>
4 years agofix die statement in CLI/pmgqm
Stoiko Ivanov [Thu, 19 Mar 2020 13:02:25 +0000 (14:02 +0100)]
fix die statement in CLI/pmgqm

a '\' was forgotten before the final 'n' - making the error message also
print filename and linenumber.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-By: Dominik Csapak <d.csapak@proxmox.com>
4 years agobump version to 6.1-7
Thomas Lamprecht [Mon, 9 Mar 2020 17:21:51 +0000 (18:21 +0100)]
bump version to 6.1-7

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>