Commit Graph

2008 Commits

Author SHA1 Message Date
Lukas Wagner
b8040a23cb add proxmox-notify crate
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:25 +02:00
Lukas Wagner
82be261447 schema: add schema/format for comments
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:22 +02:00
Lukas Wagner
8013a80b41 section-config: derive Clone for SectionConfigData
Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-07-24 10:25:20 +02:00
Wolfgang Bumiller
f6e089555e schema: verify property strings w/ new serde code
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-13 16:19:19 +02:00
Wolfgang Bumiller
12da5121ff schema: predictable order of errors for tests
Otherwise we'd have to "search" & match the errors...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-13 16:19:17 +02:00
Wolfgang Bumiller
c702638bd8 schema: fixup empty error list handling
Some(<empty list of errors>) does not actually signal an error...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-13 16:19:16 +02:00
Wolfgang Bumiller
aa10025366 schema: guard property string constraint checking
StringSchema::check_constraint runs `parse_property_string` for
property strings, but when we deserialize a `PropertyString` we
immediately follow that up with deserializing it using the schema, so
there's no need to check it beforehand.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-13 16:19:13 +02:00
Wolfgang Bumiller
1a46283b78 schema: get rid of some unsafe code
the borrow tracking won't hurt...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-13 16:19:11 +02:00
Wolfgang Bumiller
73a20c7f5f schema: use schema when serializing property strings
Adds a Schema to the `PropertyString` type and uses it for better
serialization.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-13 16:19:09 +02:00
Wolfgang Bumiller
413d631fa6 schema: convenience accessors to schema subtypes
Adds `const fn <type>(&self) -> Option<&<Type>Schema>` methods to
`Schema`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-13 16:19:05 +02:00
Wolfgang Bumiller
5a64f3258a schema: serde based property string de- and serialization
This provides `proxmox_schema::property_string::PropertyString<T>` for
a typed property-string.

To facilitate this, this introduces
`proxmox_schema:🇩🇪:SchemaDeserializer` which is a serde deserializer
for property strings given a schema.

This basically maps to one of `de::SeqAccess` (for array schemas) or
`de::MapAccess` (for object schemas).

Additionally, a `de::NoSchemaDeserializer` is added, since properties
within the strings may have string schemas with no format to it, while
the type we serialize to may ask for an array (a simple "list") via
serde.

The deserializers support borrowing, for which a helper `Cow3` needed
to be added, since property strings support quoting with escape
sequences where an intermediate string would be allocated and with an
intermediate lifetime distinct from the `'de` lifetime.

A `de::verify` module is added which uses serde infrastructure to
validate schemas without first having to deserialize a complete
`serde_json::Value`.

