]> git.proxmox.com Git - pmg-api.git/log
pmg-api.git
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>
22 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>
22 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>
22 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>
22 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>
23 months 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>
2 years agoadd TFA API
Wolfgang Bumiller [Fri, 26 Nov 2021 13:55:07 +0000 (14:55 +0100)]
add TFA API

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

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agoadd tfa.json and its lock methods
Wolfgang Bumiller [Fri, 26 Nov 2021 13:55:05 +0000 (14:55 +0100)]
add tfa.json and its lock methods

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2 years agofix #2795: add support for DSN
Stoiko Ivanov [Thu, 25 Nov 2021 17:48:13 +0000 (18:48 +0100)]
fix #2795: add support for DSN

store the esmtp parameters for the MAIL and RCPT command needed to
support Delivery status notifications (DSN - RFC 3464 [0]) and pass
them to the outbound postfix instance (port 10025) used for sending
the mail further (see also [1]).

Postfix does syntax-checking before passing the mail to the proxy
also in before-queue filtering mode.

Since the handling is done by postfix we don't need to generate any
DSN in the regular case.
For mail put into quarantine I decided to skip sending a delivery
notification (on the expectation, that few people are using quarantine
outbound, and that I would not consider a mail put in quarantine as
delivered successfully)

We only store a whitelist of parameters, instead of passing all,
because some parameters might not be valid anymore after processing
(e.g. SIZE)

The DSN EHLO keyword was added for the after-queue filtering case -
else the inbound postfix is the system that sends out the
notification.

tested with various combinations of the -V, -N and -R parameters to
sendmail (e.g.):
```
/usr/sbin/sendmail -N success,delay,failure \
-V '<xxxxxxxx@test.proxmox.com>'\
-R hdrs test@test.domain.example
```
tested the following scenarios in before and after-queue filter mode:
* successful delivery
* successful delivery with set DSN
* failed delivery (recipient rejects with 544)
* failed delivery with DSN
* delivering a mail with empty envelope sender (bounce)

some tests with invalid combinations were also done with netcat.

[0] https://tools.ietf.org/html/rfc3464
[1] http://www.postfix.org/DSN_README.html

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>
2 years agopartially fix #2795: allow for '>' in smtp parameters
Stoiko Ivanov [Thu, 25 Nov 2021 17:44:11 +0000 (18:44 +0100)]
partially fix #2795: allow for '>' in smtp parameters

The regular expressions parsing the MAIL and RCPT commands do not
cover the case where a esmtp parameter may contain angle brackets
(e.g. the ENVID parameter for the delivery status notification
extension - RFC3464 [0]).

following section 4.1.2 of RFC5321 [1] the regex is changed to:
* consider everything up to the first '>' the mailbox
* consider everything afterwards (if it starts with a ' ') as
  parameters
* since the parameter group might not match (in case no parameters are
  set - e.g. after-queue filtering) - default to '' if it's not
  defined

This is fairly robusts, only not parsing correctly if the local part
contains '>' (as quoted text) - but this did not work before anyways
(and causes problems in other places as well).

tested with:
```
cat test.eml | /usr/sbin/sendmail -N success,delay,failure \
-V '<someid@somehost>' \
-f '"local>part"@test.example' \
discard@test.example
```

[0] https://tools.ietf.org/html/rfc3464
[1] https://tools.ietf.org/html/rfc5321#section-4.1.2

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>
2 years agohtml mail: scrubber: fix passing code ref
Thomas Lamprecht [Fri, 26 Nov 2021 08:57:26 +0000 (09:57 +0100)]
html mail: scrubber: fix passing code ref

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agohtml mail: dump: fix indentation and clean up a bit
Thomas Lamprecht [Thu, 25 Nov 2021 17:17:10 +0000 (18:17 +0100)]
html mail: dump: fix indentation and clean up a bit

move in the variable declaration, keep $depth even if it's unused
currently, at least its set correctly now..

