]> git.proxmox.com Git - pmg-api.git/log
pmg-api.git
18 months agobackup: restore: keep directories in /etc/pmg for inotify
Stoiko Ivanov [Wed, 30 Nov 2022 17:07:27 +0000 (18:07 +0100)]
backup: restore: keep directories in /etc/pmg for inotify

By wiping the subdirectories in /etc/pmg/, we lose the inotify
watchers upon restore (/etc/pmg itself and thus most configs are
currently handled by the keep_root flag to rmtree)
This can lead to inconsistencies after restoring for parts relying on
config in a subdirectory (e.g. /etc/pmg/pbs/pbs.conf).

This patch uses File::Find (included in perl-modules-$perlver) to keep
all directories an unlink everything else.
This was chosen for future robustness over keeping an explicit list of
directories to keep, in case a new directory gets added.

quickly tested with a fifo, chardev, and socket in the directory.

an alternative approach would be to simply reload pmgdaemon/pmgproxy
upon config-restore, but that feels more likely to miss some
(potentially future) service, expecting inotify to work.

Reported-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Tested-by: Fiona Ebner <f.ebner@proxmox.com>
18 months agobump version to 7.2-2
Thomas Lamprecht [Wed, 30 Nov 2022 09:46:08 +0000 (10:46 +0100)]
bump version to 7.2-2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
18 months agodebian: wrap-and-sort -tkn
Thomas Lamprecht [Wed, 30 Nov 2022 09:42:44 +0000 (10:42 +0100)]
debian: wrap-and-sort -tkn

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
18 months agod/control: depend on libproxmox-acme-plugins
Thomas Lamprecht [Wed, 30 Nov 2022 09:38:47 +0000 (10:38 +0100)]
d/control: depend on libproxmox-acme-plugins

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
18 months agoapi: tasks fix misnamed variable
Stoiko Ivanov [Tue, 29 Nov 2022 20:54:34 +0000 (21:54 +0100)]
api: tasks fix misnamed variable

issue introduced in previous commit:
6aea70bea4c2a21d763325a112bb9bc015b8dff6

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
18 months agoapi: tasks: keep early exit if rpcenv is not initialized
Stoiko Ivanov [Tue, 29 Nov 2022 15:52:58 +0000 (16:52 +0100)]
api: tasks: keep early exit if rpcenv is not initialized

while $rpcenv is only used in the end to set_result_attrib, the get()
call can cause an early exit if the RESTEnvironment is not
initialized. keep it that way (as with most/all API calls)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
18 months agoapi: tasks: avoid temporary variable.
Stoiko Ivanov [Tue, 29 Nov 2022 15:50:47 +0000 (16:50 +0100)]
api: tasks: avoid temporary variable.

$download is only used as condition to an if - no gain in setting it
to 0 if undef

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
18 months agobump version to 7.2-1
Thomas Lamprecht [Tue, 29 Nov 2022 14:48:30 +0000 (15:48 +0100)]
bump version to 7.2-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
18 months agouser accesslists: reword logging and hits for newer SA rule sets
Stoiko Ivanov [Mon, 28 Nov 2022 18:17:29 +0000 (19:17 +0100)]
user accesslists: reword logging and hits for newer SA rule sets

This commit adapts the sa-hits and the logging for the user
block/welcomelist to be consistent with the terms used in the
SpamAssassin 4.0 release, which tries to avoid some terms that might
be interpreted as racially charged.

This patch is a (small part) of the fix for #3755, which will be
addressed along with the upgrade to SpamAssassin 4.0 (to be
consistent with the (quite well thought-through) namings used by SA)