For serialization, `proxmox_schema::ser::PropertyStringSerializer` is
added split into similar parts `ser::SerializeStruct` and
`ser::SerializeSeq` at the top level, and the same prefixed with
`Element` for inside the actual string. This should also properly
quote the contents if required.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-13 16:18:58 +02:00
Wolfgang Bumiller
4ca8dbf74f auth-api: fixup examples
These were missing the new client-ip parameter in the auth
function calls which was introduced to support `PAM_RHOST`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-10 09:06:35 +02:00
Thomas Lamprecht
ec5e2a5d90 proxmox-apt: bump to 0.10.3-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-07-05 12:38:08 +02:00
Wolfgang Bumiller
50136f1817 bump proxmox-tfa to 4.0.4
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-05 10:46:12 +02:00
Wolfgang Bumiller
8547ee31da tfa: also reset counters when unlocking tfa
Since this requires access to the user data, we need to add
a generic parameter to the unlock methods.
To avoid having to create another major API bump affecting
all our products this short after release, we keep the old
version around with the old behavior.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-07-04 14:45:18 +02:00
Fabian Grünbichler
415d60daf9 release file: extend component fixup to bookworm
else mirroring bookworm-security will skip *all* components..

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-06-29 13:11:17 +02:00
Thomas Lamprecht
2a070da065 proxmox-rest-server: bump to 0.4.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-27 12:44:52 +02:00
Thomas Lamprecht
880abd859b proxmox-apt: bump version to 0.10.2-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-27 12:36:05 +02:00
Wolfgang Bumiller
54cb9be8ed bump proxmox-ldap to 0.2.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-26 14:22:50 +02:00
Stefan Sterz
7f135263a9 ldap: add check_connection function
this function checks if a given connection could work. it uses the
current config to connect to an ldap directory and perform a search
with the provided base_dn. this enables us to verify a connection
before storing it in a more meaningful way than with a regex.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2023-06-26 14:15:35 +02:00
Stefan Sterz
599a6a49da ldap: remove support for unauthenticated binds
by using the default empty string if no password was provided,
unauthenticated binds were possible. to bring pbs in-line with pve,
switch to throwing an error in this case instead. however, this will
break any pre-existing setup that relied on this behavior.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2023-06-26 14:15:33 +02:00
Wolfgang Bumiller
962ce920a0 bump proxmox-human-byte to 0.1.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-26 13:37:29 +02:00
Wolfgang Bumiller
c611afcf0d human-byte: update copyright format
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-26 13:37:29 +02:00
Lukas Wagner
77dbc2fe18 human-byte: move tests to their sub module
The `#[cfg(test)]` directive ensures that the tests are not compiled
for non-test builds.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-06-26 13:24:51 +02:00
Lukas Wagner
c3545d6644 add proxmox-human-byte crate
The module previously lived in `pbs-api-types`, however turned out to
be useful in other places as well (POM, proxmox-notify), so it is moved
here as its own micro-crate.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-06-26 13:24:48 +02:00
Wolfgang Bumiller
d5b9f166a2 cargo fmt
bigger changes are only in the new crates
rest are minor ones

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-23 11:50:39 +02:00
Fabian Grünbichler
b687edc1a0 rest: remove full static file path from error messages
this triggers certain security scanners, and having the requested path instead
gives basically the same information anyhow.

reported on the forum: https://forum.proxmox.com/threads/404-path-disclosure-vulnerability.129187/

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-06-23 11:46:52 +02:00
Wolfgang Bumiller
5791af8ff4 ldap: rustfmt
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-23 11:20:25 +02:00
Lukas Wagner
378e2380b7 ldap: surround user filter expression in parenthesis if not already
In PVE, the `filter` attribute is surrounded in () if it is not already,
allowing "uid=test" as well as "(uid=test)" [1].

A forum user [2] just ran into this inconsistency, so I decided to adjust
the behavior.

