]> git.proxmox.com Git - pmg-api.git/log
pmg-api.git
3 years agoapi: cert order: print details for failed challenge if available
Thomas Lamprecht [Tue, 16 Mar 2021 17:02:18 +0000 (18:02 +0100)]
api: cert order: print details for failed challenge if available

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: certs: sort hash keys, just to be sure
Thomas Lamprecht [Tue, 16 Mar 2021 16:43:52 +0000 (17:43 +0100)]
api: certs: sort hash keys, just to be sure

knowing perl this is just nicer and should never be an issue as
without it they will be scrambled around on each run anyway.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: acme order: fix check for configured domains
Thomas Lamprecht [Tue, 16 Mar 2021 13:43:01 +0000 (14:43 +0100)]
api: acme order: fix check for configured domains

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoadd acme and cert subcommands to pmgconfig
Wolfgang Bumiller [Tue, 16 Mar 2021 10:24:15 +0000 (11:24 +0100)]
add acme and cert subcommands to pmgconfig

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agoadd node-config api entry points
Wolfgang Bumiller [Tue, 16 Mar 2021 10:24:14 +0000 (11:24 +0100)]
add node-config api entry points

adds /nodes/{nodename}/config to access node config

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agoadd certificates api endpoint
Wolfgang Bumiller [Tue, 16 Mar 2021 10:24:13 +0000 (11:24 +0100)]
add certificates api endpoint

This adds /nodes/{nodename}/certificates endpoint
containing:

  /custom/{type} - update smtp or api certificates manually
  /acme/{type} - update via acme

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agoapi: add ACME and ACMEPlugin module
Wolfgang Bumiller [Tue, 16 Mar 2021 10:24:12 +0000 (11:24 +0100)]
api: add ACME and ACMEPlugin module