drop the `.. unless expr` usage, against the style guide

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agohtml mail: remove urls: early return on undef
Thomas Lamprecht [Thu, 25 Nov 2021 17:09:59 +0000 (18:09 +0100)]
html mail: remove urls: early return on undef

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agofix #3734: scrub 'url' from style tags/attributes
Dominik Csapak [Thu, 25 Nov 2021 14:14:41 +0000 (15:14 +0100)]
fix #3734: scrub 'url' from style tags/attributes

if 'view images' for the quarantine is disabled, it is expected that
*no* images will be loaded. but in addition to img (src/href/etc.)
also css can load external images via the 'url' directive

since html scrubber does not parse/iterate over css, we simply remove
the url+protocol part of those tags/attributes. this technically leaves behind
invalid css, but the browsers should cope with that.
(we cannot 'cleanly' remove without much more effort because of quoting)

also we have to scrub the style tags in 'dump_html' since HTML::Scrubber
does not have a way to modify the *content* of a tag, only the
attributes...

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agorulesystem: limit linelength of disclaimer to 998 bytes
Stoiko Ivanov [Wed, 24 Nov 2021 21:00:48 +0000 (22:00 +0100)]
rulesystem: limit linelength of disclaimer to 998 bytes

As described in
http://www.postfix.org/postconf.5.html#smtp_line_length_limit

postfix splits lines which are longer by inserting <cr><lf><space> to
adhere with RFC 5322 (section 2.1.1):
https://datatracker.ietf.org/doc/html/rfc5322#section-2.1.1
(or actually section 4.5.3.1.6. where characters are translated to
octets)

If a longer line is part of the disclaimer pmg-smtp-filter adds it
without this modification, which breaks DKIM signatures (since the
body is modified by postfix after the body hash is computed)

regular-expression matching is used instead of length(), because the
limit is on line-length (and a disclaimer can contain multiple lines)

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

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agobump version to 7.0-9
Thomas Lamprecht [Wed, 24 Nov 2021 18:13:41 +0000 (19:13 +0100)]
bump version to 7.0-9

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoapi-daemons: set oom-policy to continue
Stoiko Ivanov [Wed, 24 Nov 2021 16:04:09 +0000 (17:04 +0100)]
api-daemons: set oom-policy to continue

OOMPolicy [0] defaults to stop - resulting in the complete daemon to
be killed.
Our Daemon class does start new workers automatically if it detects
that fewer than configured are running.

[0] systemd.service(5)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agoapi-daemons: restart on-failure
Stoiko Ivanov [Wed, 24 Nov 2021 16:04:08 +0000 (17:04 +0100)]
api-daemons: restart on-failure

user experience benefits when we restart pmgdaemon and pmgproxy if
they get terminated abnormally (now observed with oom-kills).

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agod/control: bump http-server and mini-journalreader dependencies
Thomas Lamprecht [Wed, 24 Nov 2021 17:47:19 +0000 (18:47 +0100)]
d/control: bump http-server and mini-journalreader dependencies

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoapi: journal: stream the journal data to the client
Dominik Csapak [Wed, 24 Nov 2021 14:48:52 +0000 (15:48 +0100)]
api: journal: stream the journal data to the client

instead of accumulating the whole output of 'mini-journalreader' in
the api call (this can be quite big), use the download mechanic of the
http-server to stream the output to the client.

we lose some error handling possibilities, but we do not have
to allocate anything here, and since perl does not free memory after
allocating[0] this is our desired behaviour.

to keep api compatiblitiy, we need to give the journalreader the '-j'
flag to let it output json.

also tell the http server that the encoding is gzip and pipe
the output through it.

0: https://perldoc.perl.org/perlfaq3#How-can-I-free-an-array-or-hash-so-my-program-shrinks?

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agofix #3712: strip trailing dot from searchdomain
Stoiko Ivanov [Mon, 22 Nov 2021 19:49:39 +0000 (20:49 +0100)]
fix #3712: strip trailing dot from searchdomain

having a trailing '.' in the search domain is perfectly legal syntax
(for domain names in general). postfix refuses to use a fqdn with
trailing dot as hostname[0].

The restriction might be due to section 2.3.5 (Domain Names) of
RFC5321 (a top-level domain is a single string without any dots) [1]