[1] https://git.proxmox.com/?p=pve-common.git;a=blob;f=src/PVE/LDAP.pm;h=ff98e367e63265bf76c0f302847c3749eea095a6;hb=HEAD#l115
[2] https://forum.proxmox.com/threads/ldap-query-for-security-group-members.127882/

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-06-23 11:19:04 +02:00
Maximiliano Sandoval
84edb20eb8 tfa: Improve TOTP algorithm parsing
It is very common for TOTP URIs to contain the algorithm in lowercase,
hence we convert to lowercase when doing From<&str> for Algorithm.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2023-06-20 12:39:46 +02:00
Wolfgang Bumiller
16d512b4d9 bump proxmox-compression to 0.2.1-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-15 11:01:19 +02:00
Wolfgang Bumiller
5b55ea797a compression: match style fixup
if the match arms are this far away from the actual `match`
keyword, this needs to be split up...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-15 10:37:59 +02:00
Dominik Csapak
af46b655d4 compression: zip_directory: improve error handling
when zipping a directory, our intention was to skip over files that
cannot be zipped (e.g. the file can't be read/vanished/etc.), so we
ignored errors and simply logged it.

but when 'add_entry' fails, we will never actually restore, since every
error there is fatal to the point that the zip cannot be finished thats
because we take the 'target' sink out of self, and only insert it again
after all writes succeeded. so if an error occurs in between 'target' is
not put into self again (and never will be) and the zip cannot be
finished (even if we would catch all those intermediate errors and
restore 'target', we don't know in which state the output was, so we're
unable to finish a valid zip)

to fix that, split the actual 'add_entry' part there out of the async
move block and treat its errors always as fatal

without this, we generate heaps of log lines even after an error
occurred, and can never recover

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2023-06-15 10:28:50 +02:00
Wolfgang Bumiller
39a486f574 bump proxmox-tfa to 4.0.3
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-14 13:52:20 +02:00
Wolfgang Bumiller
5f1a0bc0c9 tfa: make TfaUser fields public
So we can print them in the proxmox-backup-manager CLI text
output.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-14 13:50:38 +02:00
Wolfgang Bumiller
ba39c5f990 auth-api: bump d/control
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-14 13:50:29 +02:00
Wolfgang Bumiller
cc091c4fe5 bump proxmox-auth-api to 0.3.0
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-14 09:55:31 +02:00
Wolfgang Bumiller
a228a22918 auth-api: set PAM_RHOST during pam authentication
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-14 09:32:03 +02:00
Wolfgang Bumiller
8f08039e7e auth-api: drop pam crate
it's too limited

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-14 08:51:43 +02:00
Fabian Grünbichler
c8433e3219 fix #4653: (In)Release file: improve handling of special suites
APT doesn't mind a repository with either "/" or "./" as suite/distribution,
such as

 deb https://example.com/debian ./

in that case, the 'dists' part of the URL and the trailing slash (which would
be encoded as '_') is dropped in the file name in '/var/lib/apt/lists/'.

Other suite values with a trailing or leading '/' are rejected with an error by APT:

 E: Malformed entry 1 in sources file /etc/apt/sources.list.d/test.list (absolute Suite Component)
 E: The list of sources could not be read.

so this should be the only special case requiring handling.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-06-06 18:24:39 +02:00
Fabian Grünbichler
27cd025053 fallback to Release file for Origin retrieval
APT will not store the InRelease file in some cases, and some repositories
might not even have one in the first place.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-06-06 18:24:39 +02:00
Wolfgang Bumiller
35dc1b0b8d bump proxmox-tfa to 4.0.2
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-06-05 08:59:55 +02:00
Thomas Lamprecht
0fb7ec0c32 buildsys: also cleanup *.build files for convenience
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-04 18:27:46 +02:00
Thomas Lamprecht
45432b689d apt: bump version to 0.10.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-03 18:29:04 +02:00
Thomas Lamprecht
a367f6a0d8 build.sh: split overly long line
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-03 16:48:10 +02:00
Thomas Lamprecht
ce6a87d513 buildsys: don't try to resolve dependency metadata when assembling crate list
A build-system that needs all build-dependencies even for a simple
make clean invocation is a PITA..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-03 16:39:39 +02:00
Fiona Ebner
cc17861f54 apt: tests: add tests for Ceph Quincy repository detection on Bookworm
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-06-03 14:39:05 +02:00
Fiona Ebner
06ad528c94 apt: tests: code cleanup to avoid useless vector
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-06-03 14:39:05 +02:00
Fiona Ebner
9b7c5339d7 apt: tests: create temporary test directories in CARGO_TARGET_TMPDIR
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-06-03 14:39:05 +02:00
Fiona Ebner
bae15e2408 apt: split Ceph main repository into no-subscription and enterprise
The old 'main' component stays valid, pointing to no-subscription,
which means the is_referenced_repository() check needs a special case
for it. It will eventually go away, together with the handles for
Quincy.

Alternatively, the standard repository's info() could've been changed
to return multiple possible components, similar to URLs, but as
opposed to URLs, there could be a standard repository that wants to
have multiple components and it feels a bit unnatural, because
multiple components are usually not aliases of the same. And adapting
is_referenced_repository() would be needed here too. So overall, the
above alternative just felt better.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
2023-06-03 14:39:05 +02:00