Building proxmox-backup-client on CentOS/RHEL 7

robhost

Active Member
Jun 15, 2014
224
9
38
Dresden
www.robhost.de
Hi,

we're currently in the process of trying to build proxmox-backup-client for CentOS 7 to evaluate and test the pbs beta.

We've worked through some build strategies and are currently trying a dynamically linked binary (glibc, libacl, libfuse3 etc.) w/ statically linked OpenSSL 1.1 which - while not optimal - seems to be the most promising approach.
We've ended up with a linking error caused by libproxmox depending on kernel versions >= 3.17 because the syscall getrandom(2) is being used:

Code:
= note: /src/proxmox-backup-client/src/proxmox-backup-client-0.8.7/target/release/deps/libproxmox-b21d4ae9d6eb878a.rlib(proxmox-b21d4ae9d6eb878a.proxmox.8xjg2tsj-cgu.5.rcgu.o): In function `proxmox::sys::linux::random_data::hf36922a63a1c6ca9':
        proxmox.8xjg2tsj-cgu.5:(.text._ZN7proxmox3sys5linux11random_data17hf36922a63a1c6ca9E+0x65): undefined reference to `getrandom'
        /src/proxmox-backup-client/src/proxmox-backup-client-0.8.7/target/release/deps/libproxmox-b21d4ae9d6eb878a.rlib(proxmox-b21d4ae9d6eb878a.proxmox.8xjg2tsj-cgu.5.rcgu.o): In function `proxmox::sys::linux::fill_with_random_data::h674c6e00c2169bdd':
        proxmox.8xjg2tsj-cgu.5:(.text._ZN7proxmox3sys5linux21fill_with_random_data17h674c6e00c2169bddE+0xc): undefined reference to `getrandom'
        collect2: error: ld returned 1 exit status

I couldn't find any actual dependency information on the repositories (except for the Cargo.toml files).
Is this dep on linux>=3.17 by design (thus eliminating CentOS/RHEL 7, kernel 3.10, EOL June 2024 from the list of possibly supported OSes)?
Or could the respective code at https://git.proxmox.com/?p=proxmox....s;hb=f165dee496ba00c1578fdc9c4c104f49913059c3 maybe be patched to use either another API (like OpenSSL RAND_bytes or some suitable implementation, but afaict the module seems to already require openssl anyways) or a direct implementation?

Regards,
Dirk - IT Systems Engineer - RobHost GmbH
 
that one instance is probably easy enough to make compatible, I am not sure what other things would crop up though. you can try (e.g., read from /dev/urandom directly instead?) and report back ;)
 
I've replaced the implementation of fill_with_random_data with getrandom::getrandom - which provides an abstraction for getrandom(2) on Linux. However we have no Rust experience in-house so the patch might not be optimal, esp. regarding return value usage.
With this change proxmox-backup-client (v0.8.9, based on the Arch Linux AUR package) successfully built on CentOS 7 with statically linked OpenSSL 1.1.1g.

As previously mentioned we do not know which requirements were defined for this code/the library as a whole or what system design builds upon this. So the consequences of replacing the code are unknown at this point. Maybe you could shed some light on this and if this is a viable replacement to support LTS OSes shipping less recent kernel versions like CentOS/RHEL/Oracle?

Diff:
Subject: [PATCH 1/1] Stub fill_with_random_data() with getrandom::getrandom()

---
 proxmox/Cargo.toml       |  1 +
 proxmox/src/sys/linux.rs | 20 ++------------------
 2 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/proxmox/Cargo.toml b/proxmox/Cargo.toml
index 50e3fb3..bfbd401 100644
--- a/proxmox/Cargo.toml
+++ b/proxmox/Cargo.toml
@@ -29,6 +29,7 @@ serde_json = "1.0"
 # libc, nix, lazy_static

 # sys module:
+getrandom = "0.1.14"
 # libc, nix, lazy_static

 # api module:
diff --git a/proxmox/src/sys/linux.rs b/proxmox/src/sys/linux.rs
index 75d1336..0a3b1a2 100644
--- a/proxmox/src/sys/linux.rs
+++ b/proxmox/src/sys/linux.rs
@@ -1,6 +1,7 @@
 //! Linux specific helpers and syscall wrapper

 use anyhow::*;
+use getrandom::getrandom;

 pub mod magic;
 pub mod pid;
@@ -17,25 +18,8 @@ pub fn random_data(size: usize) -> Result<Vec<u8>, Error> {
 }

 /// Fill buffer with pseudo random data (/dev/urandom)
-///
-/// This code uses the Linux syscall getrandom() - see "man 2 getrandom".
 pub fn fill_with_random_data(buffer: &mut [u8]) -> Result<(), Error> {
-    let res = unsafe {
-        libc::getrandom(
-            buffer.as_mut_ptr() as *mut libc::c_void,
-            buffer.len() as libc::size_t,
-            0 as libc::c_uint,
-        )
-    };
-
-    if res == -1 {
-        return Err(std::io::Error::last_os_error().into());
-    }
-
-    if res as usize != buffer.len() {
-        // should not happen
-        bail!("short getrandom read");
-    }
+    getrandom(buffer)?;

     Ok(())
 }
--
1.8.3.1

- Dirk
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!