[0] src/util/valid_hostname.c in the postfix source
[1] https://datatracker.ietf.org/doc/html/rfc5321#section-2.3.5

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agoapi: ldap config: sync with the complete config
Dominik Csapak [Wed, 27 Oct 2021 15:02:28 +0000 (17:02 +0200)]
api: ldap config: sync with the complete config

use the complete config, not only the one from the parameters.
This is necessary to use the saved bindpw when it's not sent
via the api.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agofix #2071: RuleDB: ignore duplicate entries for Who objects
Dominik Csapak [Fri, 24 Sep 2021 11:17:46 +0000 (13:17 +0200)]
fix #2071: RuleDB: ignore duplicate entries for Who objects

if we detect an entry with a value that is identical, return that id
instead of adding it again to the db.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2 years agod/control: add missing builddep on libpod-parser-perl
Stoiko Ivanov [Fri, 24 Sep 2021 10:09:31 +0000 (12:09 +0200)]
d/control: add missing builddep on libpod-parser-perl

Reported-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agobump version to 7.0-8
Thomas Lamprecht [Mon, 20 Sep 2021 06:42:59 +0000 (08:42 +0200)]
bump version to 7.0-8

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoservices: update description
Thomas Lamprecht [Mon, 20 Sep 2021 06:54:58 +0000 (08:54 +0200)]
services: update description

and sort the ordering constrains alphabetically

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoservices: add drop weird binary-exists condition
Thomas Lamprecht [Mon, 20 Sep 2021 06:52:28 +0000 (08:52 +0200)]
services: add drop weird binary-exists condition

The package that ships the service is the same as the one that ships
the binaries, so quite the useless check and a remainder from initial
switch from sysv to systemd in ~2015 (when it was not 100% clear
what/how systemd features should be integrated or units encoded).

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoservices: add After=network-online.target and update
Thomas Lamprecht [Mon, 20 Sep 2021 06:50:46 +0000 (08:50 +0200)]
services: add After=network-online.target and update

while we indirectly got that by the remote-fs ordering constraint its
better to encode it explicitly, especially as the remote-fs does not
make much sense and may get removed soon

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoconfig: template vars: cope with an undefined local IP
Thomas Lamprecht [Mon, 20 Sep 2021 06:41:32 +0000 (08:41 +0200)]
config: template vars: cope with an undefined local IP

won't happen normally but it can happen now, as we do not plainly die
anymore if gai fails but do some more flexible fallback.

it's considered bad to generally die from such things, i.e., like
panic in rust, we want to just avoid that normally.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoconfig: fix "var declared in conditional statement"
Thomas Lamprecht [Mon, 20 Sep 2021 06:38:08 +0000 (08:38 +0200)]
config: fix "var declared in conditional statement"

This is actually buggy and can lead to unexpected issues as in the
case the check on the declared variable did not evaluates to true it
gets (or better keeps) the value from the previous time when it was
actually assigned. Found with perlcritic, which reports the highest
severity for this mistake.

Refactor out the "is current file equal to generated config" check
which fixes three instances of that on its own and reduces code bloat
a bit.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopmgbanner: check return value from open
Thomas Lamprecht [Mon, 20 Sep 2021 05:46:04 +0000 (07:46 +0200)]
pmgbanner: check return value from open

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopmgbanner: fix perlcritic high-severity warnings
Thomas Lamprecht [Mon, 20 Sep 2021 05:42:59 +0000 (07:42 +0200)]
pmgbanner: fix perlcritic high-severity warnings

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopmgbanner: retry getting local ip for a bit
Thomas Lamprecht [Sat, 18 Sep 2021 13:17:21 +0000 (15:17 +0200)]
pmgbanner: retry getting local ip for a bit

basically only useful for setups using (hopefully static) DHCP for
the PMG host, but we can have that in evaluation, especially when
using CTs or installing on top of a plain Debian.

