Commit Graph

164 Commits

Author SHA1 Message Date
Dietmar Maurer
57723e98fd sys: add helpers to check file and directory permissions
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-29 10:14:24 +02:00
Dietmar Maurer
37c9dbf1eb sys: create options: make file parameter generic
Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
2024-05-29 09:32:48 +02:00
Wolfgang Bumiller
bf9dc73246 sys: bump version to 0.5.5-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-05-22 15:48:34 +02:00
Stefan Sterz
eef12f91a1 sys: crypt: use constant time comparison for password verification
by using `openssl::memcmp::eq()` we can avoid potential timing side
channels as its runtime only depends on the length of the arrays, not
the contents. this requires the two arrays to have the same length, but
that should be a given since the hashes should always have the same
length.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2024-05-22 10:26:43 +02:00
Stefan Sterz
f82bb2fc2b sys: crypt: move to yescrypt for password hashing
previously we used `sha256scrypt` for password hashing. while this may
by safe if used with the correct parameters, we used the default
parameters which are considered unsafe. according to `man crypt(5)`:

> The default CPU time cost parameter is 5000, which is too low for
> modern hardware.

hence, we needed to adapt this code anyway. conveniently, verification
with crypt also works for older hashes as the parameters for the
hashing function are encoded in the output of crypt. so this is a drop
in replacement that will simply use yescrypt for new hashes while
old hashes will still verify properly.

this commit also adds a wrapper for `crypt_gensalt_rn` to more easily
generate correctly formatted salt strings. this is also useful for
switching the cpu time hardness parameter, as otherwise we'd need to
encode that ourselves.

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
2024-05-22 10:26:41 +02:00
Thomas Lamprecht
5987eb0c3f sys: bump version to 0.5.4-2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-26 17:24:23 +02:00
Thomas Lamprecht
c68b69e949 sys: bump version to 0.5.4-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-26 16:52:46 +02:00
Gabriel Goller
78bf05a458 fix: use fragmented block size for space calculation
We currently calculate the size of a datastore using `statfs64`, which
returns the number of blocks in the fs and the two block sizes:
fragemented block size(f_frsize) and block size (f_bsize). To calculate
eg the total space in a datastore we use total_blocks * f_bsize, which
is not always correct.

`f_frsize` is the minimum unit of allocation on the filesystem (in
bytes) and in 99% of the cases equal to `f_bsize`, but in some cases
it differs. For example some filesystems allow smaller blocks for small
files, in case f_frsize < f_bsize. In that case, f_frsize * total_blocks
returns (mostly) the correct result (ceph also did some weird stuff, which is
now being fixed though [0][1]). `statvfs` also documents this as the
recommended way ('fsblkcnt_t f_blocks;   /* Size of fs in f_frsize units */')[2].

This patch aligns the the behavior with the libc utilities (also used by
`df`) [3].

Motivation: [4] (Forum post)