Keeping the USER_IN_BLACKLIST hit when loading the descriptions
catches mails put in quarantine before the patched version was
installed.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
 [ T: slight commit message edit ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
18 months agouser-bl: use custom description of USER_IN_BLACKLIST consistently
Stoiko Ivanov [Mon, 28 Nov 2022 18:17:28 +0000 (19:17 +0100)]
user-bl: use custom description of USER_IN_BLACKLIST consistently

The USER_IN_BLACKLIST spamassassin hit is created by the Spam What
object, if the sending e-mail is in the receivers blacklist.
This 'hit' is kept on the PMG only - it is not written to the SPAMINFO
macro - and only visible in the quarantine interface afaict.

The description shown in the quarantine interface, however is read
from SpamAssassin sources.

They have recently changed to include a 'DEPRECATED' prefix, since the
rules containing 'blacklist' and 'whitelist' have been renamed to
'blocklist' and 'welcomelist' for the upcoming 4.0 series of
spamassassin.

In any case we should keep our description consistent, thus the move
to a sub of its own for reusing in both locations.

The mechanism for welcomlisted/whitelisted mails does not create an
'internal' sa-rule (but simply drops the SA hits for analysis) - so no
symmetric change is needed.

Reported-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
18 months agomake tasklog downloadable in the PMG backend
Daniel Tschlatscher [Wed, 23 Nov 2022 14:52:08 +0000 (15:52 +0100)]
make tasklog downloadable in the PMG backend

The read_tasklog API call now stream the whole log file if the query
parameter 'download' is set to true.
This is done in preparation for the task log download button to be
added in the TaskViewer.

I saw an opportunity here to clear some redundant code for displaying
the tasklog and replaced it with a call to dump_logfile(), akin to how
this is handled in pve-manager.

Signed-off-by: Daniel Tschlatscher <d.tschlatscher@proxmox.com>
18 months agoqueue administration: try to decode utf8
Dominik Csapak [Fri, 25 Nov 2022 08:08:46 +0000 (09:08 +0100)]
queue administration: try to decode utf8

similar to how we do the rest of the mail parsing, decode with
decode_rfc1522 instead of mime_to_perl_string and use try_decode_utf8
otherwise

this is only used for the queue administration api for the user
to view

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
18 months agobump version to 7.1-11
Thomas Lamprecht [Thu, 24 Nov 2022 15:39:04 +0000 (16:39 +0100)]
bump version to 7.1-11

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
18 months agostatistics: refactor filter_text generation
Dominik Csapak [Thu, 24 Nov 2022 12:21:12 +0000 (13:21 +0100)]
statistics: refactor filter_text generation

it's basically always the same and having one place where we encode
the filter, makes it more legible

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
18 months agoldap: improve unicode support
Dominik Csapak [Thu, 24 Nov 2022 12:21:11 +0000 (13:21 +0100)]
ldap: improve unicode support

when we receive mails with SMTPUTF8 encoded sender/recipient,
we have to encode these values for our ldapcache to work,
otherwise pmg-smtp-filter fails with when trying to insert
perl strings.

on read from the cache we have to decode these values again so
that the webui can show them correctly

also encode/decode dn and group names, since according to rfc4514[0]
utf-8 should be ok here

0: https://www.ietf.org/rfc/rfc4514.txt

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
18 months agoutils: refactor rfc1522_to_html
Dominik Csapak [Thu, 24 Nov 2022 12:21:10 +0000 (13:21 +0100)]
utils: refactor rfc1522_to_html

by reusing the utf8 decoding logic of decode_rfc1522

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
18 months agoquarantine: fix adding non-ascii senders to wl/bl
Dominik Csapak [Thu, 24 Nov 2022 12:21:09 +0000 (13:21 +0100)]
quarantine: fix adding non-ascii senders to wl/bl

by trying to decode them since they maybe were sent with SMTPUTF8
also make 'try_decode_utf8' an export of Utils and use that

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
18 months agostatistics: handle utf8 data.
Stoiko Ivanov [Thu, 24 Nov 2022 12:21:08 +0000 (13:21 +0100)]
statistics: handle utf8 data.

for SMTPUTF8, we have do decode the sender/receiver address, since
they might contain UTF-8 byte sequences.

before inserting them in the database, encode them again

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
[ D: Added commit message ]
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
18 months agopmgqm: handle smtputf8 data
Stoiko Ivanov [Thu, 24 Nov 2022 12:21:07 +0000 (13:21 +0100)]
pmgqm: handle smtputf8 data

$data->{pmail} is both used in the template rendering ('Spam Report for
$pmail'), and as content for the To header, which need different
treatment. Thus introduce 'pmail_raw' additionally.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
18 months agoquarantine: handle utf8 data
Stoiko Ivanov [Thu, 24 Nov 2022 12:21:06 +0000 (13:21 +0100)]
quarantine: handle utf8 data

use try_decode_utf8 for sender/receiver of the smtp dialog and mail
headers since they're either ASCII (not SMTPUTF8) or UTF-8 (with SMTPUTF8)
encoded

change the mail regex for wl/bl to basic email/domain syntax without
the restriction of ascii only. (whitespace and backslashes are
forbidden, but they shouldn't normally occur in email addresses and
domains)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
[ D: Added Commmit message ]
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
18 months agopartially fix #2465: handle smtputf8 addresses in the rule-system
Stoiko Ivanov [Thu, 24 Nov 2022 12:21:05 +0000 (13:21 +0100)]
partially fix #2465: handle smtputf8 addresses in the rule-system

the envelope addresses are used in the rule-system for lookups and
statistics. When the mail is received with smtputf8 the addresses are
decoded (multi-byte perl-strings) and thus need encoding before using
them as parameter in a database query.

This patch encodes the addresses as utf-8 for the relevant queries
unconditionally, because envelope-senders should either be:
* (a subset of) ascii (no smtputf8) - which is invariant for utf-8
  encoding
* valid utf-8 (smtputf8)

The patch does not address the issues with multi-byte addresses in our
LDAP-implementation (hence the partial fix), but should still be an
improvment for many deployments

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
18 months agoruledb: encode e-mail addresses for syslog
Stoiko Ivanov [Thu, 24 Nov 2022 12:21:04 +0000 (13:21 +0100)]
ruledb: encode e-mail addresses for syslog

as done in 114655f4fdb07c789a361b2f397f5345eafd16c6 for Accept and
Block.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
18 months agofix #2541 ruledb: encode relevant values as utf-8 in database
Stoiko Ivanov [Thu, 24 Nov 2022 12:21:03 +0000 (13:21 +0100)]
fix #2541 ruledb: encode relevant values as utf-8 in database

This patch adds support for storing rule names, comments(info), and
most relevant values (e.g. the header content to match) in utf-8 in
the database.

backwards-compatibility should not be an issue:
* currently the database should not contain any utf-8 multibyte
  characters, as our tooling prevented this due to sending
  wide-characters, which causes an exception in DBI.
* any character > 127 and < 256 will be correctly interpreted when
  stored in a perl-string (this happens if the decode fails in
  try_decode_utf8), and will be correctly encoded when storing into
  the database.

the database is created with SQL_ASCII encoding - which behaves by
interpreting bytes <= 127 as ascii and those > 127 are not interpreted
(see [0], which just means that we have to explicitly en-/decode upon
storing/reading from there)

This patch currently omits most Who objects:
* for email/domain we'd still need to consider how to store them
  (puny-code for the domain part, or everything as UTF-8) and it would
  need changes to the API-types.
* the LDAP objects currently would not work too well, since our LDAPCache
  is not UTF-8 safe - and fixing warants its own patch-series
* WhoRegex should work and be able to handle many use-cases

The ContentType values should also contain only ascii characters per
RFC6838 [1] and RFC2045 [2].

[0] https://www.postgresql.org/docs/13/multibyte.html
[1] https://datatracker.ietf.org/doc/html/rfc6838#section-4.2
[2] https://datatracker.ietf.org/doc/html/rfc2045#section-5.1

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
18 months agoruledb: properly substitute prox_vars in headers
Stoiko Ivanov [Thu, 24 Nov 2022 12:21:02 +0000 (13:21 +0100)]
ruledb: properly substitute prox_vars in headers

by storing the variables as perl-string (not mime-encoded, and not
utf-8 encoded), and appropriately dealing with multi-line values to
input (folding the headers and encoding as mime).

This fixes another glitch not caught by
d3d6b5dff9e4447d16cb92e0fdf26f67d9384423

the Subject was always displayed with a '?' in the end (due to the
(quoted-printable encoded) \n added).

Additionally adapt the other callsites of PMG::Utils::subst_values
where applicable.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
18 months agoutils: return perl string from decode_rfc1522
Stoiko Ivanov [Thu, 24 Nov 2022 12:21:01 +0000 (13:21 +0100)]
utils: return perl string from decode_rfc1522

decode_rfc1522 is a more robust version of decode_mimewords (in
scalar context) - adapt it to return a perlstring, under the
assumption that data is utf-8 encoded (holds true for ascii and
smtputf8 mails)

the try_decode_utf8 helper sub backwards will be used extensively in
later patches and is inspired by commit
43f8112f0bb424f99057106d57d32276d7d422a6 in pve-storage:
We consider that the valid multibyte utf-8 characters do not really
yield sensible combinations of single-byte perl characters (starting
with a byte > 127 - e.g. "£") so if something decodes without error
from utf-8 it will in all likelyhood have been utf-8 to begin with

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
18 months agofix #3287: add pmail parameter to virus/attch. quarantine list
Dominik Csapak [Wed, 23 Nov 2022 14:52:21 +0000 (15:52 +0100)]
fix #3287: add pmail parameter to virus/attch. quarantine list

so that we can filter by the recipient email
for that we also have to add the quarantine type to the 'spamusers' api
call, or else we cannot list which recipients have mails in the
respective quarantine

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
19 months agobump version to 7.1-10
Thomas Lamprecht [Wed, 16 Nov 2022 18:55:06 +0000 (19:55 +0100)]
bump version to 7.1-10

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
19 months agoruledb: add deprecation warnings for unused actions
Stoiko Ivanov [Wed, 9 Nov 2022 18:27:25 +0000 (19:27 +0100)]
ruledb: add deprecation warnings for unused actions

* ReportSpam
* Attach
* Counter

are all still present since (at least) the release of PMG 5.0, but
were never exposed in the API/GUI.

All of them in their current form don't seem to fit well nowadays, or
their functionality was taken over by some other Action:
* Attach - the functionality is currently present in the Notify action
  (attach original mail)
* Counter - without a matching What object simply increasing a counter
  by one in the database serves no purpose
* ReportSpam - sending potentially sensitive mail automatically to the
  public SpamAssassin project does not seem to fit well nowadays

Instead of dropping them right away - this patch adds logging when
they are encountered while loading or when they are run, to keep
backwards-compatibility for users who have very long-running PMG
instances (not sure if the actions were ever used in the pre git-days
of PMG)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
19 months agoruledb: modfield: properly handle fields spanning multiple lines
Stoiko Ivanov [Tue, 15 Nov 2022 12:40:14 +0000 (13:40 +0100)]
ruledb: modfield: properly handle fields spanning multiple lines

this commit fixes aa3a005a5e7e3ad69ed35e9957fa514f73315c72

MIME::Words::encode_mimewords does not deal with multiline headers
(the warning about this being a 'quick and dirty' solution [0]
partially tells as much).

Instead - split the replacement value after variable substition on:
'\r?\n\s*' (to capture multi-line values like __SPAM_INFO__, but also
already folded headers, which are separated by '\r?\n\s+') and do the
substitution for each line seperately.

reported in our community forum:
https://forum.proxmox.com/threads/.118001/

[0] https://metacpan.org/pod/MIME::Words#PUBLIC-INTERFACE

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>

19 months agofix 4006: do not split from header on ', ' for spamreport mails
Stoiko Ivanov [Tue, 15 Nov 2022 09:28:20 +0000 (10:28 +0100)]
fix 4006: do not split from header on ', ' for spamreport mails

This commit follows 0f123331c73bbcb73303f1f07b5318a68c83ad64, which
did the same change for the API calls.

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>

19 months agobump version to 7.1-9
Thomas Lamprecht [Fri, 11 Nov 2022 12:48:27 +0000 (13:48 +0100)]
bump version to 7.1-9

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
19 months agoruledb: modfield: properly encode field after variable substitution
Stoiko Ivanov [Wed, 9 Nov 2022 18:27:24 +0000 (19:27 +0100)]
ruledb: modfield: properly encode field after variable substitution

this patch follows 6296d93fecb84e71603c15218f6ffc9732173491 in
properly encoding the added header-field, the way the subject is
encoded for a notification.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
19 months agosmtp-filter: fix trailing whitespace and code style conventions
Thomas Lamprecht [Mon, 7 Nov 2022 16:09:59 +0000 (17:09 +0100)]
smtp-filter: fix trailing whitespace and code style conventions

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
19 months agorule DB: Notify: fix trailing whitespace and some calling code style conventions
Thomas Lamprecht [Mon, 7 Nov 2022 16:09:29 +0000 (17:09 +0100)]
rule DB: Notify: fix trailing whitespace and some calling code style conventions

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
19 months agoDB Tools: fix trailing whitespace and some calling code style conventions
Thomas Lamprecht [Mon, 7 Nov 2022 16:08:36 +0000 (17:08 +0100)]
DB Tools: fix trailing whitespace and some calling code style conventions

could be done much more, but that's what I touched when checking out
other stuff, baby steps.. (no semantic change intended)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
19 months agoDB Tools: code/whitespace cleanup create_ruledb
Thomas Lamprecht [Mon, 7 Nov 2022 16:05:18 +0000 (17:05 +0100)]
DB Tools: code/whitespace cleanup create_ruledb

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
19 months agoDB Tools: code/whitespace cleanup open_ruledb
Thomas Lamprecht [Mon, 7 Nov 2022 16:05:07 +0000 (17:05 +0100)]
DB Tools: code/whitespace cleanup open_ruledb

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
19 months agoapi: quarantine: add 'content-disposition' field to listattachments
Dominik Csapak [Mon, 7 Nov 2022 14:36:18 +0000 (15:36 +0100)]
api: quarantine: add 'content-disposition' field to listattachments

this can be useful to filter for 'real' attachments vs standard mail
mime parts

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
19 months agoapi: quarantine: code reduction/cleanup in $get_and_check_mail
Thomas Lamprecht [Mon, 7 Nov 2022 15:56:43 +0000 (16:56 +0100)]
api: quarantine: code reduction/cleanup in $get_and_check_mail

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
19 months agoapi: quarantine: fix indentation
Thomas Lamprecht [Sat, 5 Nov 2022 15:22:53 +0000 (16:22 +0100)]
api: quarantine: fix indentation

was hard to read correctly otherwise

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
19 months agoapi/quarantine: allow 'listattachments' for quarantine users
Dominik Csapak [Fri, 4 Nov 2022 15:04:20 +0000 (16:04 +0100)]
api/quarantine: allow 'listattachments' for quarantine users

we use 'get_attachments' which uses 'get_and_check_mail'. that already
checks the correct permsissions (quser are only able to retriever their
own mails/attachments) so it's ok here to allow it

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
19 months agobump pve-common dependency to 7.2-4
Wolfgang Bumiller [Fri, 4 Nov 2022 13:27:49 +0000 (14:27 +0100)]
bump pve-common dependency to 7.2-4

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
19 months agoapi: pbs: don't use namespaced parameters
Fabian Ebner [Wed, 20 Jul 2022 10:59:47 +0000 (12:59 +0200)]
api: pbs: don't use namespaced parameters

Instead, rely on PBSClient to set namespace according to the initial
configuration.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
19 months agoapi: get group snapshots: take backup-id into account
Fabian Ebner [Wed, 20 Jul 2022 10:59:46 +0000 (12:59 +0200)]
api: get group snapshots: take backup-id into account

instead of assuming that the requested ID is the same as the node in
the API path. This endpoint is not currently used in the UI AFAICS.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
19 months agobump version to 7.1-8
Thomas Lamprecht [Fri, 28 Oct 2022 09:44:04 +0000 (11:44 +0200)]
bump version to 7.1-8

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
20 months agoRuleDB/Notify: properly en-/decode the mail subject
Dominik Csapak [Wed, 5 Oct 2022 07:49:41 +0000 (09:49 +0200)]
RuleDB/Notify: properly en-/decode the mail subject

we need to mime decode the subject after reading it, so that we get
the 'real' subject instead of the (possibly) mime encoded one (which
might be base64 or quoted-printable encoded). To get a proper subject in
the notification mail again, we have to encode it again before passing
it MIME::Entity->build

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Tested-By: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-By: Stoiko Ivanov <s.ivanov@proxmox.com>
20 months agofix #4269: rule cache: from match: cope with undefined IP
Thomas Lamprecht [Sat, 1 Oct 2022 09:56:40 +0000 (11:56 +0200)]
fix #4269: rule cache: from match: cope with undefined IP

No semantic change, just avoids an ugly warning. Can normally only
happen if a mail is send/inject directly from the PMG host.

fwiw, all the rule implementation that actually use $ip got an early
return 0 if $ip evaluates to false(y), one might actually consider
checking the counterpart too for false-y in this case, and return a
match if both are false (or maybe better, make the check a
definedness one); but as this is for an edge case we might just keep
it as is for now, worked ok for more than a decade..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
21 months agoapt: add proxmox-offline-mirror-helper package
Fabian Grünbichler [Thu, 15 Sep 2022 07:06:55 +0000 (09:06 +0200)]
apt: add proxmox-offline-mirror-helper package

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
21 months agobump version to 7.1-7
Thomas Lamprecht [Wed, 14 Sep 2022 11:18:08 +0000 (13:18 +0200)]
bump version to 7.1-7

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
21 months agod/postinst: fix indentation to four spaces
Thomas Lamprecht [Wed, 14 Sep 2022 08:53:15 +0000 (10:53 +0200)]
d/postinst: fix indentation to four spaces

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
21 months agopostinst: migrate/update APT auth config
Fabian Grünbichler [Wed, 14 Sep 2022 08:05:39 +0000 (10:05 +0200)]
postinst: migrate/update APT auth config

missed when switching over to Proxmox::RS::Subscription, which stores
the same info in the product-specific /etc/apt/auth.conf.d/pmg.conf .

the top-level file might contain non-PMG-managed entries, so only remove
entries matching "our" machine/

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
21 months agod/control: recommend proxmox-offline-mirror-helper
Fabian Grünbichler [Mon, 12 Sep 2022 08:52:26 +0000 (10:52 +0200)]
d/control: recommend proxmox-offline-mirror-helper

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
21 months agobump version to 7.1-6
Thomas Lamprecht [Thu, 8 Sep 2022 13:04:53 +0000 (15:04 +0200)]
bump version to 7.1-6

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
21 months agod/maintscript: drop extra newline at EOF
Thomas Lamprecht [Thu, 8 Sep 2022 13:04:16 +0000 (15:04 +0200)]
d/maintscript: drop extra newline at EOF

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
21 months agod/lintian-overrides: add further future-proofing
Stoiko Ivanov [Wed, 31 Aug 2022 17:06:30 +0000 (19:06 +0200)]
d/lintian-overrides: add further future-proofing

tested with lintian from bullseye and bullseye-backports

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
21 months agofix #3915: remove obsolete /etc/apt/apt.conf.d/75pmgconf
Stoiko Ivanov [Wed, 31 Aug 2022 17:06:29 +0000 (19:06 +0200)]
fix #3915: remove obsolete /etc/apt/apt.conf.d/75pmgconf

this was forgotten when introducing the more flexible kernel-keeping
logic with proxmox-boot-tool (in 6.4).

with this file present no pve-kernel gets autoremoved.

this patch uses d/maintscript for removing instead of using
debian/conffiles (deb-conffiles(5)) 'remove-on-upgrade'

sticking with d/maintscript was chosen, since else it depends on the
installed debhelper version if the removal is done at all (debhelper
from bullseye simply ignores remove-on-upgrade in d/conffiles)

Tested the following with a local version bump to 7.1-5 and a VM:
* regular unchanged /etc/apt/apt.conf.d/75pmgconf
* manually modified /etc/apt/apt.conf.d/75pmgconf
* manually removed /etc/apt/apt.conf.d/75pmgconf

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
21 months agosubscription: handle missing subscription info
Fabian Grünbichler [Wed, 7 Sep 2022 08:48:24 +0000 (10:48 +0200)]
subscription: handle missing subscription info

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
21 months agobump version to 7.1-5
Fabian Grünbichler [Tue, 6 Sep 2022 08:36:49 +0000 (10:36 +0200)]
bump version to 7.1-5

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
21 months agosubscription: switch to rust, add offline key support
Fabian Grünbichler [Thu, 21 Jul 2022 10:02:49 +0000 (12:02 +0200)]
subscription: switch to rust, add offline key support

mimicing changes in pve-manager

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
21 months agod/lintian-overrides: future proof
Thomas Lamprecht [Wed, 31 Aug 2022 14:22:34 +0000 (16:22 +0200)]
d/lintian-overrides: future proof

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
21 months agoapi quarantine: code refactoring/reduction
Thomas Lamprecht [Tue, 30 Aug 2022 13:15:11 +0000 (15:15 +0200)]
api quarantine: code refactoring/reduction

no semantic change intended

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
22 months agoadd 'allow-subdomains' to webauthn schema
Wolfgang Bumiller [Mon, 25 Jul 2022 12:18:31 +0000 (14:18 +0200)]
add 'allow-subdomains' to webauthn schema

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
23 months agobump version to 7.1-4
Thomas Lamprecht [Wed, 13 Jul 2022 09:17:53 +0000 (11:17 +0200)]
bump version to 7.1-4

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
23 months agopmg-daily: avoid short-circuting update of local channels
Stoiko Ivanov [Wed, 13 Jul 2022 09:09:35 +0000 (11:09 +0200)]
pmg-daily: avoid short-circuting update of local channels

by using ||= directly with the actual update call, it does not get
run, if `sa-update` already returned that a restart is needed.

reported in our community forum:
https://forum.proxmox.com/threads/.112112/

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
23 months agod/control: (build-) depend on libproxmox-rs-perl
Thomas Lamprecht [Wed, 13 Jul 2022 09:11:34 +0000 (11:11 +0200)]
d/control: (build-) depend on libproxmox-rs-perl

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
23 months agoapi: apt: switch to common Proxmox::RS::APT::Repositories package
Fabian Ebner [Fri, 8 Jul 2022 11:55:55 +0000 (13:55 +0200)]
api: apt: switch to common Proxmox::RS::APT::Repositories package

which is shared between PVE and PMG.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
23 months agoapi/Quarantine: load custom rules description
Dominik Csapak [Thu, 23 Jun 2022 07:20:01 +0000 (09:20 +0200)]
api/Quarantine: load custom rules description

so that they show up in the ui too

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agoconfig: add ips/nets uniquely to the template variables
Dominik Csapak [Tue, 31 May 2022 11:52:53 +0000 (13:52 +0200)]
config: add ips/nets uniquely to the template variables

otherwise a config with many entries such as:
domain1: ip1
domain2: ip1
domain3: ip1
etc.

unnecessarily adds 'ip1' multiple times to the 'mynetworks' variable

to keep the output sorted (so it's stable) move the sort to the 'join'

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agorulesystem: matchfield: match all headers not only the first
Stoiko Ivanov [Tue, 17 May 2022 10:19:50 +0000 (12:19 +0200)]
rulesystem: matchfield: match all headers not only the first

currently the match field uses $entity->head->get in scalar context,
which only returns the first matching header (see [0])

switch over to using get_all in list context and iterating over all
headers makes it possible to match subsequent headers.

while it is uncommon in general - the Received headers are usually not
restricted to one - reported in our community forum:
https://forum.proxmox.com/threads/.109629/

[0] https://metacpan.org/pod/MIME::Head#Getting-field-contents
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agobump version to 7.1-3
Thomas Lamprecht [Mon, 16 May 2022 10:20:48 +0000 (12:20 +0200)]
bump version to 7.1-3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/control: bump versioned pbs client dependencies
Thomas Lamprecht [Mon, 16 May 2022 10:19:35 +0000 (12:19 +0200)]
d/control: bump versioned pbs client dependencies

now that its bumped

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/control: bump versioned dependencies
Thomas Lamprecht [Sat, 14 May 2022 15:21:56 +0000 (17:21 +0200)]
d/control: bump versioned dependencies

for namespace support, but note that proxmox-backup-client 2.1.10-1
is still missing some changes only in git yet, i.e., making the CLI
prune command NS aware.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopbs backup: namespace support
Thomas Lamprecht [Sat, 14 May 2022 15:20:02 +0000 (17:20 +0200)]
pbs backup: namespace support

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoldap cache: restructure from add-if-valid to skip-if-invalid
Thomas Lamprecht [Wed, 6 Apr 2022 08:11:11 +0000 (10:11 +0200)]
ldap cache: restructure from add-if-valid to skip-if-invalid

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoldap cache: reduce comment bloat
Thomas Lamprecht [Wed, 6 Apr 2022 08:06:20 +0000 (10:06 +0200)]
ldap cache: reduce comment bloat

for additional reference, the archive.is saved and shortened link
referred to:

https://docs.microsoft.com/en-us/troubleshoot/azure/active-directory/proxyaddresses-attribute-populate
https://web.archive.org/web/20220406075231/https://docs.microsoft.com/en-us/troubleshoot/azure/active-directory/proxyaddresses-attribute-populate

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoldap cache: fixup trailing whitespace errors
Thomas Lamprecht [Wed, 6 Apr 2022 07:59:06 +0000 (09:59 +0200)]
ldap cache: fixup trailing whitespace errors

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agofix #3924: ldap: accept only valid email-address
Markus Frank [Wed, 30 Mar 2022 12:32:15 +0000 (14:32 +0200)]
fix #3924: ldap: accept only valid email-address

If a mail attribute contains special characters in ldap at the first
line, it will be set as primary email and results in a
"400 invalid format - value does not look like a valid email address"
Error-Statement in the webconsole. This mostly can happen if SIP
Addresses are in Active-Directory's proxyAddresses which begin with "SIP:".

To make the validation more strict I changed the api to use
pmg-email-address and added a regex which looks for protocolnames (sip:)
that could be in proxyAddresses but are not compatible and skips these
addresses.

Signed-off-by: Markus Frank <m.frank@proxmox.com>
2 years agoldap cache: removed superfluous uppercase SMTP from regex
Markus Frank [Wed, 30 Mar 2022 12:32:14 +0000 (14:32 +0200)]
ldap cache: removed superfluous uppercase SMTP from regex

removed "SMTP" because of lowercase function is called before.

Signed-off-by: Markus Frank <m.frank@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agodaily update timer: start already on 01:00 to avoid dst change issue
Thomas Lamprecht [Mon, 14 Mar 2022 08:08:09 +0000 (09:08 +0100)]
daily update timer: start already on 01:00 to avoid dst change issue

copied from pve-manager commit f703b171:

see https://github.com/systemd/systemd/issues/5595

Has also the side effect of spreading out the updates for our most
used product over a longer time span, reducing load on the CDN.

Note, this is now the same timer setting as PBS used from the start.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agofix duplicate 'x-ms-dos-executable' in default 'Dangerous Content' object
Dominik Csapak [Mon, 7 Mar 2022 10:07:33 +0000 (11:07 +0100)]
fix duplicate 'x-ms-dos-executable' in default 'Dangerous Content' object

it was in there twice. Fixes also the testdb.txt test
(there it can be seen that there is still an entry with the same filter)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agobump version to 7.1-2
Thomas Lamprecht [Thu, 3 Feb 2022 10:38:04 +0000 (11:38 +0100)]
bump version to 7.1-2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopostgres admin cmd: include system error in chdir/getcwd failures
Thomas Lamprecht [Thu, 3 Feb 2022 11:18:26 +0000 (12:18 +0100)]
postgres admin cmd: include system error in chdir/getcwd failures

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoutils: postgres_admin_cmd chdir to / before running
Stoiko Ivanov [Wed, 1 Dec 2021 18:08:26 +0000 (19:08 +0100)]
utils: postgres_admin_cmd chdir to / before running

postgres_admin_cmd switches user to the postgres user.

When running a cli command in `/root` (or any other directory not
accessible by the postgres user) this causes:

`could not change directory to "/root": Permission denied`

to be printed multiple times on stderr for those invocations, which is
confusing and has caused quite a few support requests.

modifying the postgres_admin_cmd invocation only should not cause any
future surprises

quickly tested with `pmgconfig sync`

Reported-by: Oguz Bektas <o.bektas@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agod/control: bump libpve-http-server-perl dependency
Thomas Lamprecht [Thu, 3 Feb 2022 10:31:12 +0000 (11:31 +0100)]
d/control: bump libpve-http-server-perl dependency

to ensure the new TLS cipher suite is actually enacted.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopass disable TLS 1.2/1.3 options
Fabian Grünbichler [Fri, 17 Dec 2021 13:00:15 +0000 (14:00 +0100)]
pass disable TLS 1.2/1.3 options

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agopass TLS 1.3 ciphersuites if set
Fabian Grünbichler [Fri, 17 Dec 2021 13:00:14 +0000 (14:00 +0100)]
pass TLS 1.3 ciphersuites if set

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2 years agopostifx: code cleanup
Thomas Lamprecht [Thu, 3 Feb 2022 10:04:32 +0000 (11:04 +0100)]
postifx: code cleanup

avoid a overly long line and a useless overwriting a scalar only to
extend another one with its value, really no biggie especially in the
context that's used, but its so easy to avoid that it still has some
merit.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoapi/postfix: add 'decode-headers' to postfix queue read
Dominik Csapak [Thu, 3 Feb 2022 08:29:23 +0000 (09:29 +0100)]
api/postfix: add 'decode-headers' to postfix queue read

often, the users want to show the *decoded* header, iow. they want
to see the readable subject,from,to, etc. not the quoted-printable
versions.

so add a new parameter that decodes the header lines as we read them
using MIME::WordDecoder's 'mime_to_perl_string'.

for backwards compatibility, this is not the default in the api

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agofix #3758: allow empty `to` in noqueue case
Mira Limbeck [Wed, 1 Dec 2021 15:41:58 +0000 (16:41 +0100)]
fix #3758: allow empty `to` in noqueue case

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
2 years agobump version to 7.1-1
Thomas Lamprecht [Sun, 28 Nov 2021 20:05:03 +0000 (21:05 +0100)]
bump version to 7.1-1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoapi: tfa config: add index
Thomas Lamprecht [Sun, 28 Nov 2021 20:25:40 +0000 (21:25 +0100)]
api: tfa config: add index

in perl its dynamic all the way, so we got no auto-index stuff like
rust..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoapi: config: add tfa also to index
Thomas Lamprecht [Sun, 28 Nov 2021 20:09:33 +0000 (21:09 +0100)]
api: config: add tfa also to index

so that it shows up in `pmgsh ls /config` and the like

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoapi: config: sort index and modernize
Thomas Lamprecht [Sun, 28 Nov 2021 20:08:59 +0000 (21:08 +0100)]
api: config: sort index and modernize

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoapi: tfa: explicitly restrict quarantine users from add/modify
Thomas Lamprecht [Sun, 28 Nov 2021 16:54:17 +0000 (17:54 +0100)]
api: tfa: explicitly restrict quarantine users from add/modify

We do not support that currently, so do not suggest we do via the api
schema, to make it more explicit.

The current goal is to allow an admin to better secure access to the
box all mail is flowing through.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoapi: tfa: fix trailing whitespace
Thomas Lamprecht [Sun, 28 Nov 2021 16:53:22 +0000 (17:53 +0100)]
api: tfa: fix trailing whitespace

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agotfa: improve indentation style
Thomas Lamprecht [Sun, 28 Nov 2021 16:37:54 +0000 (17:37 +0100)]
tfa: improve indentation style

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/control: bump pmg-rs dependency versions
Thomas Lamprecht [Sun, 28 Nov 2021 16:34:26 +0000 (17:34 +0100)]
d/control: bump pmg-rs dependency versions

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoprovide qrcode.min.js from libjs-qrcodejs
Wolfgang Bumiller [Fri, 26 Nov 2021 13:55:10 +0000 (14:55 +0100)]
provide qrcode.min.js from libjs-qrcodejs

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agoimplement tfa authentication
Wolfgang Bumiller [Fri, 26 Nov 2021 13:55:09 +0000 (14:55 +0100)]
implement tfa authentication

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agoadd tfa config api
Wolfgang Bumiller [Fri, 26 Nov 2021 13:55:08 +0000 (14:55 +0100)]
add tfa config api

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>