This was favored over adding an After=network-online.target order
constraint for the pmgbanner service, as it'd delay the console-getty
service needlessly in most setups

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopmgbanner: use safer get-ip helper, drop hacks for old one
Thomas Lamprecht [Sat, 18 Sep 2021 13:15:19 +0000 (15:15 +0200)]
pmgbanner: use safer get-ip helper, drop hacks for old one

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoprefer more flexible get_local_ip where possible
Thomas Lamprecht [Sat, 18 Sep 2021 13:06:57 +0000 (15:06 +0200)]
prefer more flexible get_local_ip where possible

get_ip_from_hostname does only check getaddrinfo, which can fail for
the local node in some environments, especially container ones.

Rather, use the new get_local_ip helper, that still tries to do a gai
call first, but falls back to configured (/etc/network/interfaces)
IPs and also on the currently, from kernel POV active ones.

A big bonus is that the new helper is much less likely to die, so it
won't break service startup in restricted (CTs) envs after initial
setup as often anymore.

While yes, if no addr is resolved, configured or active the PMG won't
work, but killing pmg proxy/daemon won't better that situation either
;)

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoapi: apt: use actual pmg-style permission for endpoint schema
Oguz Bektas [Thu, 2 Sep 2021 08:47:12 +0000 (10:47 +0200)]
api: apt: use actual pmg-style permission for endpoint schema

it wrongly uses the permission model from PVE, which caused the
endpoints to be root-only as a side effect, since PMG API doesn't
recognize the PVE-specific permissions.

fix those to allow PMG users with administrator role to add/delete
repositories, and auditor role to view the repositories.

reported in a forum thread [0]

[0]:
https://forum.proxmox.com/threads/no-apt-repo-information-for-non-root-on-the-web-gui.95217/

Reviewed-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
2 years agoapi: apt: repos: avoid creating implicit default for enabled
Fabian Ebner [Fri, 16 Jul 2021 13:42:36 +0000 (15:42 +0200)]
api: apt: repos: avoid creating implicit default for enabled

The parameter is optional, so a check for definedness is needed before
converting to int.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agobump version to 7.0-7
Thomas Lamprecht [Mon, 19 Jul 2021 07:11:22 +0000 (09:11 +0200)]
bump version to 7.0-7

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoapi: implement live network reload with ifupdown2
Thomas Lamprecht [Fri, 16 Jul 2021 10:27:01 +0000 (12:27 +0200)]
api: implement live network reload with ifupdown2

Like most of the other call here, copied over from PVE, with the SDN
stuff dropped and some task-log feedback if we actually moved a
pending change in. Also adding error handling for the rename, both
should be added to PVE too.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoapi: apt versions: report more packages
Thomas Lamprecht [Thu, 15 Jul 2021 12:25:10 +0000 (14:25 +0200)]
api: apt versions: report more packages

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agopmgversion: do not show packages with only residual config as error
Thomas Lamprecht [Thu, 15 Jul 2021 12:24:11 +0000 (14:24 +0200)]
pmgversion: do not show packages with only residual config as error

copied over from pve-manager

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agobump version to 7.0-6
Thomas Lamprecht [Wed, 14 Jul 2021 15:54:07 +0000 (17:54 +0200)]
bump version to 7.0-6

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agovalid_ssh_pubkey_regex: code style: add missing whitespace
Thomas Lamprecht [Wed, 14 Jul 2021 15:50:55 +0000 (17:50 +0200)]
valid_ssh_pubkey_regex: code style: add missing whitespace

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agofollowup: s/valid_ssh_pubkey/valid_ssh_pubkey_regex/
Thomas Lamprecht [Wed, 14 Jul 2021 15:49:41 +0000 (17:49 +0200)]
followup: s/valid_ssh_pubkey/valid_ssh_pubkey_regex/

else the function is a bit vague

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agocluster: add '=' to ssh pubkey pattern
Stoiko Ivanov [Wed, 14 Jul 2021 14:44:30 +0000 (16:44 +0200)]
cluster: add '=' to ssh pubkey pattern

ssh public keys are base64 encoded, thus can potentially contain =.
until now the RSA keys generated by Debian were 2048 bits long and did
not need padding

