Commit Graph

1496 Commits

Author SHA1 Message Date
Stoiko Ivanov
b0f596edd4 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>
2021-11-24 18:59:46 +01:00
Stoiko Ivanov
da29d81d3f 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>
2021-11-24 18:59:46 +01:00
Thomas Lamprecht
22c1452e30 d/control: bump http-server and mini-journalreader dependencies
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-11-24 18:47:19 +01:00
Dominik Csapak
c165cff34d 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>
2021-11-24 18:46:44 +01:00
Stoiko Ivanov
4091d7d539 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>
2021-11-23 12:50:31 +01:00
Dominik Csapak
6804695f02 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>
2021-10-28 22:12:51 +02:00
Dominik Csapak
736b986fa0 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>
2021-10-06 18:22:08 +02:00
Stoiko Ivanov
b6398262ef 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>
2021-09-24 12:09:31 +02:00
Thomas Lamprecht
36f2537c82 bump version to 7.0-8
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-09-20 08:55:24 +02:00
Thomas Lamprecht
466c71c4b7 services: update description
and sort the ordering constrains alphabetically

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-09-20 08:55:24 +02:00
Thomas Lamprecht
a0e286f0e3 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>
2021-09-20 08:55:24 +02:00
Thomas Lamprecht
81faf89e05 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>
2021-09-20 08:55:24 +02:00
Thomas Lamprecht
c48fefb046 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>
2021-09-20 08:41:34 +02:00
Thomas Lamprecht
99e7a8b1fc 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>
2021-09-20 08:40:38 +02:00
Thomas Lamprecht
32f704e09e pmgbanner: check return value from open
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-09-20 07:46:04 +02:00
Thomas Lamprecht
f95eb381da pmgbanner: fix perlcritic high-severity warnings
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-09-20 07:42:59 +02:00
Thomas Lamprecht
72766fc08f 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>
2021-09-18 16:10:00 +02:00
Thomas Lamprecht
c3e98aed5b pmgbanner: use safer get-ip helper, drop hacks for old one
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-09-18 15:20:14 +02:00
Thomas Lamprecht
687cb0ef9c 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>
2021-09-18 15:07:03 +02:00
Oguz Bektas
239ef32a83 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>
2021-09-02 17:19:13 +02:00
Fabian Ebner
8fe9b27c44 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>
2021-07-19 17:43:00 +02:00
Thomas Lamprecht
78c8fe1762 bump version to 7.0-7
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-19 09:11:22 +02:00
Thomas Lamprecht
d513a8df5b 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>
2021-07-16 12:28:38 +02:00
Thomas Lamprecht
afbb3de285 api: apt versions: report more packages
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-15 14:25:10 +02:00
Thomas Lamprecht
63bbaa5eef 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>
2021-07-15 14:24:15 +02:00
Thomas Lamprecht
773780b022 bump version to 7.0-6
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-14 17:54:07 +02:00
Thomas Lamprecht
69a6a66d63 valid_ssh_pubkey_regex: code style: add missing whitespace
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-14 17:50:55 +02:00
Thomas Lamprecht
2eabf88038 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>
2021-07-14 17:49:51 +02:00
Stoiko Ivanov
81634addb6 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>
2021-07-14 17:48:48 +02:00
Stoiko Ivanov
2a5ed7c1e2 cluster: refactor ssh pubkey verification
to only have the regex in one place.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2021-07-14 17:48:27 +02:00
Thomas Lamprecht
9b4f6334f0 bump version to 7.0-5
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-14 11:58:53 +02:00
Thomas Lamprecht
11fe759695 use bullseye for enterprise repository
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-14 11:58:21 +02:00
Thomas Lamprecht
e9d823c960 bump version to 7.0-4
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-14 10:32:38 +02:00
Thomas Lamprecht
3bd155cfa9 d/control: recommend ifupdown2 and suggest zfsutils-linux
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-14 10:02:15 +02:00
Thomas Lamprecht
ecab836a03 bump version to 7.0-3
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-13 18:42:14 +02:00
Thomas Lamprecht
364f0a6c21 utils: fix typo in error message
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-13 18:40:50 +02:00
Thomas Lamprecht
d77bea5a24 api: services: track chrony 2021-07-13 17:15:59 +02:00
Thomas Lamprecht
04a08436e6 api: services: check if unit is even found
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-13 17:15:32 +02:00
Thomas Lamprecht
2b11b93ed1 api: services: code cleanup
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-13 17:15:05 +02:00
Thomas Lamprecht
219a8775f6 api: services: return active- and unit-state infos
same is PVE nowadays

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-13 17:07:26 +02:00
Thomas Lamprecht
822477d522 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>
2021-07-13 17:05:22 +02:00
Thomas Lamprecht
982c37b78e d/control: bump versioned dependency for libpmg-rs-perl
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-13 14:16:19 +02:00
Fabian Ebner
b50c7a1459 api: apt: add calls for repositories
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
2021-07-13 14:14:58 +02:00
Thomas Lamprecht
b335a91dc6 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>
2021-07-13 10:36:47 +02:00
Stoiko Ivanov
6ffef3edde 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>
2021-07-13 10:01:43 +02:00
Stoiko Ivanov
a90140cccb 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>
2021-07-13 10:01:43 +02:00
Stoiko Ivanov
fe0886a975 acme: handle wildcard dns validation
Wildcard DNS names (*.domain.example) are validated through their
base-domain (domain.example) according to the ACME RFC [0].

We store the indirection while parsing the acme config, and check for
an extra validation target during ordering.

This makes it possible to order wildcard certificates which are not
valid for the base-domain.

[0] https://tools.ietf.org/html/rfc8555#section-7.1.3

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2021-07-13 10:01:43 +02:00
Thomas Lamprecht
7266d5fd32 bump version to 7.0-2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2021-07-03 22:51:18 +02:00
Stoiko Ivanov
fe2090fbf0 config: freshclam: default to incremental downloads
clamav recently started yielding 429 (too many requests) response
codes on even comparatively low attempts to download the complete
signature files (cvd)(see [0]), instead of the incremental changes
(cdiff) (see [1] for some background)

changing the default to scriptedupdates (a.k.a. cdiff download) seems
sensible for most situations.

[0] https://docs.clamav.net/faq/faq-freshclam.html
[1] https://blog.clamav.net/2021/03/clamav-cvds-cdiffs-and-magic-behind.html

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2021-07-03 22:05:50 +02:00
Stoiko Ivanov
0a05c9d2de utils: fix service_aliases usage
2 errors were introduced in 4f06ff8ac2:

* a typo in the postgresql service name
* it missed the other uses of the service_name hash, apart from the
  lookup_real_service_name sub.

both fixed here

Reported-by: Martin Maurer <martin@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2021-07-03 22:05:50 +02:00