This adds the cluster-wide acme account and plugin
configuration:

   * /config/acme
   |`+ account/
   | '- {name}
   |`- tos
   |`- directories
   |`- challenge-schema
    `+ plugins/
     '- {name}

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agocluster: sync acme/ and acme-plugins.conf
Wolfgang Bumiller [Tue, 16 Mar 2021 10:24:11 +0000 (11:24 +0100)]
cluster: sync acme/ and acme-plugins.conf

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agoadd PMG::NodeConfig module
Wolfgang Bumiller [Tue, 16 Mar 2021 10:24:10 +0000 (11:24 +0100)]
add PMG::NodeConfig module

for node-local configuration, currently only containing acme
domains/account choices

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agoadd PMG::CertHelpers module
Wolfgang Bumiller [Tue, 16 Mar 2021 10:24:09 +0000 (11:24 +0100)]
add PMG::CertHelpers module

Contains helpers to update certificates and provide locking
for certificates and when accessing acme accounts.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agodepend on libpmg-rs-perl and proxmox-acme
Wolfgang Bumiller [Tue, 16 Mar 2021 10:24:08 +0000 (11:24 +0100)]
depend on libpmg-rs-perl and proxmox-acme

This contains `PMG::RS::Acme` and `PMG::RS::CSR` which are
used for letsencrypt certificates.

Note that for the DNS plugins this still uses the perl code
from proxmox-acme for now.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 years agobump version to 6.3-6
Thomas Lamprecht [Fri, 5 Mar 2021 21:48:17 +0000 (22:48 +0100)]
bump version to 6.3-6

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobackup: add notify parameter to 'classic' backup
Stoiko Ivanov [Mon, 1 Mar 2021 14:12:20 +0000 (15:12 +0100)]
backup: add notify parameter to 'classic' backup

for feature-parity, and since we recently had a user in our community
forum, who does regular backups via cron+rsync (small site w/o
dedicated backup host). Those setups could also benefit from this.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobackup: fix #3146 add email notifications
Stoiko Ivanov [Mon, 1 Mar 2021 14:12:19 +0000 (15:12 +0100)]
backup: fix #3146 add email notifications

this patch addresses the missing email notification for scheduled
backup related tasks, which we have in all our other products, for our
mail product.

the parameter names are inspired by PBS' datastore config.

the default is 'never' in order to stay consistent with the current
code.

it uses the templateing system for the notification, because this
results in less code and a bit of added flexibility for the users.

the recipient address is currently hardcoded to the admin address in
pmg.conf as we also send the (admin) pmgreport there, and I did not
want to overengineer this (even more).

I shortly considered adding a $SIG{'__DIE__'} handler to the
run_backup API call but dropped the idea due to the warning in
perlvar(1).

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobackup: pbs: prevent race in concurrent backups
Stoiko Ivanov [Mon, 1 Mar 2021 14:12:18 +0000 (15:12 +0100)]
backup: pbs: prevent race in concurrent backups

If two pbs backup-creation calls happen simultaneously, it is possible
that the first removes the backup dir before the other is done
creating or sending it to the pbs remote.

This patch takes the same route as non-PBS backups - creating a unique
tempdir indexed by remote, PID and current time.

the tmp-dir now also needs to be removed in case of error while
backing up. (before the next invocation would have wiped it).

Noticed while having 2 schedules to different PBS instances with the
same interval and w/o random delay.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agodebian: add some OK lintian overrides
Thomas Lamprecht [Thu, 25 Feb 2021 09:40:18 +0000 (10:40 +0100)]
debian: add some OK lintian overrides

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agomakefile: fix missing trailing backslash and whitespace errors
Thomas Lamprecht [Thu, 25 Feb 2021 09:37:01 +0000 (10:37 +0100)]
makefile: fix missing trailing backslash and whitespace errors

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agofix #3154: backup: add 'include-statistics' to pbs
Stoiko Ivanov [Wed, 24 Feb 2021 18:30:59 +0000 (19:30 +0100)]
fix #3154: backup: add 'include-statistics' to pbs

This patch addresses part of #3154 - by adding the parameter
'include-statistics' for each remote in /etc/pmg/pbs/pbs.conf.

The other part (actively asking the user whether to include it) is GUI
only, since the API already has the paramter for backup calls.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobackup: fix die invocation
Stoiko Ivanov [Wed, 24 Feb 2021 18:30:58 +0000 (19:30 +0100)]
backup: fix die invocation

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: get_detail_statistics: rework param passing
Thomas Lamprecht [Wed, 10 Feb 2021 09:44:33 +0000 (10:44 +0100)]
api: get_detail_statistics: rework param passing

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoutils: allow '/' inside email address localpart
Stoiko Ivanov [Tue, 2 Feb 2021 13:03:16 +0000 (14:03 +0100)]
utils: allow '/' inside email address localpart

The change is motivated by a report in our community forum [0], where
a mail addressed to an address containing '/' in its local-part ended
up in the quarantine.
This is permitted by RFC5322 ([1]), and, probably more relevant,
happily accepted and processed by postfix.

Once inside the quarantine (or the statistic database) the records cannot
be displayed (due to the parameter verification failure).

This leaves the user unable to delete the quarantined mail.

Apart from the quarantine and statistics the 'pmg-email-address'
format is only used in the PBSConfig and the fetchmail configuration
(both of which are available only to the admin and can be still be
edited irrespective of the set localpart).

[0]
https://forum.proxmox.com/threads/pmg-error-parameter-verification-failed-400.82353/
[1] https://tools.ietf.org/html/rfc5322

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: statistics: add common method for details
Stoiko Ivanov [Tue, 2 Feb 2021 13:03:15 +0000 (14:03 +0100)]
api: statistics: add common method for details

This patch changes adds a new method, which yields the detail statistics
for a particular address.

Depending on the provided type argument it returns the same information as
the contact/sender/receiver detail calls.

This allows the statistics to be displayed for addresses containing
'/' in their localpart, once this is permitted in our api schema.

the idea follows a similar change for the user blocklists in
e8d909c11faeb5a4f84f39ef50e0eaf8ea65046d

By adding a new API method we can eventually drop the old methods with 7.0

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: statistics: refactor detail calls
Stoiko Ivanov [Thu, 21 Jan 2021 15:51:04 +0000 (16:51 +0100)]
api: statistics: refactor detail calls

the API calls returning the detailed statistics for a particular
email use much common code.
This patch introduces a sub to be used in all detail api calls.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agoapi: statistics: refactor return for detail calls
Stoiko Ivanov [Thu, 21 Jan 2021 15:51:03 +0000 (16:51 +0100)]
api: statistics: refactor return for detail calls

all api methods returning information for a particular sender,
receiver or contact have similar returns.

This commit pulls the common ones out into a sub like the common method
parameters in $default_properties.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agoapi: statistics: remove unneeded RESTEnvironment
Stoiko Ivanov [Thu, 21 Jan 2021 15:51:02 +0000 (16:51 +0100)]
api: statistics: remove unneeded RESTEnvironment

none of the API calls in PMG::API2::Statistics use the
RESTEnvironment - so remove the unused code.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agopmg-daily: run sa-update for local channels
Stoiko Ivanov [Tue, 19 Jan 2021 10:38:15 +0000 (11:38 +0100)]
pmg-daily: run sa-update for local channels

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agoapi: spamassassin: update local channels
Stoiko Ivanov [Tue, 19 Jan 2021 10:38:14 +0000 (11:38 +0100)]
api: spamassassin: update local channels

This patch adds a helper to loop over all present Spamassassin
channels files in /etc/mail/spamassassin/channel.d and:
* import the included gpg key into sa-update's keyring
* run sa-update for each channel separately

the verbose argument of the helper is for reusing the code in
pmg-daily (where we only want to log errors and be less informative)

the $SA_UPDATE variable hardcoding the path of /usr/bin/sa-update was
dropped in favor of using 'sa-update' without path since we do have a
sensible setting of PATH everywhere, and hardcoding paths is
problematic (especially in usr-merged systems).

The choice of invoking sa-update for each channel separately, instead
of providing multiple '--channel' and '--gpgkey' options to a single
command was made to prevent downloading signatures, which were signed
by a key not configured for the channel.

Importing gpg-keys is also done with individual sa-update invocations,
because sa-update only imports the last present --import argument
(wrong use of Getopt::Long)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agoapi: spamassassin: read local channels
Stoiko Ivanov [Tue, 19 Jan 2021 10:38:13 +0000 (11:38 +0100)]
api: spamassassin: read local channels

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agoadd helper for parsing SA channel.d files
Stoiko Ivanov [Tue, 19 Jan 2021 10:38:12 +0000 (11:38 +0100)]
add helper for parsing SA channel.d files

RHEL/CentOS based SpamAssassin implementations ship an update script,
which reads shell snippets from
/etc/mail/spamassassin/channel.d/*.conf and uses the information there
to update SA rules from the configured channels [0].

Noticed the existence of this directory/mechanism while reading the
announcement of the updatechannel for the KAM ruleset [1].

Parsing the file as text, instead of sourcing it in a shell, since I
hope that the channel files distributed don't rely on running commands
to get the ruleset url and gpg key.

The parser has some minimal tests added (inspired by the
convert_size_test.pl from pve-common)

[0] https://src.fedoraproject.org/rpms/spamassassin/blob/master/f/sa-update.cronscript
[1] https://mcgrail.com/template/kam.cf_channel

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agobuildsys: fix PERLLIB setting in tests/Makefile
Stoiko Ivanov [Tue, 19 Jan 2021 10:38:11 +0000 (11:38 +0100)]
buildsys: fix PERLLIB setting in tests/Makefile

Make variables don't need quoting - and with quotes the PERLLIB is
literally set to ".." instead of .. (only the latter works)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agobuildsys: fix check target in main Makefile
Stoiko Ivanov [Tue, 19 Jan 2021 10:38:10 +0000 (11:38 +0100)]
buildsys: fix check target in main Makefile

the tests are in src/ - the test target in the main Makefile still
tries to run them in the main directory.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agobuild-depends: remove dh-systemd
Dietmar Maurer [Thu, 19 Nov 2020 07:39:31 +0000 (08:39 +0100)]
build-depends: remove dh-systemd

no longer required

3 years agobump version to 6.3-5
Thomas Lamprecht [Wed, 25 Nov 2020 09:21:55 +0000 (10:21 +0100)]
bump version to 6.3-5

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoutils: ignore leading whitespace in sa description
Stoiko Ivanov [Thu, 19 Nov 2020 15:48:39 +0000 (16:48 +0100)]
utils: ignore leading whitespace in sa description

load_sa_descriptions is used to parse the 'describe' lines for SpamAssassin
rules for the SpamInfo in the quarantine view.

The regex for parsing is too strict, since config lines can contain
leading whitespace (e.g. due to indentation in an 'ifplugin' block)

checked Mail::SpamAssassin::Conf::Parser and they strip leading/trailing
whitespace as well.

tested on my local setup with a quarantined mail which hit KAM_DMARC_STATUS.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agoapi: termproxy: adapt to newer PVE/PBS interface
Thomas Lamprecht [Wed, 25 Nov 2020 09:17:23 +0000 (10:17 +0100)]
api: termproxy: adapt to newer PVE/PBS interface

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobump version to 6.3-4
Thomas Lamprecht [Wed, 18 Nov 2020 18:53:01 +0000 (19:53 +0100)]
bump version to 6.3-4

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoremove debug code
Thomas Lamprecht [Wed, 18 Nov 2020 18:52:18 +0000 (19:52 +0100)]
remove debug code

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobump version to 6.3-3
Thomas Lamprecht [Wed, 18 Nov 2020 18:47:09 +0000 (19:47 +0100)]
bump version to 6.3-3

...

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agofixup: use File::Path qw(rmtree)
Thomas Lamprecht [Wed, 18 Nov 2020 18:46:40 +0000 (19:46 +0100)]
fixup: use File::Path qw(rmtree)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agobump version to 6.3-2
Thomas Lamprecht [Wed, 18 Nov 2020 18:24:55 +0000 (19:24 +0100)]
bump version to 6.3-2

re use previous changelog, it's just a small bug fix after all

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoapi: pbs: remove state after backup
Stoiko Ivanov [Wed, 18 Nov 2020 17:59:35 +0000 (18:59 +0100)]
api: pbs: remove state after backup

else left-over files will continue to be included (e.g. statistics database)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agopbs: api: add statistic parameter to run_backup
Stoiko Ivanov [Wed, 18 Nov 2020 17:59:34 +0000 (18:59 +0100)]
pbs: api: add statistic parameter to run_backup

Without it the backup does not include the statistics database

Reported-by: Martin Maurer <martin@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
3 years agobump version to 6.3-1
Thomas Lamprecht [Wed, 18 Nov 2020 16:59:45 +0000 (17:59 +0100)]
bump version to 6.3-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agod/control: bump versioned dependency on pve-common
Thomas Lamprecht [Wed, 18 Nov 2020 17:00:34 +0000 (18:00 +0100)]
d/control: bump versioned dependency on pve-common

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
3 years agoquarantine: user self service: add some response delays
Thomas Lamprecht [Wed, 18 Nov 2020 16:45:00 +0000 (17:45 +0100)]
quarantine: user self service: add some response delays

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
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>