with bullseye (openssh (1:8.0p1-1)) the RSA keysize got increased to
3072 bits, and now does contain a =

noticed while trying to join a PMG container from a bullseye template
to my existing cluster (the error happens on the new node).

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agocluster: refactor ssh pubkey verification
Stoiko Ivanov [Wed, 14 Jul 2021 14:44:29 +0000 (16:44 +0200)]
cluster: refactor ssh pubkey verification

to only have the regex in one place.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agobump version to 7.0-5
Thomas Lamprecht [Wed, 14 Jul 2021 09:58:53 +0000 (11:58 +0200)]
bump version to 7.0-5

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agouse bullseye for enterprise repository
Thomas Lamprecht [Wed, 14 Jul 2021 09:58:21 +0000 (11:58 +0200)]
use bullseye for enterprise repository

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agobump version to 7.0-4
Thomas Lamprecht [Wed, 14 Jul 2021 08:32:38 +0000 (10:32 +0200)]
bump version to 7.0-4

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/control: recommend ifupdown2 and suggest zfsutils-linux
Thomas Lamprecht [Wed, 14 Jul 2021 08:02:15 +0000 (10:02 +0200)]
d/control: recommend ifupdown2 and suggest zfsutils-linux

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agobump version to 7.0-3
Thomas Lamprecht [Tue, 13 Jul 2021 16:42:14 +0000 (18:42 +0200)]
bump version to 7.0-3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoutils: fix typo in error message
Thomas Lamprecht [Tue, 13 Jul 2021 16:40:50 +0000 (18:40 +0200)]
utils: fix typo in error message

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoapi: services: track chrony
Thomas Lamprecht [Tue, 13 Jul 2021 15:15:42 +0000 (17:15 +0200)]
api: services: track chrony

2 years agoapi: services: check if unit is even found
Thomas Lamprecht [Tue, 13 Jul 2021 15:15:32 +0000 (17:15 +0200)]
api: services: check if unit is even found

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoapi: services: code cleanup
Thomas Lamprecht [Tue, 13 Jul 2021 15:14:52 +0000 (17:14 +0200)]
api: services: code cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoapi: services: return active- and unit-state infos
Thomas Lamprecht [Tue, 13 Jul 2021 15:06:43 +0000 (17:06 +0200)]
api: services: return active- and unit-state infos

same is PVE nowadays

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoutils: service command: improve refusal to stop error message
Thomas Lamprecht [Tue, 13 Jul 2021 15:05:09 +0000 (17:05 +0200)]
utils: service command: improve refusal to stop error message

As "ERROR" is probably the worst reason to tell an user ;)

use the same as PVE has

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agod/control: bump versioned dependency for libpmg-rs-perl
Thomas Lamprecht [Tue, 13 Jul 2021 12:16:19 +0000 (14:16 +0200)]
d/control: bump versioned dependency for libpmg-rs-perl

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agoapi: apt: add calls for repositories
Fabian Ebner [Tue, 13 Jul 2021 08:04:12 +0000 (10:04 +0200)]
api: apt: add calls for repositories

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2 years agoapi: termproxy: sort hash-keys when setting enum
Thomas Lamprecht [Tue, 13 Jul 2021 08:36:45 +0000 (10:36 +0200)]
api: termproxy: sort hash-keys when setting enum

else the api-viewer's dumper may get a false-positive change every
time we update the schema there

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 years agonodeconfig: parse acme config before writing
Stoiko Ivanov [Thu, 15 Apr 2021 19:46:20 +0000 (21:46 +0200)]
nodeconfig: parse acme config before writing

we use `get_acme_conf` as higher level sanity checker (e.g. to ensure
that wildcard certificates have a configured DNS plugin)

(adapted from pve-manger (where this is done in the corresponding API
call)

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2 years agoacme: check plugin for wildcard certificates
Stoiko Ivanov [Thu, 15 Apr 2021 19:46:19 +0000 (21:46 +0200)]
acme: check plugin for wildcard certificates

Let's Encrypt currently only issues wildcard certificates if the
domain ownership is validated via a dns-01 type plugin.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>