[0]: https://tracker.ceph.com/issues/3793
[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=92a49fb0f79f3300e6e50ddf56238e70678e4202
[2]: https://www.man7.org/linux/man-pages/man3/statvfs.3.html
[3]: https://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/fsusage.c#n147
[4]: https://forum.proxmox.com/threads/pbs-3-1-2-wrong-datastore-information-sshfs.139875/#post-626959

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2024-03-25 16:59:17 +01:00
Thomas Lamprecht
55f4d532c7 sys: d/copyright: update years
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-19 11:23:43 +01:00
Maximiliano Sandoval R
430df21720 sys: Use safe wrapper for libc::isatty
Use the `std::io::IsTerminal` trait introduced in Rust 1.70.

Internally it calls `libc::isatty`, see [1, 2]. Note that it switches
the comparison from `== 1` to `!= 0` which shouldn't make a difference
assuming that libc::isatty upholds the promises made in its man page.

The MSRV was set on the workspace to reflect this change.

[1] https://doc.rust-lang.org/src/std/io/stdio.rs.html#1079
[2] https://doc.rust-lang.org/src/std/sys/unix/io.rs.html#79

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
2024-02-16 16:55:58 +01:00
Wolfgang Bumiller
674ab33a43 bump proxmox-sys to 0.5.3-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-01-08 12:48:57 +01:00
Lukas Wagner
dc72878d37 sys: email: use epoch_to_rfc2822 from proxmox_time
`strftime`'s formatting is locale-dependent. If the system locale was
set to e.g. de_DE.UTF-8, the `Date` header became invalid
(e.g Mo instead of Mon for 'Monday'), tripping up some mail clients
(e.g. KMail).

This commit should fix this by using the new `epoch_to_rfc2822`
function from proxmox_time. Under the hood, this function uses
`strftime_l` with a fixed locale (C).

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2024-01-08 12:04:47 +01:00
Wolfgang Bumiller
50b79198f8 sys: bump to 0.5.2-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-29 15:26:21 +01:00
Gabriel Goller
5517d6f839 sys: email: move Auto-Submitted header up
Move the Auto-Submitted header out of the multipart section.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2023-11-29 15:17:53 +01:00
Wolfgang Bumiller
8e5c164bf5 sys: cleanup assigned and immediately returned var
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-29 14:57:29 +01:00
Gabriel Goller
12657f89b3 sys: add helper to get bootmode and secureboot status
Helper that return the current boot_mode and secureboot status.
Detection works the same as in pve, we use `/sys/firmware/efi` and
the `efivars/SecureBoot-xxx..` file.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2023-11-29 14:54:29 +01:00
Thomas Lamprecht
af660f1fee sys: bump version to 0.5.1-1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 10:42:38 +01:00
Thomas Lamprecht
a3fbe14f44 sys: purge pty module
it was only used in the terminal proxy and got moved there.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 08:35:18 +01:00
Lukas Wagner
d20d9ec1aa sys: email: add forward
This new function forwards an email to new recipients.

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-11-17 08:31:36 +01:00
Thomas Lamprecht
c8a0ba04ca sys: depreacate PTY module, moves to termproxy directly
As termproxy only used this module from the huge proxmox-sys crate,
and this module was also only used here, it makes sense to move it
over there (and dropping proxmox-sys halved build-time from 8.5 s to
4.2 s).

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-10-24 13:52:16 +02:00
Gabriel Goller
bcdcb181ee fix #4162: sys: added auto-submitted header to email body
`Auto-Submitted` is defined in the rfc 5436 [1] and describes how
an automatic response (f.e. ooo replies, etc.) should behave on the
emails. When using `Auto-Submitted: auto-generated` (or any value
other than `none`) automatic replies won't be triggered.

[1]: https://www.rfc-editor.org/rfc/rfc3834.html

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2023-09-18 16:41:06 +02:00
Lukas Wagner
bcd134a349 sys: fs: move tests to a sub-module
This ensures that test code is not compiled in regular builds

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
2023-08-30 17:37:31 +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
Wolfgang Bumiller
dd87a120bd bump proxmox-sys to 0.5.0-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-23 13:02:51 +02:00
Wolfgang Bumiller
818ac8e708 update zstd 0.6 -> 0.12 for bookworm
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-23 13:02:51 +02:00
Wolfgang Bumiller
8f8d52f148 update d/copyright files to debian copyright-format 1.0
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-05-23 13:02:39 +02:00
Wolfgang Bumiller
7e12788c60 sys: drop sortable and identity macros
We should not use the sys crate to pull in the sortable
macro, just depend on its crate instead...
And the identity macro used to be required by the sortable
macro, but is not anymore and has been deprecated for a
while, so we can now drop it.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-03-01 13:40:40 +01:00
Thomas Lamprecht
fbac2f0a0c sys: fixup error types handling
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-02-02 16:32:37 +01:00
Thomas Lamprecht
ce389914ff sys: cope with unavailable KSM sharing info
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-02-02 16:12:20 +01:00
Fabian Grünbichler
9c44e9b410 update d/control files
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-05 12:17:00 +01:00
Fabian Grünbichler
01e9b3affc bump proxmox-sys to 0.4.2-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-05 12:07:45 +01:00
Fabian Grünbichler
ff9aa2012e update nix to 0.26
it's the version currently shipped by bookworm, so let's unify this widely-used
dependency to make bootstrapping easier.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-01-05 12:07:16 +01:00
Fabian Grünbichler
1380182538 update d/control
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-12 11:05:30 +01:00
Fabian Grünbichler
8316fd3899 more workspace dependencies
regex was missed in the first pass, and two intra-workspace dev-dependencies as
well.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-12 09:30:30 +01:00
Fabian Grünbichler
46a675830d update d/control files
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:47 +01:00
Fabian Grünbichler
bdca6de588 update d/control files
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:47 +01:00
Fabian Grünbichler
e5abc0590e define workspace dependencies in workspace
so that we no longer have to (or forget to) bump the version in multiple places.

notable changes:
- outdated versions have been unified
- proxmox-metrics -> proxmox-async no longer uses explicit empty features
  (proxmox-async doesn't provide any anyway)
- proxmox-subscription -> proxmox-http no longer uses explicit default_features
  = false (proxmox-http has an empty default feature anyway)
- missing path dependencies added (mainly proxmox-rest-server)

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:38 +01:00
Fabian Grünbichler
4189221470 inherit shared, external dependencies
noteworthy changes:
- proxmox-http had a default_features_false dep on hyper, which is dropped (the
  default feature is empty anyway)
- hyper, libc, nix, tokio and url versions are unified
- missing (cosmetic) bindgen feature on zstd enabled everywhere

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:38 +01:00
Fabian Grünbichler
64959d9ae0 move common metadata to workspace
and switch all crates to 2021 edition as well as a unified "authors" value.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-07 09:48:25 +01:00
Fabian Grünbichler
5ec765f842 update d/control files
debcargo 2.6 changed some minor details

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-06 11:21:43 +01:00
Fabian Grünbichler
538578c558 clippy 1.65 fixes
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-12-05 11:17:37 +01:00
Wolfgang Bumiller
cfa77e0e88 sys: impl AsFd for PTY
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-10-19 14:36:45 +02:00
Wolfgang Bumiller
34688a6d74 sys: impl AsFd for PidFd
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-10-19 14:35:07 +02:00
Wolfgang Bumiller
34f47339d5 bump sys to 0.4.1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-10-19 14:21:08 +02:00
Wolfgang Bumiller
ab17fdb4d9 sys: deprecate RawFdNum
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-10-19 13:55:47 +02:00
Wolfgang Bumiller
88677d8955 sys: add From<OwnedFd/Fd> for Fd/OwnedFd temporarily
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-10-19 13:50:17 +02:00
Wolfgang Bumiller
8420c266af sys: deprecate Fd, add its methods as module functions
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-10-19 13:25:40 +02:00
Wolfgang Bumiller
85c260f6b5 sys: deprecate BorrowedFd
std has this now, stable since 1.63

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2022-10-19 10:55:16 +02:00
Fabian Grünbichler
95f7232188 cargo fmt
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2022-10-11 09:48:11 +02:00
Thomas Lamprecht
52a8eb6ace d/control: tree wide update after switch to weak/namespaced dependencies
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2022-08-26 12:07:36 +02:00