]> git.proxmox.com Git - proxmox-backup.git/commitdiff
update to proxmox-sys 0.2 crate
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 23 Nov 2021 16:57:00 +0000 (17:57 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 24 Nov 2021 09:32:27 +0000 (10:32 +0100)
- imported pbs-api-types/src/common_regex.rs from old proxmox crate
- use hex crate to generate/parse hex digest
- remove all reference to proxmox crate (use proxmox-sys and
  proxmox-serde instead)

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
201 files changed:
Cargo.toml
debian/control
examples/cipherbench.rs
pbs-api-types/Cargo.toml
pbs-api-types/src/common_regex.rs [new file with mode: 0644]
pbs-api-types/src/crypto.rs
pbs-api-types/src/human_byte.rs
pbs-api-types/src/jobs.rs
pbs-api-types/src/lib.rs
pbs-api-types/src/remote.rs
pbs-api-types/src/tape/media_location.rs
pbs-api-types/src/userid.rs
pbs-client/Cargo.toml
pbs-client/src/backup_reader.rs
pbs-client/src/backup_writer.rs
pbs-client/src/catalog_shell.rs
pbs-client/src/http_client.rs
pbs-client/src/pxar/create.rs
pbs-client/src/pxar/dir_stack.rs
pbs-client/src/pxar/extract.rs
pbs-client/src/pxar/flags.rs
pbs-client/src/pxar/fuse.rs
pbs-client/src/pxar/metadata.rs
pbs-client/src/tools/key_source.rs
pbs-client/src/tools/mod.rs
pbs-config/Cargo.toml
pbs-config/src/config_version_cache.rs
pbs-config/src/datastore.rs
pbs-config/src/domains.rs
pbs-config/src/drive.rs
pbs-config/src/key_config.rs
pbs-config/src/lib.rs
pbs-config/src/media_pool.rs
pbs-config/src/network/helper.rs
pbs-config/src/network/mod.rs
pbs-config/src/network/parser.rs
pbs-config/src/remote.rs
pbs-config/src/sync.rs
pbs-config/src/tape_encryption_keys.rs
pbs-config/src/tape_job.rs
pbs-config/src/token_shadow.rs
pbs-config/src/traffic_control.rs
pbs-config/src/user.rs
pbs-config/src/verify.rs
pbs-datastore/Cargo.toml
pbs-datastore/src/backup_info.rs
pbs-datastore/src/cached_chunk_reader.rs
pbs-datastore/src/chunk_store.rs
pbs-datastore/src/crypt_writer.rs
pbs-datastore/src/data_blob.rs
pbs-datastore/src/datastore.rs
pbs-datastore/src/dynamic_index.rs
pbs-datastore/src/fixed_index.rs
pbs-datastore/src/manifest.rs
pbs-datastore/src/paperkey.rs
pbs-datastore/src/snapshot_reader.rs
pbs-fuse-loop/Cargo.toml
pbs-fuse-loop/src/fuse_loop.rs
pbs-tape/Cargo.toml
pbs-tape/src/blocked_reader.rs
pbs-tape/src/blocked_writer.rs
pbs-tape/src/emulate_tape_reader.rs
pbs-tape/src/emulate_tape_writer.rs
pbs-tape/src/linux_list_drives.rs
pbs-tape/src/sg_tape.rs
pbs-tape/src/sg_tape/mam.rs
pbs-tape/src/tape_write.rs
pbs-tools/Cargo.toml
pbs-tools/src/acl.rs [deleted file]
pbs-tools/src/cert.rs
pbs-tools/src/command.rs [deleted file]
pbs-tools/src/fs.rs [deleted file]
pbs-tools/src/io.rs
pbs-tools/src/lib.rs
pbs-tools/src/sync/std_channel_writer.rs
pbs-tools/src/xattr.rs [deleted file]
proxmox-backup-client/Cargo.toml
proxmox-backup-client/src/benchmark.rs
proxmox-backup-client/src/key.rs
proxmox-backup-client/src/main.rs
proxmox-backup-client/src/mount.rs
proxmox-backup-client/src/snapshot.rs
proxmox-file-restore/Cargo.toml
proxmox-file-restore/src/block_driver_qemu.rs
proxmox-file-restore/src/main.rs
proxmox-file-restore/src/qemu_helper.rs
proxmox-rest-server/Cargo.toml
proxmox-rest-server/src/api_config.rs
proxmox-rest-server/src/daemon.rs
proxmox-rest-server/src/file_logger.rs
proxmox-rest-server/src/lib.rs
proxmox-rest-server/src/rest.rs
proxmox-rest-server/src/worker_task.rs
proxmox-restore-daemon/Cargo.toml
proxmox-restore-daemon/src/proxmox_restore_daemon/api.rs
proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
proxmox-rrd/Cargo.toml
proxmox-rrd/examples/prrd.rs
proxmox-rrd/src/cache.rs
proxmox-rrd/src/cache/journal.rs
proxmox-rrd/src/cache/rrd_map.rs
proxmox-rrd/src/rrd.rs
proxmox-rrd/tests/file_format_test.rs
pxar-bin/Cargo.toml
pxar-bin/src/main.rs
src/acme/client.rs
src/api2/access/acl.rs
src/api2/access/domain.rs
src/api2/access/mod.rs
src/api2/access/openid.rs
src/api2/access/user.rs
src/api2/admin/datastore.rs
src/api2/admin/sync.rs
src/api2/admin/traffic_control.rs
src/api2/admin/verify.rs
src/api2/backup/environment.rs
src/api2/backup/mod.rs
src/api2/backup/upload_chunk.rs
src/api2/config/access/mod.rs
src/api2/config/access/openid.rs
src/api2/config/access/tfa.rs
src/api2/config/acme.rs
src/api2/config/changer.rs
src/api2/config/datastore.rs
src/api2/config/drive.rs
src/api2/config/media_pool.rs
src/api2/config/remote.rs
src/api2/config/sync.rs
src/api2/config/tape_backup_job.rs
src/api2/config/tape_encryption_keys.rs
src/api2/config/traffic_control.rs
src/api2/config/verify.rs
src/api2/node/apt.rs
src/api2/node/certificates.rs
src/api2/node/config.rs
src/api2/node/disks/directory.rs
src/api2/node/disks/mod.rs
src/api2/node/disks/zfs.rs
src/api2/node/dns.rs
src/api2/node/mod.rs
src/api2/node/network.rs
src/api2/node/services.rs
src/api2/node/status.rs
src/api2/node/tasks.rs
src/api2/node/time.rs
src/api2/reader/mod.rs
src/api2/tape/backup.rs
src/api2/tape/drive.rs
src/api2/tape/restore.rs
src/auth.rs
src/auth_helpers.rs
src/backup/verify.rs
src/bin/proxmox-backup-api.rs
src/bin/proxmox-backup-manager.rs
src/bin/proxmox-backup-proxy.rs
src/bin/proxmox-daily-update.rs
src/bin/proxmox_backup_debug/inspect.rs
src/bin/proxmox_backup_debug/recover.rs
src/bin/proxmox_backup_manager/acme.rs
src/bin/proxmox_tape/encryption_key.rs
src/config/acme/mod.rs
src/config/acme/plugin.rs
src/config/mod.rs
src/config/node.rs
src/config/tfa.rs
src/rrd_cache.rs
src/server/email_notifications.rs
src/server/jobstate.rs
src/server/mod.rs
src/server/pull.rs
src/server/report.rs
src/shared_rate_limiter.rs
src/tape/changer/mod.rs
src/tape/changer/mtx/mtx_wrapper.rs
src/tape/drive/lto/mod.rs
src/tape/drive/mod.rs
src/tape/drive/virtual_tape.rs
src/tape/file_formats/catalog_archive.rs
src/tape/file_formats/chunk_archive.rs
src/tape/file_formats/multi_volume_reader.rs
src/tape/file_formats/multi_volume_writer.rs
src/tape/file_formats/snapshot_archive.rs
src/tape/inventory.rs
src/tape/media_catalog.rs
src/tape/media_catalog_cache.rs
src/tape/mod.rs
src/tape/pool_writer/mod.rs
src/tape/pool_writer/new_chunks_iterator.rs
src/tools/apt.rs
src/tools/disks/lvm.rs
src/tools/disks/mod.rs
src/tools/disks/smart.rs
src/tools/disks/zfs.rs
src/tools/disks/zpool_list.rs
src/tools/disks/zpool_status.rs
src/tools/http.rs
src/tools/mod.rs
src/tools/subscription.rs
src/tools/systemd/config.rs
src/tools/systemd/unit.rs
tests/worker-task-abort.rs

index eed8f8f9877554b38d3fce97242e12aeb87fb9f5..872ea1a0a4af9c39e72850286544afefdecb5399 100644 (file)
@@ -94,8 +94,7 @@ zstd = { version = "0.6", features = [ "bindgen" ] }
 pathpatterns = "0.1.2"
 pxar = { version = "0.10.1", features = [ "tokio-io" ] }
 
-proxmox = { version = "0.15.3", features = [ "sortable-macro" ] }
-proxmox-http = { version = "0.5.4", features = [ "client", "http-helpers", "websocket" ] }
+proxmox-http = { version = "0.6", features = [ "client", "http-helpers", "websocket" ] }
 proxmox-io = "1"
 proxmox-lang = "1"
 proxmox-router = { version = "1.1", features = [ "cli" ] }
@@ -104,12 +103,14 @@ proxmox-section-config = "1"
 proxmox-tfa = { version = "1.3", features = [ "api", "api-types" ] }
 proxmox-time = "1"
 proxmox-uuid = "1"
-proxmox-shared-memory = "0.1.1"
-proxmox-sys = "0.1.2"
+proxmox-serde = "0.1"
+proxmox-shared-memory = "0.2"
+proxmox-sys = { version = "0.2", features = [ "sortable-macro" ] }
+
 
 proxmox-acme-rs = "0.3"
 proxmox-apt = "0.8.0"
-proxmox-async = "0.2"
+proxmox-async = "0.3"
 proxmox-openid = "0.9.0"
 
 pbs-api-types = { path = "pbs-api-types" }
index 170009ab5874ddae05d833348e622e8837249b47..53c38d2e7d1351605ef54500d437093c57b04034 100644 (file)
@@ -40,18 +40,15 @@ Build-Depends: debhelper (>= 12),
  librust-pathpatterns-0.1+default-dev (>= 0.1.2-~~),
  librust-percent-encoding-2+default-dev (>= 2.1-~~),
  librust-pin-project-lite-0.2+default-dev,
- librust-proxmox-0.15+default-dev (>= 0.15.3-~~),
- librust-proxmox-0.15+sortable-macro-dev (>= 0.15.3-~~),
- librust-proxmox-0.15+tokio-dev (>= 0.15.3-~~),
  librust-proxmox-acme-rs-0.3+default-dev,
  librust-proxmox-apt-0.8+default-dev,
- librust-proxmox-async-0.2+default-dev,
+ librust-proxmox-async-0.3+default-dev,
  librust-proxmox-borrow-1+default-dev,
  librust-proxmox-fuse-0.1+default-dev (>= 0.1.1-~~),
- librust-proxmox-http-0.5+client-dev (>= 0.5.4-~~),
- librust-proxmox-http-0.5+default-dev (>= 0.5.4-~~),
- librust-proxmox-http-0.5+http-helpers-dev (>= 0.5.4-~~),
- librust-proxmox-http-0.5+websocket-dev (>= 0.5.4-~~),
+ librust-proxmox-http-0.6+client-dev,
+ librust-proxmox-http-0.6+default-dev,
+ librust-proxmox-http-0.6+http-helpers-dev,
+ librust-proxmox-http-0.6+websocket-dev,
  librust-proxmox-io-1+default-dev,
  librust-proxmox-io-1+tokio-dev,
  librust-proxmox-lang-1+default-dev,
@@ -62,8 +59,9 @@ Build-Depends: debhelper (>= 12),
  librust-proxmox-schema-1+default-dev (>= 1.0.1-~~),
  librust-proxmox-schema-1+upid-api-impl-dev (>= 1.0.1-~~),
  librust-proxmox-section-config-1+default-dev,
- librust-proxmox-shared-memory-0.1+default-dev (>= 0.1.1-~~),
- librust-proxmox-sys-0.1+default-dev (>= 0.1.2-~~),
+ librust-proxmox-shared-memory-0.2+default-dev,
+ librust-proxmox-sys-0.2+default-dev,
+ librust-proxmox-sys-0.2+sortable-macro-dev,
  librust-proxmox-tfa-1+api-dev (>= 1.3-~~),
  librust-proxmox-tfa-1+api-types-dev (>= 1.3-~~),
  librust-proxmox-tfa-1+default-dev (>= 1.3-~~),
index 40e4984bd8d270809f7e41964f75d49a9659affc..2abb0aafdd75b50b6047df0521c0b2c9748ce3d4 100644 (file)
@@ -27,7 +27,7 @@ fn rate_test(name: &str, bench: &dyn Fn() -> usize) {
 
 fn main() -> Result<(), Error> {
 
-    let input = proxmox::sys::linux::random_data(1024*1024)?;
+    let input = proxmox_sys::linux::random_data(1024*1024)?;
 
     rate_test("crc32", &|| {
         let mut crchasher = crc32fast::Hasher::new();
@@ -46,9 +46,9 @@ fn main() -> Result<(), Error> {
         input.len()
     });
 
-    let key = proxmox::sys::linux::random_data(32)?;
+    let key = proxmox_sys::linux::random_data(32)?;
 
-    let iv = proxmox::sys::linux::random_data(16)?;
+    let iv = proxmox_sys::linux::random_data(16)?;
 
     let cipher =  openssl::symm::Cipher::aes_256_gcm();
 
index 925207e8603009a273ae4972416447aa9850657d..3bee23ba9249e4995d18c3abbf79b4a23b6d8625 100644 (file)
@@ -15,8 +15,10 @@ openssl = "0.10"
 regex = "1.2"
 serde = { version = "1.0", features = ["derive"] }
 
-proxmox = "0.15.3"
 proxmox-lang = "1.0.0"
 proxmox-schema = { version = "1.0.1", features = [ "api-macro" ] }
+proxmox-serde = "0.1"
 proxmox-time = "1.1"
 proxmox-uuid = { version = "1.0.0", features = [ "serde" ] }
+
+proxmox-sys = "0.2" # only needed foör nodename()??
\ No newline at end of file
diff --git a/pbs-api-types/src/common_regex.rs b/pbs-api-types/src/common_regex.rs
new file mode 100644 (file)
index 0000000..8fe3067
--- /dev/null
@@ -0,0 +1,78 @@
+//! Predefined Regular Expressions
+//!
+//! This is a collection of useful regular expressions
+
+use lazy_static::lazy_static;
+use regex::Regex;
+
+#[rustfmt::skip]
+#[macro_export]
+macro_rules! IPV4OCTET { () => (r"(?:25[0-5]|(?:2[0-4]|1[0-9]|[1-9])?[0-9])") }
+#[rustfmt::skip]
+#[macro_export]
+macro_rules! IPV6H16 { () => (r"(?:[0-9a-fA-F]{1,4})") }
+#[rustfmt::skip]
+#[macro_export]
+macro_rules! IPV6LS32 { () => (concat!(r"(?:(?:", IPV4RE!(), "|", IPV6H16!(), ":", IPV6H16!(), "))" )) }
+
+/// Returns the regular expression string to match IPv4 addresses
+#[rustfmt::skip]
+#[macro_export]
+macro_rules! IPV4RE { () => (concat!(r"(?:(?:", IPV4OCTET!(), r"\.){3}", IPV4OCTET!(), ")")) }
+
+/// Returns the regular expression string to match IPv6 addresses
+#[rustfmt::skip]
+#[macro_export]
+macro_rules! IPV6RE { () => (concat!(r"(?:",
+    r"(?:(?:",                                               r"(?:", IPV6H16!(), r":){6})", IPV6LS32!(), r")|",
+    r"(?:(?:",                                             r"::(?:", IPV6H16!(), r":){5})", IPV6LS32!(), r")|",
+    r"(?:(?:(?:",                            IPV6H16!(), r")?::(?:", IPV6H16!(), r":){4})", IPV6LS32!(), r")|",
+    r"(?:(?:(?:(?:", IPV6H16!(), r":){0,1}", IPV6H16!(), r")?::(?:", IPV6H16!(), r":){3})", IPV6LS32!(), r")|",
+    r"(?:(?:(?:(?:", IPV6H16!(), r":){0,2}", IPV6H16!(), r")?::(?:", IPV6H16!(), r":){2})", IPV6LS32!(), r")|",
+    r"(?:(?:(?:(?:", IPV6H16!(), r":){0,3}", IPV6H16!(), r")?::(?:", IPV6H16!(), r":){1})", IPV6LS32!(), r")|",
+    r"(?:(?:(?:(?:", IPV6H16!(), r":){0,4}", IPV6H16!(), r")?::",                      ")", IPV6LS32!(), r")|",
+    r"(?:(?:(?:(?:", IPV6H16!(), r":){0,5}", IPV6H16!(), r")?::",                      ")", IPV6H16!(),  r")|",
+    r"(?:(?:(?:(?:", IPV6H16!(), r":){0,6}", IPV6H16!(), r")?::",                                        ")))"))
+}
+
+/// Returns the regular expression string to match IP addresses (v4 or v6)
+#[rustfmt::skip]
+#[macro_export]
+macro_rules! IPRE { () => (concat!(r"(?:", IPV4RE!(), "|", IPV6RE!(), ")")) }
+
+/// Regular expression string to match IP addresses where IPv6 addresses require brackets around
+/// them, while for IPv4 they are forbidden.
+#[rustfmt::skip]
+#[macro_export]
+macro_rules! IPRE_BRACKET { () => (
+    concat!(r"(?:",
+        IPV4RE!(),
+        r"|\[(?:",
+            IPV6RE!(),
+        r")\]",
+    r")"))
+}
+
+lazy_static! {
+    pub static ref IP_REGEX: Regex = Regex::new(concat!(r"^", IPRE!(), r"$")).unwrap();
+    pub static ref IP_BRACKET_REGEX: Regex =
+        Regex::new(concat!(r"^", IPRE_BRACKET!(), r"$")).unwrap();
+    pub static ref SHA256_HEX_REGEX: Regex = Regex::new(r"^[a-f0-9]{64}$").unwrap();
+    pub static ref SYSTEMD_DATETIME_REGEX: Regex =
+        Regex::new(r"^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}(:\d{2})?)?$").unwrap();
+}
+
+#[test]
+fn test_regexes() {
+    assert!(IP_REGEX.is_match("127.0.0.1"));
+    assert!(IP_REGEX.is_match("::1"));
+    assert!(IP_REGEX.is_match("2014:b3a::27"));
+    assert!(IP_REGEX.is_match("2014:b3a::192.168.0.1"));
+    assert!(IP_REGEX.is_match("2014:b3a:0102:adf1:1234:4321:4afA:BCDF"));
+
+    assert!(IP_BRACKET_REGEX.is_match("127.0.0.1"));
+    assert!(IP_BRACKET_REGEX.is_match("[::1]"));
+    assert!(IP_BRACKET_REGEX.is_match("[2014:b3a::27]"));
+    assert!(IP_BRACKET_REGEX.is_match("[2014:b3a::192.168.0.1]"));
+    assert!(IP_BRACKET_REGEX.is_match("[2014:b3a:0102:adf1:1234:4321:4afA:BCDF]"));
+}
index 6f931f8f2c15845e4677030a5eef21a8c6d63cf3..bd817034ba5f55c571e9c26d7e76022aa67f8eb3 100644 (file)
@@ -51,7 +51,8 @@ impl std::str::FromStr for Fingerprint {
     fn from_str(s: &str) -> Result<Self, Error> {
         let mut tmp = s.to_string();
         tmp.retain(|c| c != ':');
-        let bytes = proxmox::tools::hex_to_digest(&tmp)?;
+        let mut bytes = [0u8; 32];
+        hex::decode_to_slice(&tmp, &mut bytes)?;
         Ok(Fingerprint::new(bytes))
     }
 }
index 895f029b885af9b865f4afee55846534fbe653ff..e5969875f9303bd8aab3cf4592f728ad1f054459 100644 (file)
@@ -216,8 +216,8 @@ impl std::str::FromStr for HumanByte {
     }
 }
 
-proxmox::forward_deserialize_to_from_str!(HumanByte);
-proxmox::forward_serialize_to_display!(HumanByte);
+proxmox_serde::forward_deserialize_to_from_str!(HumanByte);
+proxmox_serde::forward_serialize_to_display!(HumanByte);
 
 #[test]
 fn test_human_byte_parser() -> Result<(), Error> {
index fe2383a51ca33ce4293c665f6bad9614389ac859..d6479a98a6ca835afd849484b2e3c2710c03b5eb 100644 (file)
@@ -365,8 +365,8 @@ impl std::fmt::Display for GroupFilter {
     }
 }
 
-proxmox::forward_deserialize_to_from_str!(GroupFilter);
-proxmox::forward_serialize_to_display!(GroupFilter);
+proxmox_serde::forward_deserialize_to_from_str!(GroupFilter);
+proxmox_serde::forward_serialize_to_display!(GroupFilter);
 
 fn verify_group_filter(input: &str) -> Result<(), anyhow::Error> {
     GroupFilter::from_str(input).map(|_| ())
index a28ddafd071f9bb55ff270f6ad9463856565dafd..bb5d152fb37783a6db815b1daf16171af14c0395 100644 (file)
@@ -3,10 +3,11 @@
 use serde::{Deserialize, Serialize};
 use anyhow::bail;
 
+pub mod common_regex;
+
 use proxmox_schema::{
     api, const_regex, ApiStringFormat, ApiType, ArraySchema, Schema, StringSchema, ReturnType,
 };
-use proxmox::{IPRE, IPRE_BRACKET, IPV4OCTET, IPV4RE, IPV6H16, IPV6LS32, IPV6RE};
 use proxmox_time::parse_daily_duration;
 
 #[rustfmt::skip]
@@ -199,7 +200,7 @@ pub const DNS_NAME_OR_IP_SCHEMA: Schema = StringSchema::new("DNS name or IP addr
 
 pub const NODE_SCHEMA: Schema = StringSchema::new("Node name (or 'localhost')")
     .format(&ApiStringFormat::VerifyFn(|node| {
-        if node == "localhost" || node == proxmox::tools::nodename() {
+        if node == "localhost" || node == proxmox_sys::nodename() {
             Ok(())
         } else {
             bail!("no such node '{}'", node);
index 15c336b78163d50cdc8b215c1c2944bc5cf09927..b7cee5d3c2a00717b6b41ced44ba342a7bda6695 100644 (file)
@@ -79,7 +79,7 @@ pub struct Remote {
     pub name: String,
     // Note: The stored password is base64 encoded
     #[serde(skip_serializing_if="String::is_empty")]
-    #[serde(with = "proxmox::tools::serde::string_as_base64")]
+    #[serde(with = "proxmox_serde::string_as_base64")]
     pub password: String,
     #[serde(flatten)]
     pub config: RemoteConfig,
index a05f11567f673f9b776a0a2b3d7a542db76023d9..496bd0004151df18843102affa62d0e626e52d14 100644 (file)
@@ -22,8 +22,8 @@ pub enum MediaLocation {
     Vault(String),
 }
 
-proxmox::forward_deserialize_to_from_str!(MediaLocation);
-proxmox::forward_serialize_to_display!(MediaLocation);
+proxmox_serde::forward_deserialize_to_from_str!(MediaLocation);
+proxmox_serde::forward_serialize_to_display!(MediaLocation);
 
 impl proxmox_schema::ApiType for MediaLocation {
     const API_SCHEMA: Schema = StringSchema::new(
index 8c58da2e0f58a9f3ac9493d249fdd69b4c39960f..60137d2a56c2180fd20485b5d9d90edf58040935 100644 (file)
@@ -685,8 +685,8 @@ fn test_token_id() {
     assert_eq!(auth_id.to_string(), "test@pam!bar".to_string());
 }
 
-proxmox::forward_deserialize_to_from_str!(Userid);
-proxmox::forward_serialize_to_display!(Userid);
+proxmox_serde::forward_deserialize_to_from_str!(Userid);
+proxmox_serde::forward_serialize_to_display!(Userid);
 
-proxmox::forward_deserialize_to_from_str!(Authid);
-proxmox::forward_serialize_to_display!(Authid);
+proxmox_serde::forward_deserialize_to_from_str!(Authid);
+proxmox_serde::forward_serialize_to_display!(Authid);
index 076219f3f8995c20bafdec53ba3bff76cc06d9d7..a1b5df4455cb5be37b2502f11aa6463c29dfd50c 100644 (file)
@@ -10,6 +10,7 @@ anyhow = "1.0"
 bitflags = "1.2.1"
 bytes = "1.0"
 futures = "0.3"
+hex = "0.4.3"
 h2 = { version = "0.3", features = [ "stream" ] }
 http = "0.2"
 hyper = { version = "0.14", features = [ "full" ] }
@@ -28,15 +29,17 @@ tower-service = "0.3.0"
 xdg = "2.2"
 
 pathpatterns = "0.1.2"
-proxmox = "0.15.3"
-proxmox-async = "0.2"
+
+proxmox-async = "0.3"
 proxmox-fuse = "0.1.1"
-proxmox-http = { version = "0.5.4", features = [ "client", "http-helpers", "websocket" ] }
+proxmox-http = { version = "0.6", features = [ "client", "http-helpers", "websocket" ] }
 proxmox-io = { version = "1", features = [ "tokio" ] }
 proxmox-lang = "1"
 proxmox-router = { version = "1.1", features = [ "cli" ] }
 proxmox-schema = "1"
 proxmox-time = "1"
+proxmox-sys = "0.2"
+
 pxar = { version = "0.10.1", features = [ "tokio-io" ] }
 
 pbs-api-types = { path = "../pbs-api-types" }
index 5da5616c0c4d01cbfa99deb2d4ab3882f07fb501..0f39a395ef8da54cd16bfb67a6b4d092632d7c1d 100644 (file)
@@ -7,8 +7,6 @@ use std::os::unix::fs::OpenOptionsExt;
 use futures::future::AbortHandle;
 use serde_json::{json, Value};
 
-use proxmox::tools::digest_to_hex;
-
 use pbs_tools::crypt_config::CryptConfig;
 use pbs_tools::sha::sha256;
 use pbs_datastore::{PROXMOX_BACKUP_READER_PROTOCOL_ID_V1, BackupManifest};
@@ -121,7 +119,7 @@ impl BackupReader {
         output: W,
     ) -> Result<(), Error> {
         let path = "chunk";
-        let param = json!({ "digest": digest_to_hex(digest) });
+        let param = json!({ "digest": hex::encode(digest) });
         self.h2.download(path, Some(param), output).await
     }
 
index e44474c3ce79bf80eb75c6b5fde5f92655a959c4..000b7eb74fe3b311f29dbea4e148738c150c4ced 100644 (file)
@@ -12,8 +12,6 @@ use tokio::io::AsyncReadExt;
 use tokio::sync::{mpsc, oneshot};
 use tokio_stream::wrappers::ReceiverStream;
 
-use proxmox::tools::digest_to_hex;
-
 use pbs_api_types::HumanByte;
 use pbs_tools::crypt_config::CryptConfig;
 use pbs_datastore::{CATALOG_NAME, PROXMOX_BACKUP_PROTOCOL_ID_V1};
@@ -389,7 +387,7 @@ impl BackupWriter {
             "wid": wid ,
             "chunk-count": upload_stats.chunk_count,
             "size": upload_stats.size,
-            "csum": proxmox::tools::digest_to_hex(&upload_stats.csum),
+            "csum": hex::encode(&upload_stats.csum),
         });
         let _value = self.h2.post(&close_path, Some(param)).await?;
         Ok(BackupStats {
@@ -481,7 +479,7 @@ impl BackupWriter {
                             let mut digest_list = vec![];
                             let mut offset_list = vec![];
                             for (offset, digest) in chunk_list {
-                                digest_list.push(digest_to_hex(&digest));
+                                digest_list.push(hex::encode(&digest));
                                 offset_list.push(offset);
                             }
                             if verbose { println!("append chunks list len ({})", digest_list.len()); }
@@ -712,7 +710,7 @@ impl BackupWriter {
                 if let MergedChunkInfo::New(chunk_info) = merged_chunk_info {
                     let offset = chunk_info.offset;
                     let digest = chunk_info.digest;
-                    let digest_str = digest_to_hex(&digest);
+                    let digest_str = hex::encode(&digest);
 
                     /* too verbose, needs finer verbosity setting granularity
                     if verbose {
index aab4c98966cb5b518b5d36b9740736bbc9306d75..007d23465bb34d3225177f639284d2bcfbc1051d 100644 (file)
@@ -14,7 +14,7 @@ use nix::fcntl::OFlag;
 use nix::sys::stat::Mode;
 
 use pathpatterns::{MatchEntry, MatchList, MatchPattern, MatchType, PatternFlag};
-use proxmox::tools::fs::{create_path, CreateOptions};
+use proxmox_sys::fs::{create_path, CreateOptions};
 use proxmox_router::cli::{self, CliCommand, CliCommandMap, CliHelper, CommandLineInterface};
 use proxmox_schema::api;
 use pxar::{EntryKind, Metadata};
index a91b5e005a1d8121aa4c24ccec8a639f2893b816..30099b38ddeb7b29af315cc5520d3b36f95fb7ea 100644 (file)
@@ -14,10 +14,8 @@ use serde_json::{json, Value};
 use percent_encoding::percent_encode;
 use xdg::BaseDirectories;
 
-use proxmox::{
-    sys::linux::tty,
-    tools::fs::{file_get_json, replace_file, CreateOptions},
-};
+use proxmox_sys::linux::tty;
+use proxmox_sys::fs::{file_get_json, replace_file, CreateOptions};
 use proxmox_router::HttpError;
 
 use proxmox_http::client::{HttpsConnector, RateLimiter};
@@ -521,7 +519,7 @@ impl HttpClient {
             Ok(fp) => fp,
             Err(err) => bail!("failed to calculate certificate FP - {}", err), // should not happen
         };
-        let fp_string = proxmox::tools::digest_to_hex(&fp);
+        let fp_string = hex::encode(&fp);
         let fp_string = fp_string.as_bytes().chunks(2).map(|v| std::str::from_utf8(v).unwrap())
             .collect::<Vec<&str>>().join(":");
 
index 4ad2925830d43efa271f92c0f075650328c996f9..f705e39984ece676267450610ccc216d82f031bb 100644 (file)
@@ -19,14 +19,14 @@ use pathpatterns::{MatchEntry, MatchFlag, MatchList, MatchType, PatternFlag};
 use pxar::Metadata;
 use pxar::encoder::{SeqWrite, LinkOffset};
 
-use proxmox::sys::error::SysError;
-use proxmox::tools::fd::RawFdNum;
-use proxmox::tools::fd::Fd;
+use proxmox_sys::error::SysError;
+use proxmox_sys::fd::RawFdNum;
+use proxmox_sys::fd::Fd;
+use proxmox_sys::fs::{self, acl, xattr};
 use proxmox_io::vec;
 use proxmox_lang::c_str;
 
 use pbs_datastore::catalog::BackupCatalogWriter;
-use pbs_tools::{acl, fs, xattr};
 use pbs_tools::str::strip_ascii_whitespace;
 
 use crate::pxar::metadata::errno_is_unsupported;
@@ -60,7 +60,7 @@ fn detect_fs_type(fd: RawFd) -> Result<i64, Error> {
 
 #[rustfmt::skip]
 pub fn is_virtual_file_system(magic: i64) -> bool {
-    use proxmox::sys::linux::magic::*;
+    use proxmox_sys::linux::magic::*;
 
     matches!(magic, BINFMTFS_MAGIC |
         CGROUP2_SUPER_MAGIC |
@@ -855,7 +855,7 @@ fn get_chattr(metadata: &mut Metadata, fd: RawFd) -> Result<(), Error> {
 }
 
 fn get_fat_attr(metadata: &mut Metadata, fd: RawFd, fs_magic: i64) -> Result<(), Error> {
-    use proxmox::sys::linux::magic::*;
+    use proxmox_sys::linux::magic::*;
 
     if fs_magic != MSDOS_SUPER_MAGIC && fs_magic != FUSE_SUPER_MAGIC {
         return Ok(());
@@ -891,7 +891,7 @@ fn get_quota_project_id(
         return Ok(());
     }
 
-    use proxmox::sys::linux::magic::*;
+    use proxmox_sys::linux::magic::*;
 
     match magic {
         EXT4_SUPER_MAGIC | XFS_SUPER_MAGIC | FUSE_SUPER_MAGIC | ZFS_SUPER_MAGIC => (),
index 86740ffd4e0089adb285b6e0ce5f5f259d9f5661..a2d35a59234ee26d1ffcefbc4e4777e4387f316a 100644 (file)
@@ -7,8 +7,8 @@ use nix::dir::Dir;
 use nix::fcntl::OFlag;
 use nix::sys::stat::{mkdirat, Mode};
 
-use proxmox::sys::error::SysError;
-use proxmox::tools::fd::BorrowedFd;
+use proxmox_sys::error::SysError;
+use proxmox_sys::fd::BorrowedFd;
 use pxar::Metadata;
 
 use crate::pxar::tools::{assert_single_path_component, perms_from_metadata};
index 350f96cf112604d9f4ba575bd94a7d284a6f60bf..8c85dd022188792b6a84276b9aea94ea9ba77ab6 100644 (file)
@@ -21,8 +21,8 @@ use pxar::decoder::aio::Decoder;
 use pxar::format::Device;
 use pxar::{Entry, EntryKind, Metadata};
 
-use proxmox::c_result;
-use proxmox::tools::fs::{create_path, CreateOptions};
+use proxmox_sys::c_result;
+use proxmox_sys::fs::{create_path, CreateOptions};
 use proxmox_io::{sparse_copy, sparse_copy_async};
 
 use proxmox_async::zip::{ZipEncoder, ZipEntry};
index eca5ee97ad0e8fe877bff5087aed04a6e4671d4c..78940ada5fd51f14a54299ac86534d90821a82c8 100644 (file)
@@ -255,7 +255,7 @@ impl Flags {
 
     /// Return the supported *pxar* feature flags based on the magic number of the filesystem.
     pub fn from_magic(magic: i64) -> Flags {
-        use proxmox::sys::linux::magic::*;
+        use proxmox_sys::linux::magic::*;
         match magic {
             MSDOS_SUPER_MAGIC => {
                 Flags::WITH_2SEC_TIME |
index e8bb89ff45e97ce8400c4b0cf7fb2de921caeb47..8801c8f3444fea8eb3e6f81e30be80e00794381f 100644 (file)
@@ -25,8 +25,7 @@ use pxar::accessor::{self, EntryRangeInfo, ReadAt};
 
 use proxmox_fuse::requests::{self, FuseRequest};
 use proxmox_fuse::{EntryParam, Fuse, ReplyBufState, Request, ROOT_ID};
-
-use pbs_tools::xattr;
+use proxmox_sys::fs::xattr;
 
 /// We mark inodes for regular files this way so we know how to access them.
 const NON_DIRECTORY_INODE: u64 = 1u64 << 63;
index 2d27270a44a78984adae1f2e518247ddab29b294..e402a362ed6f81ea8c1629d151dcc5c278a7da46 100644 (file)
@@ -9,11 +9,10 @@ use nix::sys::stat::Mode;
 
 use pxar::Metadata;
 
-use proxmox::c_result;
-use proxmox::sys::error::SysError;
-use proxmox::tools::fd::RawFdNum;
-
-use pbs_tools::{acl, fs, xattr};
+use proxmox_sys::c_result;
+use proxmox_sys::error::SysError;
+use proxmox_sys::fd::RawFdNum;
+use proxmox_sys::fs::{self, acl, xattr};
 
 use crate::pxar::tools::perms_from_metadata;
 use crate::pxar::Flags;
@@ -67,7 +66,7 @@ pub fn apply_at(
     path_info: &Path,
     on_error: &mut (dyn FnMut(Error) -> Result<(), Error> + Send),
 ) -> Result<(), Error> {
-    let fd = proxmox::tools::fd::Fd::openat(
+    let fd = proxmox_sys::fd::Fd::openat(
         &unsafe { RawFdNum::from_raw_fd(parent) },
         file_name,
         OFlag::O_PATH | OFlag::O_CLOEXEC | OFlag::O_NOFOLLOW,
index 8fb24bd104646ff548c4c0da67e6398a27b3b6f0..1b1f7828e1e39c7093ff887e3424662f0013a4d4 100644 (file)
@@ -6,8 +6,8 @@ use std::io::Read;
 use anyhow::{bail, format_err, Error};
 use serde_json::Value;
 
-use proxmox::sys::linux::tty;
-use proxmox::tools::fs::file_get_contents;
+use proxmox_sys::linux::tty;
+use proxmox_sys::fs::file_get_contents;
 use proxmox_schema::*;
 
 use pbs_api_types::CryptMode;
@@ -374,7 +374,7 @@ fn create_testdir(name: &str) -> Result<String, Error> {
 // safe w.r.t. concurrency
 fn test_crypto_parameters_handling() -> Result<(), Error> {
     use serde_json::json;
-    use proxmox::tools::fs::{replace_file, CreateOptions};
+    use proxmox_sys::fs::{replace_file, CreateOptions};
 
     let some_key = vec![1;1];
     let default_key = vec![2;1];
index f7a253dff6bcf86fa3aa3058745d0ae09eaa9758..92562068ba5dd0e5465a0cd866628021e8bb3fbc 100644 (file)
@@ -12,7 +12,7 @@ use xdg::BaseDirectories;
 
 use proxmox_schema::*;
 use proxmox_router::cli::{complete_file_name, shellword_split};
-use proxmox::tools::fs::file_get_json;
+use proxmox_sys::fs::file_get_json;
 
 use pbs_api_types::{BACKUP_REPO_URL, Authid, RateLimitConfig, UserWithTokens};
 use pbs_datastore::BackupDir;
@@ -100,7 +100,7 @@ pub fn get_secret_from_env(base_name: &str) -> Result<Option<String>, Error> {
             let args = shellword_split(command)?;
             let mut command = Command::new(&args[0]);
             command.args(&args[1..]);
-            let output = pbs_tools::run_command(command, None)?;
+            let output = proxmox_sys::command::run_command(command, None)?;
             return Ok(Some(firstline(output)));
         }
         Err(NotUnicode(_)) => bail!(format!("{} contains bad characters", env_name)),
index 19ff93bb8d4067cc55dc93bb7feaaee7077e9045..cd14d8230ae846714b7bd49038d6f1f89a69bb29 100644 (file)
@@ -17,14 +17,14 @@ regex = "1.2"
 serde = { version = "1.0", features = ["derive"] }
 serde_json = "1.0"
 
-proxmox = "0.15.3"
 proxmox-lang = "1"
 proxmox-router = { version = "1.1", default-features = false }
 proxmox-schema = "1"
 proxmox-section-config = "1"
 proxmox-time = "1"
-proxmox-shared-memory = "0.1.1"
-proxmox-sys = "0.1.2"
+proxmox-serde = "0.1"
+proxmox-shared-memory = "0.2"
+proxmox-sys = "0.2"
 
 pbs-api-types = { path = "../pbs-api-types" }
 pbs-buildcfg = { path = "../pbs-buildcfg" }
index 76ba84e913a8f657e1007396b71193c1bf011c87..c0d181d61098477d455261e0d4d239b1e75086bf 100644 (file)
@@ -7,7 +7,7 @@ use anyhow::{bail, Error};
 use once_cell::sync::OnceCell;
 use nix::sys::stat::Mode;
 
-use proxmox::tools::fs::{create_path, CreateOptions};
+use proxmox_sys::fs::{create_path, CreateOptions};
 
 // openssl::sha::sha256(b"Proxmox Backup ConfigVersionCache v1.0")[0..8];
 pub const PROXMOX_BACKUP_CONFIG_VERSION_CACHE_MAGIC_1_0: [u8; 8] = [25, 198, 168, 230, 154, 132, 143, 131];
index 953551d295811017029a58be2ed758b7852208be..b47b05e2767bb90b4b1e47de74fd781df0da0b88 100644 (file)
@@ -36,7 +36,7 @@ pub fn lock_config() -> Result<BackupLockGuard, Error> {
 
 pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
 
-    let content = proxmox::tools::fs::file_read_optional_string(DATASTORE_CFG_FILENAME)?
+    let content = proxmox_sys::fs::file_read_optional_string(DATASTORE_CFG_FILENAME)?
         .unwrap_or_else(|| "".to_string());
 
     let digest = openssl::sha::sha256(content.as_bytes());
index 3a8921a6caf6ae92faebb5f3bbce5fdace73b517..7b6b3768366b0c2e142601835687bdd89a98a773 100644 (file)
@@ -37,7 +37,7 @@ pub fn lock_config() -> Result<BackupLockGuard, Error> {
 
 pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
 
-    let content = proxmox::tools::fs::file_read_optional_string(DOMAINS_CFG_FILENAME)?
+    let content = proxmox_sys::fs::file_read_optional_string(DOMAINS_CFG_FILENAME)?
         .unwrap_or_else(|| "".to_string());
 
     let digest = openssl::sha::sha256(content.as_bytes());
index b800cd8bec8f8f8dcdb5b6707351df1aed7dd7c8..c37bf673def12a46af39b69b188da611ba652390 100644 (file)
@@ -71,7 +71,7 @@ pub fn lock() -> Result<BackupLockGuard, Error> {
 /// Read and parse the configuration file
 pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
 
-    let content = proxmox::tools::fs::file_read_optional_string(DRIVE_CFG_FILENAME)?
+    let content = proxmox_sys::fs::file_read_optional_string(DRIVE_CFG_FILENAME)?
         .unwrap_or_else(|| "".to_string());
 
     let digest = openssl::sha::sha256(content.as_bytes());
index 8c20cff374c18f28058f08dc512834b45d3c830c..47a096dd03576a72f8521a2897893144c8490269 100644 (file)
@@ -4,7 +4,7 @@ use std::path::Path;
 use anyhow::{bail, format_err, Context, Error};
 use serde::{Deserialize, Serialize};
 
-use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
+use proxmox_sys::fs::{file_get_contents, replace_file, CreateOptions};
 use proxmox_lang::try_block;
 
 use pbs_api_types::{Kdf, KeyInfo, Fingerprint};
@@ -18,12 +18,12 @@ pub enum KeyDerivationConfig {
         n: u64,
         r: u64,
         p: u64,
-        #[serde(with = "proxmox::tools::serde::bytes_as_base64")]
+        #[serde(with = "proxmox_serde::bytes_as_base64")]
         salt: Vec<u8>,
     },
     PBKDF2 {
         iter: usize,
-        #[serde(with = "proxmox::tools::serde::bytes_as_base64")]
+        #[serde(with = "proxmox_serde::bytes_as_base64")]
         salt: Vec<u8>,
     },
 }
@@ -72,11 +72,11 @@ impl KeyDerivationConfig {
 #[derive(Deserialize, Serialize, Clone, Debug)]
 pub struct KeyConfig {
     pub kdf: Option<KeyDerivationConfig>,
-    #[serde(with = "proxmox::tools::serde::epoch_as_rfc3339")]
+    #[serde(with = "proxmox_serde::epoch_as_rfc3339")]
     pub created: i64,
-    #[serde(with = "proxmox::tools::serde::epoch_as_rfc3339")]
+    #[serde(with = "proxmox_serde::epoch_as_rfc3339")]
     pub modified: i64,
-    #[serde(with = "proxmox::tools::serde::bytes_as_base64")]
+    #[serde(with = "proxmox_serde::bytes_as_base64")]
     pub data: Vec<u8>,
     #[serde(skip_serializing_if = "Option::is_none")]
     #[serde(default)]
@@ -111,7 +111,7 @@ impl KeyConfig  {
     /// Creates a new key using random data, protected by passphrase.
     pub fn new(passphrase: &[u8], kdf: Kdf) -> Result<([u8;32], Self), Error> {
         let mut key = [0u8; 32];
-        proxmox::sys::linux::fill_with_random_data(&mut key)?;
+        proxmox_sys::linux::fill_with_random_data(&mut key)?;
         let key_config = Self::with_key(&key, passphrase, kdf)?;
         Ok((key, key_config))
     }
@@ -144,7 +144,7 @@ impl KeyConfig  {
             bail!("got strange key length ({} != 32)", raw_key.len())
         }
 
-        let salt = proxmox::sys::linux::random_data(32)?;
+        let salt = proxmox_sys::linux::random_data(32)?;
 
         let kdf = match kdf {
             Kdf::Scrypt => KeyDerivationConfig::Scrypt {
@@ -166,7 +166,7 @@ impl KeyConfig  {
 
         let cipher = openssl::symm::Cipher::aes_256_gcm();
 
-        let iv = proxmox::sys::linux::random_data(16)?;
+        let iv = proxmox_sys::linux::random_data(16)?;
         let mut tag = [0u8; 16];
 
         let encrypted_key = openssl::symm::encrypt_aead(
index ba1289ede4754805fd1f4f0ef600cdb11ea51faf..b68b1bde11625969f590b10bf81995f350c6ad2f 100644 (file)
@@ -55,14 +55,14 @@ pub fn open_backup_lockfile<P: AsRef<std::path::Path>>(
     exclusive: bool,
 ) -> Result<BackupLockGuard, Error> {
     let user = backup_user()?;
-    let options = proxmox::tools::fs::CreateOptions::new()
+    let options = proxmox_sys::fs::CreateOptions::new()
         .perm(nix::sys::stat::Mode::from_bits_truncate(0o660))
         .owner(user.uid)
         .group(user.gid);
 
     let timeout = timeout.unwrap_or(std::time::Duration::new(10, 0));
 
-    let file = proxmox::tools::fs::open_file_locked(&path, timeout, exclusive, options)?;
+    let file = proxmox_sys::fs::open_file_locked(&path, timeout, exclusive, options)?;
     Ok(BackupLockGuard(Some(file)))
 }
 
@@ -77,12 +77,12 @@ pub fn replace_backup_config<P: AsRef<std::path::Path>>(
     let mode = nix::sys::stat::Mode::from_bits_truncate(0o0640);
     // set the correct owner/group/permissions while saving file
     // owner(rw) = root, group(r)= backup
-    let options = proxmox::tools::fs::CreateOptions::new()
+    let options = proxmox_sys::fs::CreateOptions::new()
         .perm(mode)
         .owner(nix::unistd::ROOT)
         .group(backup_user.gid);
 
-    proxmox::tools::fs::replace_file(path, data, options, true)?;
+    proxmox_sys::fs::replace_file(path, data, options, true)?;
 
     Ok(())
 }
@@ -97,12 +97,12 @@ pub fn replace_secret_config<P: AsRef<std::path::Path>>(
     let mode = nix::sys::stat::Mode::from_bits_truncate(0o0600);
     // set the correct owner/group/permissions while saving file
     // owner(rw) = root, group(r)= root
-    let options = proxmox::tools::fs::CreateOptions::new()
+    let options = proxmox_sys::fs::CreateOptions::new()
         .perm(mode)
         .owner(nix::unistd::ROOT)
         .group(nix::unistd::Gid::from_raw(0));
 
-    proxmox::tools::fs::replace_file(path, data, options, true)?;
+    proxmox_sys::fs::replace_file(path, data, options, true)?;
 
     Ok(())
 }
index 5193061ae7bc9ef207aa65eb6163d41ac360f15e..c07af123d33b079ffada1163a252ab37b16d6900 100644 (file)
@@ -49,7 +49,7 @@ pub fn lock() -> Result<BackupLockGuard, Error> {
 /// Read and parse the configuration file
 pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
 
-    let content = proxmox::tools::fs::file_read_optional_string(MEDIA_POOL_CFG_FILENAME)?
+    let content = proxmox_sys::fs::file_read_optional_string(MEDIA_POOL_CFG_FILENAME)?
         .unwrap_or_else(|| "".to_string());
 
     let digest = openssl::sha::sha256(content.as_bytes());
index 1bf7c08f7a548e6feda61970595da739efbca992..58d6339e4f7fd21d1eb2c11ba57648a8142d2cab 100644 (file)
@@ -9,8 +9,9 @@ use nix::ioctl_read_bad;
 use nix::sys::socket::{socket, AddressFamily, SockType, SockFlag};
 use regex::Regex;
 
-use proxmox::*; // for IP macros
-use proxmox::tools::fd::Fd;
+use pbs_api_types::*; // for IP macros
+
+use proxmox_sys::fd::Fd;
 
 pub static IPV4_REVERSE_MASK: &[&str] = &[
     "0.0.0.0",
@@ -188,7 +189,7 @@ pub fn compute_file_diff(filename: &str, shadow: &str) -> Result<String, Error>
         .output()
         .map_err(|err| format_err!("failed to execute diff - {}", err))?;
 
-    let diff = pbs_tools::command_output_as_string(output, Some(|c| c == 0 || c == 1))
+    let diff = proxmox_sys::command::command_output_as_string(output, Some(|c| c == 0 || c == 1))
         .map_err(|err| format_err!("diff failed: {}", err))?;
 
     Ok(diff)
@@ -209,7 +210,7 @@ pub fn network_reload() -> Result<(), Error> {
         .output()
         .map_err(|err| format_err!("failed to execute 'ifreload' - {}", err))?;
 
-    pbs_tools::command_output(output, None)
+    proxmox_sys::command::command_output(output, None)
         .map_err(|err| format_err!("ifreload failed: {}", err))?;
 
 
index 1c10ab31dd5989ce8fa9cd8f23d85ff50e844fac..a71be54bc3baabfaeafabbe0fb1678d184521492 100644 (file)
@@ -6,7 +6,7 @@ use serde::de::{value, IntoDeserializer, Deserialize};
 use lazy_static::lazy_static;
 use regex::Regex;
 
-use proxmox::tools::{fs::replace_file, fs::CreateOptions};
+use proxmox_sys::{fs::replace_file, fs::CreateOptions};
 
 mod helper;
 pub use helper::*;
@@ -409,10 +409,10 @@ pub fn lock_config() -> Result<BackupLockGuard, Error> {
 
 pub fn config() -> Result<(NetworkConfig, [u8;32]), Error> {
 
-    let content = match proxmox::tools::fs::file_get_optional_contents(NETWORK_INTERFACES_NEW_FILENAME)? {
+    let content = match proxmox_sys::fs::file_get_optional_contents(NETWORK_INTERFACES_NEW_FILENAME)? {
         Some(content) => content,
         None => {
-            let content = proxmox::tools::fs::file_get_optional_contents(NETWORK_INTERFACES_FILENAME)?;
+            let content = proxmox_sys::fs::file_get_optional_contents(NETWORK_INTERFACES_FILENAME)?;
             content.unwrap_or_default()
         }
     };
index 7cb081ae7569cf316fcd666a7c2644e3a678d9ab..56c097a963469832ea7df5f7a0d654e42d9fa158 100644 (file)
@@ -184,7 +184,7 @@ impl <R: BufRead> NetworkParser<R> {
         self.eat(Token::Gateway)?;
         let gateway = self.next_text()?;
 
-        if proxmox::tools::common_regex::IP_REGEX.is_match(&gateway) {
+        if pbs_api_types::common_regex::IP_REGEX.is_match(&gateway) {
             if gateway.contains(':') {
                 set_gateway_v6(interface, gateway)?;
             } else {
index fb19cb53c90548ea04b30cecd35d51bd45d4af44..a90aa13b81a8d5b54e36550cbb6a069db2726392 100644 (file)
@@ -37,7 +37,7 @@ pub fn lock_config() -> Result<BackupLockGuard, Error> {
 
 pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
 
-    let content = proxmox::tools::fs::file_read_optional_string(REMOTE_CFG_FILENAME)?
+    let content = proxmox_sys::fs::file_read_optional_string(REMOTE_CFG_FILENAME)?
         .unwrap_or_else(|| "".to_string());
 
     let digest = openssl::sha::sha256(content.as_bytes());
index 6331fa3489cfa09d924a2753723ca73f5a674a84..23cf460775f5f0ebcfe2407f2250d7063e0b6984 100644 (file)
@@ -38,7 +38,7 @@ pub fn lock_config() -> Result<BackupLockGuard, Error> {
 
 pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
 
-    let content = proxmox::tools::fs::file_read_optional_string(SYNC_CFG_FILENAME)?
+    let content = proxmox_sys::fs::file_read_optional_string(SYNC_CFG_FILENAME)?
         .unwrap_or_else(|| "".to_string());
 
     let digest = openssl::sha::sha256(content.as_bytes());
index e40975c73db3c4305dce1304c916ea2f17372d59..c1e688ec34f19efc098b92e5c0701801aa90a2de 100644 (file)
@@ -15,7 +15,7 @@ use std::collections::HashMap;
 use anyhow::{bail, Error};
 use serde::{Deserialize, Serialize};
 
-use proxmox::tools::fs::file_read_optional_string;
+use proxmox_sys::fs::file_read_optional_string;
 use pbs_api_types::Fingerprint;
 
 use crate::key_config::KeyConfig;
@@ -23,7 +23,8 @@ use crate::{open_backup_lockfile, replace_secret_config, replace_backup_config};
 
 mod hex_key {
     use serde::{self, Deserialize, Serializer, Deserializer};
-
+    use hex::FromHex;
+    
     pub fn serialize<S>(
         csum: &[u8; 32],
         serializer: S,
@@ -31,7 +32,7 @@ mod hex_key {
     where
         S: Serializer,
     {
-        let s = proxmox::tools::digest_to_hex(csum);
+        let s = hex::encode(csum);
         serializer.serialize_str(&s)
     }
 
@@ -42,7 +43,7 @@ mod hex_key {
         D: Deserializer<'de>,
     {
         let s = String::deserialize(deserializer)?;
-        proxmox::tools::hex_to_digest(&s).map_err(serde::de::Error::custom)
+        <[u8; 32]>::from_hex(&s).map_err(serde::de::Error::custom)
     }
 }
 
index 60084e4f4afca46e10c7b69b3227f77458d5e258..82eda8e10abb9a9bfc0976a39ad88941f56c2c23 100644 (file)
@@ -36,7 +36,7 @@ pub fn lock() -> Result<BackupLockGuard, Error> {
 
 pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
 
-    let content = proxmox::tools::fs::file_read_optional_string(TAPE_JOB_CFG_FILENAME)?
+    let content = proxmox_sys::fs::file_read_optional_string(TAPE_JOB_CFG_FILENAME)?
         .unwrap_or_else(|| "".to_string());
 
     let digest = openssl::sha::sha256(content.as_bytes());
index 0a9d12976c723526b6a6d34a4c5f7cd5b4e3ed5a..a0b08550a1104134872521d863ddc0962ebe28cf 100644 (file)
@@ -4,7 +4,7 @@ use anyhow::{bail, format_err, Error};
 use serde::{Serialize, Deserialize};
 use serde_json::{from_value, Value};
 
-use proxmox::tools::fs::CreateOptions;
+use proxmox_sys::fs::CreateOptions;
 
 use pbs_api_types::Authid;
 //use crate::auth;
@@ -27,7 +27,7 @@ fn lock_config() -> Result<BackupLockGuard, Error> {
 }
 
 fn read_file() -> Result<HashMap<Authid, String>, Error> {
-    let json = proxmox::tools::fs::file_get_json(CONF_FILE, Some(Value::Null))?;
+    let json = proxmox_sys::fs::file_get_json(CONF_FILE, Some(Value::Null))?;
 
     if json == Value::Null {
         Ok(HashMap::new())
@@ -45,7 +45,7 @@ fn write_file(data: HashMap<Authid, String>) -> Result<(), Error> {
         .group(backup_user.gid);
 
     let json = serde_json::to_vec(&data)?;
-    proxmox::tools::fs::replace_file(CONF_FILE, &json, options, true)
+    proxmox_sys::fs::replace_file(CONF_FILE, &json, options, true)
 }
 
 
index 48e2a514759ad69b5d60777a7d44a6de88e6be2a..ac88706947b4c5e9a0166d8b80310ce4e1ac2a1d 100644 (file)
@@ -44,7 +44,7 @@ pub fn lock_config() -> Result<BackupLockGuard, Error> {
 /// Read and parse the configuration file
 pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
 
-    let content = proxmox::tools::fs::file_read_optional_string(TRAFFIC_CONTROL_CFG_FILENAME)?
+    let content = proxmox_sys::fs::file_read_optional_string(TRAFFIC_CONTROL_CFG_FILENAME)?
         .unwrap_or_else(|| "".to_string());
 
     let digest = openssl::sha::sha256(content.as_bytes());
index 0df0a2456e98fa75cfacaa4ab855afde78234a98..ada1cd8d97e0c869da0778450b43343f6501e44a 100644 (file)
@@ -49,7 +49,7 @@ pub fn lock_config() -> Result<BackupLockGuard, Error> {
 
 pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
 
-    let content = proxmox::tools::fs::file_read_optional_string(USER_CFG_FILENAME)?
+    let content = proxmox_sys::fs::file_read_optional_string(USER_CFG_FILENAME)?
         .unwrap_or_else(|| "".to_string());
 
     let digest = openssl::sha::sha256(content.as_bytes());
index f72bfebbcbc93982bb4b9c4c0b01e72f753e88b1..85e4bbfc9bea4a95a0f7accdf1227f93ce11b4fa 100644 (file)
@@ -37,7 +37,7 @@ pub fn lock_config() -> Result<BackupLockGuard, Error> {
 
 pub fn config() -> Result<(SectionConfigData, [u8;32]), Error> {
 
-    let content = proxmox::tools::fs::file_read_optional_string(VERIFICATION_CFG_FILENAME)?;
+    let content = proxmox_sys::fs::file_read_optional_string(VERIFICATION_CFG_FILENAME)?;
     let content = content.unwrap_or_else(String::new);
 
     let digest = openssl::sha::sha256(content.as_bytes());
index de40f0f6cd6765b0ad912ffd4447091c48c3f97d..f4b5b2a97b2c720353b7022af319d277ce2b381a 100644 (file)
@@ -11,6 +11,7 @@ base64 = "0.13"
 crc32fast = "1"
 endian_trait = { version = "0.6", features = [ "arrays" ] }
 futures = "0.3"
+hex = "0.4.3"
 lazy_static = "1.4"
 libc = "0.2"
 log = "0.4"
@@ -25,14 +26,13 @@ zstd = { version = "0.6", features = [ "bindgen" ] }
 pathpatterns = "0.1.2"
 pxar = "0.10.1"
 
-proxmox = "0.15.3"
 proxmox-borrow = "1"
 proxmox-io = "1"
 proxmox-lang = "1"
 proxmox-schema = { version = "1", features = [ "api-macro" ] }
 proxmox-time = "1"
 proxmox-uuid = "1"
-proxmox-sys = "0.1.2"
+proxmox-sys = "0.2"
 
 pbs-api-types = { path = "../pbs-api-types" }
 pbs-tools = { path = "../pbs-tools" }
index 9f56e9244c62e75c45bb7a08d40af5e5b58fbcc1..81933b0851515c58ab51474f81674f39365024a5 100644 (file)
@@ -81,7 +81,7 @@ impl BackupGroup {
         let mut path = base_path.to_owned();
         path.push(self.group_path());
 
-        pbs_tools::fs::scandir(
+        proxmox_sys::fs::scandir(
             libc::AT_FDCWD,
             &path,
             &BACKUP_DATE_REGEX,
@@ -110,7 +110,7 @@ impl BackupGroup {
         let mut path = base_path.to_owned();
         path.push(self.group_path());
 
-        pbs_tools::fs::scandir(
+        proxmox_sys::fs::scandir(
             libc::AT_FDCWD,
             &path,
             &BACKUP_DATE_REGEX,
@@ -369,7 +369,7 @@ impl BackupInfo {
     pub fn list_backup_groups(base_path: &Path) -> Result<Vec<BackupGroup>, Error> {
         let mut list = Vec::new();
 
-        pbs_tools::fs::scandir(
+        proxmox_sys::fs::scandir(
             libc::AT_FDCWD,
             base_path,
             &BACKUP_TYPE_REGEX,
@@ -377,7 +377,7 @@ impl BackupInfo {
                 if file_type != nix::dir::Type::Directory {
                     return Ok(());
                 }
-                pbs_tools::fs::scandir(
+                proxmox_sys::fs::scandir(
                     l0_fd,
                     backup_type,
                     &BACKUP_ID_REGEX,
@@ -411,7 +411,7 @@ fn list_backup_files<P: ?Sized + nix::NixPath>(
 ) -> Result<Vec<String>, Error> {
     let mut files = vec![];
 
-    pbs_tools::fs::scandir(dirfd, path, &BACKUP_FILE_REGEX, |_, filename, file_type| {
+    proxmox_sys::fs::scandir(dirfd, path, &BACKUP_FILE_REGEX, |_, filename, file_type| {
         if file_type != nix::dir::Type::File {
             return Ok(());
         }
index 6cbec98ec20c246ede627898697b8418c713d173..1fa2643606cf4214d654fbdb397f2e18dadbf31a 100644 (file)
@@ -10,8 +10,8 @@ use anyhow::Error;
 use futures::ready;
 use tokio::io::{AsyncRead, AsyncSeek, ReadBuf};
 
-use proxmox::io_format_err;
-use proxmox::sys::error::io_err_other;
+use proxmox_sys::io_format_err;
+use proxmox_sys::error::io_err_other;
 
 use pbs_tools::async_lru_cache::{AsyncCacher, AsyncLruCache};
 
index 55155efb4cde23f86330307bc5be0d190b311c09..b2f3ca32564f7e029dc48304b3aa1293a0f815c9 100644 (file)
@@ -5,9 +5,9 @@ use std::sync::{Arc, Mutex};
 
 use anyhow::{bail, format_err, Error};
 
-use proxmox::tools::fs::{CreateOptions, create_path, create_dir};
+use proxmox_sys::fs::{CreateOptions, create_path, create_dir};
 use proxmox_sys::process_locker::{ProcessLocker, ProcessLockSharedGuard, ProcessLockExclusiveGuard};
-use proxmox_sys::worker_task_context::WorkerTaskContext;
+use proxmox_sys::WorkerTaskContext;
 use proxmox_sys::task_log;
 use pbs_api_types::GarbageCollectionStatus;
 
@@ -96,7 +96,7 @@ impl ChunkStore {
 
         // create lock file with correct owner/group
         let lockfile_path = Self::lockfile_path(&base);
-        proxmox::tools::fs::replace_file(lockfile_path, b"", options.clone(), false)?;
+        proxmox_sys::fs::replace_file(lockfile_path, b"", options.clone(), false)?;
 
         // create 64*1024 subdirs
         let mut last_percentage = 0;
@@ -194,7 +194,7 @@ impl ChunkStore {
     pub fn get_chunk_iterator(
         &self,
     ) -> Result<
-        impl Iterator<Item = (Result<pbs_tools::fs::ReadDirEntry, Error>, usize, bool)> + std::iter::FusedIterator,
+        impl Iterator<Item = (Result<proxmox_sys::fs::ReadDirEntry, Error>, usize, bool)> + std::iter::FusedIterator,
         Error
     > {
         use nix::dir::Dir;
@@ -212,7 +212,7 @@ impl ChunkStore {
             })?;
 
         let mut done = false;
-        let mut inner: Option<pbs_tools::fs::ReadDir> = None;
+        let mut inner: Option<proxmox_sys::fs::ReadDir> = None;
         let mut at = 0;
         let mut percentage = 0;
         Ok(std::iter::from_fn(move || {
@@ -256,7 +256,7 @@ impl ChunkStore {
                 let subdir: &str = &format!("{:04x}", at);
                 percentage = (at * 100) / 0x10000;
                 at += 1;
-                match pbs_tools::fs::read_subdir(base_handle.as_raw_fd(), subdir) {
+                match proxmox_sys::fs::read_subdir(base_handle.as_raw_fd(), subdir) {
                     Ok(dir) => {
                         inner = Some(dir);
                         // start reading:
@@ -382,7 +382,7 @@ impl ChunkStore {
         digest: &[u8; 32],
     ) -> Result<(bool, u64), Error> {
 
-        //println!("DIGEST {}", proxmox::tools::digest_to_hex(digest));
+        //println!("DIGEST {}", hex::encode(digest));
 
         let (chunk_path, digest_str) = self.chunk_path(digest);
 
@@ -440,7 +440,7 @@ impl ChunkStore {
         let mut chunk_path = self.chunk_dir.clone();
         let prefix = digest_to_prefix(digest);
         chunk_path.push(&prefix);
-        let digest_str = proxmox::tools::digest_to_hex(digest);
+        let digest_str = hex::encode(digest);
         chunk_path.push(&digest_str);
         (chunk_path, digest_str)
     }
index eb5f136f27ff3a4aad61663539a0378791c7a961..36e27b138d036268e7a41c30f4a6832a12bcddef 100644 (file)
@@ -17,7 +17,7 @@ impl <W: Write> CryptWriter<W> {
 
     pub fn new(writer: W, config: Arc<CryptConfig>) -> Result<Self, Error> {
         let mut iv = [0u8; 16];
-        proxmox::sys::linux::fill_with_random_data(&mut iv)?;
+        proxmox_sys::linux::fill_with_random_data(&mut iv)?;
         let block_size = config.cipher().block_size();
 
         let crypter = config.data_crypter(&iv, openssl::symm::Mode::Encrypt)?;
index 9f956d76c44c050b618edfe579d31093d164867d..7da461e07d02dbb97d9de293809046658565ba2c 100644 (file)
@@ -347,7 +347,7 @@ impl DataBlob {
     ) -> Result<([u8;16], [u8;16]), Error> {
 
         let mut iv = [0u8; 16];
-        proxmox::sys::linux::fill_with_random_data(&mut iv)?;
+        proxmox_sys::linux::fill_with_random_data(&mut iv)?;
 
         let mut tag = [0u8; 16];
 
index 027f1db84b68da685a5c18a2729ae0f4df4d6f38..5a97933e8b9ca53f0ad474b180e9afceaae7bc4c 100644 (file)
@@ -9,13 +9,13 @@ use std::time::Duration;
 use anyhow::{bail, format_err, Error};
 use lazy_static::lazy_static;
 
-use proxmox::tools::fs::{replace_file, file_read_optional_string, CreateOptions};
+use proxmox_sys::fs::{replace_file, file_read_optional_string, CreateOptions};
 use proxmox_sys::process_locker::ProcessLockSharedGuard;
-use proxmox_sys::worker_task_context::WorkerTaskContext;
+use proxmox_sys::WorkerTaskContext;
 use proxmox_sys::{task_log, task_warn};
+use proxmox_sys::fs::{lock_dir_noblock, DirLockGuard};
 
 use pbs_api_types::{UPID, DataStoreConfig, Authid, GarbageCollectionStatus, HumanByte};
-use pbs_tools::fs::{lock_dir_noblock, DirLockGuard};
 use pbs_config::{open_backup_lockfile, BackupLockGuard};
 
 use crate::DataBlob;
@@ -127,7 +127,7 @@ impl DataStore {
     pub fn get_chunk_iterator(
         &self,
     ) -> Result<
-        impl Iterator<Item = (Result<pbs_tools::fs::ReadDirEntry, Error>, usize, bool)>,
+        impl Iterator<Item = (Result<proxmox_sys::fs::ReadDirEntry, Error>, usize, bool)>,
         Error
     > {
         self.chunk_store.get_chunk_iterator()
@@ -199,7 +199,7 @@ impl DataStore {
                 map_err(|err| {
                     format_err!(
                         "fast_index_verification error, stat_chunk {} failed - {}",
-                        proxmox::tools::digest_to_hex(&info.digest),
+                        hex::encode(&info.digest),
                         err,
                     )
                 })?;
@@ -232,7 +232,7 @@ impl DataStore {
         wanted_files.insert(CLIENT_LOG_BLOB_NAME.to_string());
         manifest.files().iter().for_each(|item| { wanted_files.insert(item.filename.clone()); });
 
-        for item in pbs_tools::fs::read_subdir(libc::AT_FDCWD, &full_path)? {
+        for item in proxmox_sys::fs::read_subdir(libc::AT_FDCWD, &full_path)? {
             if let Ok(item) = item {
                 if let Some(file_type) = item.file_type() {
                     if file_type != nix::dir::Type::File { continue; }
@@ -272,7 +272,7 @@ impl DataStore {
 
         let full_path = self.group_path(backup_group);
 
-        let _guard = pbs_tools::fs::lock_dir_noblock(&full_path, "backup group", "possible running backup")?;
+        let _guard = proxmox_sys::fs::lock_dir_noblock(&full_path, "backup group", "possible running backup")?;
 
         log::info!("removing backup group {:?}", full_path);
 
@@ -358,7 +358,7 @@ impl DataStore {
         let mut full_path = self.base_path();
         full_path.push(backup_group.group_path());
         full_path.push("owner");
-        let owner = proxmox::tools::fs::file_read_firstline(full_path)?;
+        let owner = proxmox_sys::fs::file_read_firstline(full_path)?;
         Ok(owner.trim_end().parse()?) // remove trailing newline
     }
 
@@ -525,7 +525,7 @@ impl DataStore {
                 task_warn!(
                     worker,
                     "warning: unable to access non-existent chunk {}, required by {:?}",
-                    proxmox::tools::digest_to_hex(digest),
+                    hex::encode(digest),
                     file_name,
                 );
 
index 56d9b08015a5e43dd5af4946247e3f4c58928f5b..9aa1474cc3dfaa446f986a5355a474d79e930859 100644 (file)
@@ -9,7 +9,7 @@ use std::task::Context;
 
 use anyhow::{bail, format_err, Error};
 
-use proxmox::tools::mmap::Mmap;
+use proxmox_sys::mmap::Mmap;
 use proxmox_io::ReadExt;
 use proxmox_uuid::Uuid;
 use proxmox_sys::process_locker::ProcessLockSharedGuard;
@@ -467,7 +467,7 @@ impl DynamicChunkWriter {
                     chunk_size,
                     (compressed_size * 100) / (chunk_size as u64),
                     is_duplicate,
-                    proxmox::tools::digest_to_hex(&digest)
+                    hex::encode(&digest)
                 );
                 self.index.add_chunk(self.chunk_offset as u64, &digest)?;
                 self.chunk_buffer.truncate(0);
index 72a02793d0865cb3ea9971be21ab7e107acdad9e..21404eed3e6d03e2accc653f2f88b0ba0bbe0bc6 100644 (file)
@@ -424,7 +424,7 @@ impl FixedIndexWriter {
             chunk_len,
             (compressed_size * 100) / (chunk_len as u64),
             is_duplicate,
-            proxmox::tools::digest_to_hex(digest)
+            hex::encode(digest)
         );
 
         if is_duplicate {
index 94e54e765089d4b316302d59849ebfc3cb53f5f7..2aa1d48958992d7ff523b5d8e8d14b2d8de31962 100644 (file)
@@ -18,6 +18,7 @@ pub const ENCRYPTED_KEY_BLOB_NAME: &str = "rsa-encrypted.key.blob";
 
 mod hex_csum {
     use serde::{self, Deserialize, Serializer, Deserializer};
+    use hex::FromHex;
 
     pub fn serialize<S>(
         csum: &[u8; 32],
@@ -26,7 +27,7 @@ mod hex_csum {
     where
         S: Serializer,
     {
-        let s = proxmox::tools::digest_to_hex(csum);
+        let s = hex::encode(csum);
         serializer.serialize_str(&s)
     }
 
@@ -37,7 +38,7 @@ mod hex_csum {
         D: Deserializer<'de>,
     {
         let s = String::deserialize(deserializer)?;
-        proxmox::tools::hex_to_digest(&s).map_err(serde::de::Error::custom)
+        <[u8; 32]>::from_hex(&s).map_err(serde::de::Error::custom)
     }
 }
 
@@ -190,7 +191,7 @@ impl BackupManifest {
 
         if let Some(crypt_config) = crypt_config {
             let sig = self.signature(crypt_config)?;
-            manifest["signature"] = proxmox::tools::digest_to_hex(&sig).into();
+            manifest["signature"] = hex::encode(&sig).into();
             let fingerprint = &Fingerprint::new(crypt_config.fingerprint());
             manifest["unprotected"]["key-fingerprint"] = serde_json::to_value(fingerprint)?;
         }
@@ -240,7 +241,7 @@ impl BackupManifest {
 
         if let Some(ref crypt_config) = crypt_config {
             if let Some(signature) = signature {
-                let expected_signature = proxmox::tools::digest_to_hex(&Self::json_signature(&json, crypt_config)?);
+                let expected_signature = hex::encode(&Self::json_signature(&json, crypt_config)?);
 
                 let fingerprint = &json["unprotected"]["key-fingerprint"];
                 if fingerprint != &Value::Null {
@@ -318,7 +319,7 @@ fn test_manifest_signature() -> Result<(), Error> {
     assert_eq!(signature, "d7b446fb7db081662081d4b40fedd858a1d6307a5aff4ecff7d5bf4fd35679e9");
 
     let manifest: BackupManifest = serde_json::from_value(manifest)?;
-    let expected_signature = proxmox::tools::digest_to_hex(&manifest.signature(&crypt_config)?);
+    let expected_signature = hex::encode(&manifest.signature(&crypt_config)?);
 
     assert_eq!(signature, expected_signature);
 
index da29fd98bffc499a29b405321c420d1122341ef4..f9c4001c431b782d9cf57a9c2e91d1a319fa30d8 100644 (file)
@@ -247,7 +247,7 @@ fn generate_qr_code(output_type: &str, lines: &[String]) -> Result<Vec<u8>, Erro
         .wait_with_output()
         .map_err(|_| format_err!("Failed to read stdout"))?;
 
-    let output = pbs_tools::command_output(output, None)?;
+    let output = proxmox_sys::command::command_output(output, None)?;
 
     Ok(output)
 }
index c386256d26deebf8f8602f619184e4282031d899..7e2ddf5b610f4ddb29f644a996bf07c29a579e71 100644 (file)
@@ -6,13 +6,14 @@ use std::fs::File;
 use anyhow::{bail, Error};
 use nix::dir::Dir;
 
+use proxmox_sys::fs::lock_dir_noblock_shared;
+
 use crate::backup_info::BackupDir;
 use crate::index::IndexFile;
 use crate::fixed_index::FixedIndexReader;
 use crate::dynamic_index::DynamicIndexReader;
 use crate::manifest::{archive_type, ArchiveType, CLIENT_LOG_BLOB_NAME, MANIFEST_BLOB_NAME};
 use crate::DataStore;
-use pbs_tools::fs::lock_dir_noblock_shared;
 
 /// Helper to access the contents of a datastore backup snapshot
 ///
index 1da2aec874ed6c48c3b72ba9509c01f2955551e9..630f1bf004ef2520d47c018dd7a4016ee5fcc423 100644 (file)
@@ -16,5 +16,4 @@ tokio = { version = "1.6", features = [] }
 
 proxmox-time = "1"
 proxmox-fuse = "0.1.1"
-
-pbs-tools = { path = "../pbs-tools" }
+proxmox-sys = "0.2"
\ No newline at end of file
index fedb7dfd2e6039d56e6578dabb5dd071f61c530a..6a9e8bff0084071dbe033d59fbd71de25249e03a 100644 (file)
@@ -304,7 +304,7 @@ fn emerg_cleanup(loopdev: Option<&str>, mut backing_file: PathBuf) {
     let mut command = std::process::Command::new("fusermount");
     command.arg("-u");
     command.arg(&backing_file);
-    let _ = pbs_tools::run_command(command, None);
+    let _ = proxmox_sys::command::run_command(command, None);
 
     let _ = remove_file(&backing_file);
     backing_file.set_extension("pid");
@@ -365,7 +365,7 @@ fn unmap_from_backing(backing_file: &Path, loopdev: Option<&str>) -> Result<(),
 pub fn find_all_mappings() -> Result<impl Iterator<Item = (String, Option<String>)>, Error> {
     // get map of all /dev/loop mappings belonging to us
     let mut loopmap = HashMap::new();
-    for ent in pbs_tools::fs::scan_subdir(libc::AT_FDCWD, Path::new("/dev/"), &LOOPDEV_REGEX)? {
+    for ent in proxmox_sys::fs::scan_subdir(libc::AT_FDCWD, Path::new("/dev/"), &LOOPDEV_REGEX)? {
         if let Ok(ent) = ent {
             let loopdev = format!("/dev/{}", ent.file_name().to_string_lossy());
             if let Ok(file) = get_backing_file(&loopdev) {
@@ -376,7 +376,7 @@ pub fn find_all_mappings() -> Result<impl Iterator<Item = (String, Option<String
     }
 
     Ok(
-        pbs_tools::fs::read_subdir(libc::AT_FDCWD, Path::new(RUN_DIR))?.filter_map(move |ent| {
+        proxmox_sys::fs::read_subdir(libc::AT_FDCWD, Path::new(RUN_DIR))?.filter_map(move |ent| {
             match ent {
                 Ok(ent) => {
                     let file = ent.file_name().to_string_lossy();
index e11a835ab283f117bdbe38a0562297efd226c683..01c6d1811275ac4771b7fc4ed779c36175b22066 100644 (file)
@@ -11,6 +11,7 @@ libc = "0.2"
 anyhow = "1.0"
 thiserror = "1.0"
 endian_trait = { version = "0.6", features = ["arrays"] }
+hex = "0.4.3"
 nix = "0.19.1"
 serde = { version = "1.0", features = ["derive"] }
 serde_json = "1.0"
@@ -18,7 +19,6 @@ bitflags = "1.2.1"
 regex = "1.2"
 udev = "0.4"
 
-proxmox = "0.15.3"
 proxmox-io = "1"
 proxmox-lang = "1"
 # api-macro is only used by the binaries, so maybe we should split them out
@@ -28,6 +28,7 @@ proxmox-uuid = "1"
 
 # router::cli is only used by binaries, so maybe we should split them out
 proxmox-router = "1.1"
+proxmox-sys = "0.2"
 
 pbs-api-types = { path = "../pbs-api-types" }
 pbs-tools = { path = "../pbs-tools" }
index 78595e533be3ceb237eb14bc80cc175adfe3dfe0..c9aec65eb08b7648e3613c0de22dd4203db6903a 100644 (file)
@@ -69,11 +69,11 @@ impl <R: BlockRead> BlockedReader<R> {
     fn check_buffer(buffer: &BlockHeader, seq_nr: u32) -> Result<(usize, bool), std::io::Error> {
 
         if buffer.magic != PROXMOX_TAPE_BLOCK_HEADER_MAGIC_1_0 {
-            proxmox::io_bail!("detected tape block with wrong magic number - not written by proxmox tape");
+            proxmox_sys::io_bail!("detected tape block with wrong magic number - not written by proxmox tape");
         }
 
         if seq_nr != buffer.seq_nr() {
-            proxmox::io_bail!(
+            proxmox_sys::io_bail!(
                 "detected tape block with wrong sequence number ({} != {})",
                 seq_nr, buffer.seq_nr())
         }
@@ -82,9 +82,9 @@ impl <R: BlockRead> BlockedReader<R> {
         let found_end_marker = buffer.flags.contains(BlockHeaderFlags::END_OF_STREAM);
 
         if size > buffer.payload.len() {
-            proxmox::io_bail!("detected tape block with wrong payload size ({} > {}", size, buffer.payload.len());
+            proxmox_sys::io_bail!("detected tape block with wrong payload size ({} > {}", size, buffer.payload.len());
         } else if size == 0 && !found_end_marker {
-            proxmox::io_bail!("detected tape block with zero payload size");
+            proxmox_sys::io_bail!("detected tape block with zero payload size");
         }
 
 
@@ -103,7 +103,7 @@ impl <R: BlockRead> BlockedReader<R> {
         let bytes = reader.read_block(data)?;
 
         if bytes != BlockHeader::SIZE {
-            return Err(proxmox::io_format_err!("got wrong block size").into());
+            return Err(proxmox_sys::io_format_err!("got wrong block size").into());
         }
 
         Ok(())
@@ -113,13 +113,13 @@ impl <R: BlockRead> BlockedReader<R> {
         let mut tmp_buf = [0u8; 512]; // use a small buffer for testing EOF
         match reader.read_block(&mut tmp_buf) {
             Ok(_) => {
-                proxmox::io_bail!("detected tape block after block-stream end marker");
+                proxmox_sys::io_bail!("detected tape block after block-stream end marker");
             }
             Err(BlockReadError::EndOfFile) => {
                 return Ok(());
             }
             Err(BlockReadError::EndOfStream) => {
-                proxmox::io_bail!("got unexpected end of tape");
+                proxmox_sys::io_bail!("got unexpected end of tape");
             }
             Err(BlockReadError::Error(err)) => {
                 return Err(err);
@@ -135,12 +135,12 @@ impl <R: BlockRead> BlockedReader<R> {
                 self.got_eod = true;
                 self.read_pos = self.buffer.payload.len();
                 if !self.found_end_marker && check_end_marker {
-                    proxmox::io_bail!("detected tape stream without end marker");
+                    proxmox_sys::io_bail!("detected tape stream without end marker");
                 }
                 return Ok(0); // EOD
             }
             Err(BlockReadError::EndOfStream) => {
-                proxmox::io_bail!("got unexpected end of tape");
+                proxmox_sys::io_bail!("got unexpected end of tape");
             }
             Err(BlockReadError::Error(err)) => {
                 return Err(err);
@@ -167,10 +167,10 @@ impl <R: BlockRead> TapeRead for BlockedReader<R> {
 
     fn is_incomplete(&self) -> Result<bool, std::io::Error> {
         if !self.got_eod {
-            proxmox::io_bail!("is_incomplete failed: EOD not reached");
+            proxmox_sys::io_bail!("is_incomplete failed: EOD not reached");
         }
         if !self.found_end_marker {
-            proxmox::io_bail!("is_incomplete failed: no end marker found");
+            proxmox_sys::io_bail!("is_incomplete failed: no end marker found");
         }
 
         Ok(self.incomplete)
@@ -178,7 +178,7 @@ impl <R: BlockRead> TapeRead for BlockedReader<R> {
 
     fn has_end_marker(&self) -> Result<bool, std::io::Error> {
         if !self.got_eod {
-            proxmox::io_bail!("has_end_marker failed: EOD not reached");
+            proxmox_sys::io_bail!("has_end_marker failed: EOD not reached");
         }
 
         Ok(self.found_end_marker)
@@ -207,7 +207,7 @@ impl <R: BlockRead> Read for BlockedReader<R> {
     fn read(&mut self, buffer: &mut [u8]) -> Result<usize, std::io::Error> {
 
          if self.read_error {
-            proxmox::io_bail!("detected read after error - internal error");
+            proxmox_sys::io_bail!("detected read after error - internal error");
         }
 
         let mut buffer_size = self.buffer.size();
@@ -299,7 +299,7 @@ mod test {
 
     #[test]
     fn large_data() -> Result<(), Error> {
-        let data = proxmox::sys::linux::random_data(1024*1024*5)?;
+        let data = proxmox_sys::linux::random_data(1024*1024*5)?;
         write_and_verify(&data)
     }
 
@@ -323,7 +323,7 @@ mod test {
             let writer = EmulateTapeWriter::new(&mut tape_data, 1024*1024);
             let mut writer = BlockedWriter::new(writer);
             // write at least one block
-            let data = proxmox::sys::linux::random_data(PROXMOX_TAPE_BLOCK_SIZE)?;
+            let data = proxmox_sys::linux::random_data(PROXMOX_TAPE_BLOCK_SIZE)?;
             writer.write_all(&data)?;
             // but do not call finish here
         }
index 91893e06c940bec39fdf62a4ac8b30145473bd17..e98db5d006baa2084ceb0fa54af1f88601751ce8 100644 (file)
@@ -65,7 +65,7 @@ impl <W: BlockWrite> BlockedWriter<W> {
 
     fn write_eof(&mut self) -> Result<(), std::io::Error> {
         if self.wrote_eof {
-            proxmox::io_bail!("BlockedWriter: detected multiple EOF writes");
+            proxmox_sys::io_bail!("BlockedWriter: detected multiple EOF writes");
         }
         self.wrote_eof = true;
 
index fe0a5fe4b9bf0054aad4414bd7c578fd29bcaf4e..1e6454ced3f783a0b3c4a7c57af4922f0e0610b3 100644 (file)
@@ -22,7 +22,7 @@ impl <R: Read> EmulateTapeReader<R> {
 impl <R: Read> BlockRead for EmulateTapeReader<R> {
     fn read_block(&mut self, buffer: &mut [u8]) -> Result<usize, BlockReadError> {
         if self.got_eof {
-             return Err(BlockReadError::Error(proxmox::io_format_err!("detected read after EOF!")));
+             return Err(BlockReadError::Error(proxmox_sys::io_format_err!("detected read after EOF!")));
         }
         match self.reader.read_exact_or_eof(buffer)? {
             false => {
@@ -33,7 +33,7 @@ impl <R: Read> BlockRead for EmulateTapeReader<R> {
                 // test buffer len after EOF test (to allow EOF test with small buffers in BufferedReader)
                 if buffer.len() != PROXMOX_TAPE_BLOCK_SIZE {
                     return Err(BlockReadError::Error(
-                        proxmox::io_format_err!(
+                        proxmox_sys::io_format_err!(
                             "EmulateTapeReader: read_block with wrong block size ({} != {})",
                             buffer.len(),
                             PROXMOX_TAPE_BLOCK_SIZE,
index c8f1cbef62364217074d7303a5a306ab9a2ce47e..04ad697e6f0eb0e1770511b95b91567c80aed06c 100644 (file)
@@ -39,7 +39,7 @@ impl <W: Write> BlockWrite for EmulateTapeWriter<W> {
     fn write_block(&mut self, buffer: &[u8]) -> Result<bool, io::Error> {
 
         if buffer.len() != PROXMOX_TAPE_BLOCK_SIZE {
-            proxmox::io_bail!("EmulateTapeWriter: got write with wrong block size ({} != {}",
+            proxmox_sys::io_bail!("EmulateTapeWriter: got write with wrong block size ({} != {}",
                               buffer.len(), PROXMOX_TAPE_BLOCK_SIZE);
         }
 
@@ -59,7 +59,7 @@ impl <W: Write> BlockWrite for EmulateTapeWriter<W> {
 
     fn write_filemark(&mut self) -> Result<(), std::io::Error> {
         if self.wrote_eof {
-            proxmox::io_bail!("EmulateTapeWriter: detected multiple EOF writes");
+            proxmox_sys::io_bail!("EmulateTapeWriter: detected multiple EOF writes");
         }
         // do nothing, just record the call
         self.wrote_eof = true;
index b8a40d8ef29ede1265368a6f41c7198f60c42c87..60c05218bb9024e098a40f7935d7a8cd85738ba3 100644 (file)
@@ -7,9 +7,9 @@ use std::os::unix::io::AsRawFd;
 use anyhow::{bail, format_err, Error};
 use nix::fcntl::{fcntl, FcntlArg, OFlag};
 
-use proxmox::sys::error::SysResult;
+use proxmox_sys::error::SysResult;
+use proxmox_sys::fs::scan_subdir;
 
-use pbs_tools::fs::scan_subdir;
 use pbs_api_types::{DeviceKind, OptionalDeviceIdentification, TapeDeviceInfo};
 
 lazy_static::lazy_static!{
index 7d4ba84c9fa1a2aa0c1594d187b0d56a24192714..f59fbe12ff4295f1703acc422bf6ef7c3e1c0627 100644 (file)
@@ -25,7 +25,7 @@ pub use mam::*;
 mod report_density;
 pub use report_density::*;
 
-use proxmox::sys::error::SysResult;
+use proxmox_sys::error::SysResult;
 use proxmox_io::{ReadExt, WriteExt};
 
 use pbs_api_types::{MamAttribute, Lp17VolumeStatistics, LtoDriveAndMediaStatus};
@@ -530,11 +530,11 @@ impl SgTape {
     ) ->  Result<(), std::io::Error> {
 
         if count > 255 {
-            proxmox::io_bail!("write_filemarks failed: got strange count '{}'", count);
+            proxmox_sys::io_bail!("write_filemarks failed: got strange count '{}'", count);
         }
 
         let mut sg_raw = SgRaw::new(&mut self.file, 16)
-            .map_err(|err| proxmox::io_format_err!("write_filemarks failed (alloc) - {}", err))?;
+            .map_err(|err| proxmox_sys::io_format_err!("write_filemarks failed (alloc) - {}", err))?;
 
         sg_raw.set_timeout(Self::SCSI_TAPE_DEFAULT_TIMEOUT);
         let mut cmd = Vec::new();
@@ -553,7 +553,7 @@ impl SgTape {
                 /* LEOM - ignore */
             }
             Err(err) => {
-                proxmox::io_bail!("write filemark  failed - {}", err);
+                proxmox_sys::io_bail!("write filemark  failed - {}", err);
             }
         }
 
@@ -632,7 +632,7 @@ impl SgTape {
         let transfer_len = data.len();
 
         if transfer_len > 0x800000 {
-           proxmox::io_bail!("write failed - data too large");
+           proxmox_sys::io_bail!("write failed - data too large");
         }
 
         let mut sg_raw = SgRaw::new(&mut self.file, 0)
@@ -656,7 +656,7 @@ impl SgTape {
                 return Ok(true); // LEOM
             }
             Err(err) => {
-                proxmox::io_bail!("write failed - {}", err);
+                proxmox_sys::io_bail!("write failed - {}", err);
             }
         }
     }
@@ -666,7 +666,7 @@ impl SgTape {
 
         if transfer_len > 0xFFFFFF {
             return Err(BlockReadError::Error(
-                proxmox::io_format_err!("read failed - buffer too large")
+                proxmox_sys::io_format_err!("read failed - buffer too large")
             ));
         }
 
@@ -693,14 +693,14 @@ impl SgTape {
             }
             Err(err) => {
                 return Err(BlockReadError::Error(
-                    proxmox::io_format_err!("read failed - {}", err)
+                    proxmox_sys::io_format_err!("read failed - {}", err)
                 ));
             }
         };
 
         if data.len() != transfer_len {
             return Err(BlockReadError::Error(
-                proxmox::io_format_err!("read failed - unexpected block len ({} != {})", data.len(), buffer.len())
+                proxmox_sys::io_format_err!("read failed - unexpected block len ({} != {})", data.len(), buffer.len())
             ));
         }
 
@@ -951,7 +951,7 @@ impl <'a> BlockRead for SgTapeReader<'a> {
 
     fn read_block(&mut self, buffer: &mut [u8]) -> Result<usize, BlockReadError> {
         if self.end_of_file {
-            return Err(BlockReadError::Error(proxmox::io_format_err!("detected read after EOF!")));
+            return Err(BlockReadError::Error(proxmox_sys::io_format_err!("detected read after EOF!")));
         }
         match self.sg_tape.read_block(buffer) {
             Ok(usize) => Ok(usize),
index e006ea43e9051d15a03ba07d9cf4aae155950bfc..4bc73c738331cb7c84ef4bbe81dbf160d3019b30 100644 (file)
@@ -175,7 +175,7 @@ fn decode_mam_attributes(data: &[u8]) -> Result<Vec<MamAttribute>, Error> {
                             unreachable!();
                         }
                     },
-                    MamFormat::BINARY => proxmox::tools::digest_to_hex(&data),
+                    MamFormat::BINARY => hex::encode(&data),
                 };
                 list.push(MamAttribute {
                     id: head_id,
index d3d6aaa2c5335366565a5350352e4b5b3b077cbe..321fb5d81b71e228442f14b82f2d12f993a52961 100644 (file)
@@ -34,7 +34,7 @@ pub trait TapeWrite {
         data: &[u8],
     ) -> Result<bool, std::io::Error> {
         if header.size as usize != data.len() {
-            proxmox::io_bail!("write_header with wrong size - internal error");
+            proxmox_sys::io_bail!("write_header with wrong size - internal error");
         }
         let header = header.to_le();
 
index 7a2b6c27f4a83f77980035c98aff18b48eef5ca6..bce9354f6b384c973fe22a106a0e55092bf2cfd8 100644 (file)
@@ -32,12 +32,13 @@ url = "2.1"
 walkdir = "2"
 zstd = { version = "0.6", features = [ "bindgen" ] }
 
-proxmox = { version = "0.15.3", default-features = false, features = [ "tokio" ] }
-proxmox-async = "0.2"
+#proxmox = { version = "0.15.3", default-features = false, features = [ "tokio" ] }
+proxmox-async = "0.3"
 proxmox-borrow = "1"
 proxmox-io = { version = "1", features = [ "tokio" ] }
 proxmox-lang = { version = "1" }
 proxmox-time = { version = "1" }
+proxmox-sys = "0.2"
 
 pbs-buildcfg = { path = "../pbs-buildcfg" }
 pbs-api-types = { path = "../pbs-api-types" }
diff --git a/pbs-tools/src/acl.rs b/pbs-tools/src/acl.rs
deleted file mode 100644 (file)
index 80e2781..0000000
+++ /dev/null
@@ -1,334 +0,0 @@
-//! Implementation of the calls to handle POSIX access control lists
-
-// see C header file <sys/acl.h> for reference
-extern crate libc;
-
-use std::ffi::CString;
-use std::marker::PhantomData;
-use std::os::unix::ffi::OsStrExt;
-use std::os::unix::io::RawFd;
-use std::path::Path;
-use std::ptr;
-
-use libc::{c_char, c_int, c_uint, c_void};
-use nix::errno::Errno;
-use nix::NixPath;
-
-// from: acl/include/acl.h
-pub const ACL_UNDEFINED_ID: u32 = 0xffffffff;
-// acl_perm_t values
-pub type ACLPerm = c_uint;
-pub const ACL_READ: ACLPerm     = 0x04;
-pub const ACL_WRITE: ACLPerm    = 0x02;
-pub const ACL_EXECUTE: ACLPerm  = 0x01;
-
-// acl_tag_t values
-pub type ACLTag = c_int;
-pub const ACL_UNDEFINED_TAG: ACLTag = 0x00;
-pub const ACL_USER_OBJ: ACLTag      = 0x01;
-pub const ACL_USER: ACLTag          = 0x02;
-pub const ACL_GROUP_OBJ: ACLTag     = 0x04;
-pub const ACL_GROUP: ACLTag         = 0x08;
-pub const ACL_MASK: ACLTag          = 0x10;
-pub const ACL_OTHER: ACLTag         = 0x20;
-
-// acl_type_t values
-pub type ACLType = c_uint;
-pub const ACL_TYPE_ACCESS: ACLType  = 0x8000;
-pub const ACL_TYPE_DEFAULT: ACLType = 0x4000;
-
-// acl entry constants
-pub const ACL_FIRST_ENTRY: c_int = 0;
-pub const ACL_NEXT_ENTRY: c_int  = 1;
-
-// acl to extended attribute names constants
-// from: acl/include/acl_ea.h
-pub const ACL_EA_ACCESS: &str = "system.posix_acl_access";
-pub const ACL_EA_DEFAULT: &str = "system.posix_acl_default";
-pub const ACL_EA_VERSION: u32 = 0x0002;
-
-#[link(name = "acl")]
-extern "C" {
-    fn acl_get_file(path: *const c_char, acl_type: ACLType) -> *mut c_void;
-    fn acl_set_file(path: *const c_char, acl_type: ACLType, acl: *mut c_void) -> c_int;
-    fn acl_get_fd(fd: RawFd) -> *mut c_void;
-    fn acl_get_entry(acl: *const c_void, entry_id: c_int, entry: *mut *mut c_void) -> c_int;
-    fn acl_create_entry(acl: *mut *mut c_void, entry: *mut *mut c_void) -> c_int;
-    fn acl_get_tag_type(entry: *mut c_void, tag_type: *mut ACLTag) -> c_int;
-    fn acl_set_tag_type(entry: *mut c_void, tag_type: ACLTag) -> c_int;
-    fn acl_get_permset(entry: *mut c_void, permset: *mut *mut c_void) -> c_int;
-    fn acl_clear_perms(permset: *mut c_void) -> c_int;
-    fn acl_get_perm(permset: *mut c_void, perm: ACLPerm) -> c_int;
-    fn acl_add_perm(permset: *mut c_void, perm: ACLPerm) -> c_int;
-    fn acl_get_qualifier(entry: *mut c_void) -> *mut c_void;
-    fn acl_set_qualifier(entry: *mut c_void, qualifier: *const c_void) -> c_int;
-    fn acl_init(count: c_int) -> *mut c_void;
-    fn acl_valid(ptr: *const c_void) -> c_int;
-    fn acl_free(ptr: *mut c_void) -> c_int;
-}
-
-#[derive(Debug)]
-pub struct ACL {
-    ptr: *mut c_void,
-}
-
-impl Drop for ACL {
-    fn drop(&mut self) {
-        let ret = unsafe { acl_free(self.ptr) };
-        if ret != 0 {
-            panic!("invalid pointer encountered while dropping ACL - {}", Errno::last());
-        }
-    }
-}
-
-impl ACL {
-    pub fn init(count: usize) -> Result<ACL, nix::errno::Errno> {
-        let ptr = unsafe { acl_init(count as i32 as c_int) };
-        if ptr.is_null() {
-            return Err(Errno::last());
-        }
-
-        Ok(ACL { ptr })
-    }
-
-    pub fn get_file<P: AsRef<Path>>(path: P, acl_type: ACLType) -> Result<ACL, nix::errno::Errno> {
-        let path_cstr = CString::new(path.as_ref().as_os_str().as_bytes()).unwrap();
-        let ptr = unsafe { acl_get_file(path_cstr.as_ptr(), acl_type) };
-        if ptr.is_null() {
-            return Err(Errno::last());
-        }
-        Ok(ACL { ptr })
-    }
-
-    pub fn set_file<P: NixPath + ?Sized>(&self, path: &P, acl_type: ACLType) -> nix::Result<()> {
-        path.with_nix_path(|path| {
-            Errno::result(unsafe { acl_set_file(path.as_ptr(), acl_type, self.ptr) })
-        })?
-        .map(drop)
-    }
-
-    pub fn get_fd(fd: RawFd) -> Result<ACL, nix::errno::Errno> {
-        let ptr = unsafe { acl_get_fd(fd) };
-        if ptr.is_null() {
-            return Err(Errno::last());
-        }
-
-        Ok(ACL { ptr })
-    }
-
-    pub fn create_entry(&mut self) -> Result<ACLEntry, nix::errno::Errno> {
-        let mut ptr = ptr::null_mut() as *mut c_void;
-        let res = unsafe { acl_create_entry(&mut self.ptr, &mut ptr) };
-        if res < 0 {
-            return Err(Errno::last());
-        }
-
-        Ok(ACLEntry {
-            ptr,
-            _phantom: PhantomData,
-        })
-    }
-
-    pub fn is_valid(&self) -> bool {
-        let res = unsafe { acl_valid(self.ptr) };
-        if res == 0 {
-            return true;
-        }
-
-        false
-    }
-
-    pub fn entries(self) -> ACLEntriesIterator {
-        ACLEntriesIterator {
-            acl: self,
-            current: ACL_FIRST_ENTRY,
-        }
-    }
-
-    pub fn add_entry_full(&mut self, tag: ACLTag, qualifier: Option<u64>, permissions: u64)
-        -> Result<(), nix::errno::Errno>
-    {
-        let mut entry = self.create_entry()?;
-        entry.set_tag_type(tag)?;
-        if let Some(qualifier) = qualifier {
-            entry.set_qualifier(qualifier)?;
-        }
-        entry.set_permissions(permissions)?;
-
-        Ok(())
-    }
-}
-
-#[derive(Debug)]
-pub struct ACLEntry<'a> {
-    ptr: *mut c_void,
-    _phantom: PhantomData<&'a mut ()>,
-}
-
-impl<'a> ACLEntry<'a> {
-    pub fn get_tag_type(&self) -> Result<ACLTag, nix::errno::Errno> {
-        let mut tag = ACL_UNDEFINED_TAG;
-        let res = unsafe { acl_get_tag_type(self.ptr, &mut tag as *mut ACLTag) };
-        if res < 0 {
-            return Err(Errno::last());
-        }
-
-        Ok(tag)
-    }
-
-    pub fn set_tag_type(&mut self, tag: ACLTag) -> Result<(), nix::errno::Errno> {
-        let res = unsafe { acl_set_tag_type(self.ptr, tag) };
-        if res < 0 {
-            return Err(Errno::last());
-        }
-
-        Ok(())
-    }
-
-    pub fn get_permissions(&self) -> Result<u64, nix::errno::Errno> {
-        let mut permissions = 0;
-        let mut permset = ptr::null_mut() as *mut c_void;
-        let mut res = unsafe { acl_get_permset(self.ptr, &mut permset) };
-        if res < 0 {
-            return Err(Errno::last());
-        }
-
-        for &perm in &[ACL_READ, ACL_WRITE, ACL_EXECUTE] {
-            res = unsafe { acl_get_perm(permset, perm) };
-            if res < 0 {
-                return Err(Errno::last());
-            }
-
-            if res == 1 {
-                permissions |= perm as u64;
-            }
-        }
-
-        Ok(permissions)
-    }
-
-    pub fn set_permissions(&mut self, permissions: u64) -> Result<u64, nix::errno::Errno> {
-        let mut permset = ptr::null_mut() as *mut c_void;
-        let mut res = unsafe { acl_get_permset(self.ptr, &mut permset) };
-        if res < 0 {
-            return Err(Errno::last());
-        }
-
-        res = unsafe { acl_clear_perms(permset) };
-        if res < 0 {
-            return Err(Errno::last());
-        }
-
-        for &perm in &[ACL_READ, ACL_WRITE, ACL_EXECUTE] {
-            if permissions & perm as u64 == perm as u64 {
-                res = unsafe { acl_add_perm(permset, perm) };
-                if res < 0 {
-                    return Err(Errno::last());
-                }
-            }
-        }
-
-        Ok(permissions)
-    }
-
-    pub fn get_qualifier(&self) -> Result<u64, nix::errno::Errno> {
-        let qualifier = unsafe { acl_get_qualifier(self.ptr) };
-        if qualifier.is_null() {
-            return Err(Errno::last());
-        }
-        let result = unsafe { *(qualifier as *const u32) as u64 };
-        let ret = unsafe { acl_free(qualifier) };
-        if ret != 0 {
-            panic!("invalid pointer encountered while dropping ACL qualifier - {}", Errno::last());
-        }
-
-        Ok(result)
-    }
-
-    pub fn set_qualifier(&mut self, qualifier: u64) -> Result<(), nix::errno::Errno> {
-        let val = qualifier as u32;
-        let val_ptr: *const u32 = &val;
-        let res = unsafe { acl_set_qualifier(self.ptr, val_ptr as *const c_void) };
-        if res < 0 {
-            return Err(Errno::last());
-        }
-
-        Ok(())
-    }
-}
-
-#[derive(Debug)]
-pub struct ACLEntriesIterator {
-    acl: ACL,
-    current: c_int,
-}
-
-impl<'a> Iterator for &'a mut ACLEntriesIterator {
-    type Item = ACLEntry<'a>;
-
-    fn next(&mut self) -> Option<Self::Item> {
-        let mut entry_ptr = ptr::null_mut();
-        let res = unsafe { acl_get_entry(self.acl.ptr, self.current, &mut entry_ptr) };
-        self.current = ACL_NEXT_ENTRY;
-        if res == 1 {
-            return Some(ACLEntry { ptr: entry_ptr, _phantom: PhantomData });
-        }
-
-        None
-    }
-}
-
-/// Helper to transform `PxarEntry`s user mode to acl permissions.
-pub fn mode_user_to_acl_permissions(mode: u64) -> u64 {
-    (mode >> 6) & 7
-}
-
-/// Helper to transform `PxarEntry`s group mode to acl permissions.
-pub fn mode_group_to_acl_permissions(mode: u64) -> u64 {
-    (mode >> 3) & 7
-}
-
-/// Helper to transform `PxarEntry`s other mode to acl permissions.
-pub fn mode_other_to_acl_permissions(mode: u64) -> u64 {
-    mode & 7
-}
-
-/// Buffer to compose ACLs as extended attribute.
-pub struct ACLXAttrBuffer {
-    buffer: Vec<u8>,
-}
-
-impl ACLXAttrBuffer {
-    /// Create a new buffer to write ACLs as extended attribute.
-    ///
-    /// `version` defines the ACL_EA_VERSION found in acl/include/acl_ea.h
-    pub fn new(version: u32) -> Self {
-        let mut buffer = Vec::new();
-        buffer.extend_from_slice(&version.to_le_bytes());
-        Self { buffer }
-    }
-
-    /// Add ACL entry to buffer.
-    pub fn add_entry(&mut self, tag: ACLTag, qualifier: Option<u64>, permissions: u64) {
-        self.buffer.extend_from_slice(&(tag as u16).to_le_bytes());
-        self.buffer.extend_from_slice(&(permissions as u16).to_le_bytes());
-        match qualifier {
-            Some(qualifier) => self.buffer.extend_from_slice(&(qualifier as u32).to_le_bytes()),
-            None => self.buffer.extend_from_slice(&ACL_UNDEFINED_ID.to_le_bytes()),
-        }
-    }
-
-    /// Length of the buffer in bytes.
-    pub fn len(&self) -> usize {
-        self.buffer.len()
-    }
-
-    /// The buffer always contains at least the version, it is never empty
-    pub const fn is_empty(&self) -> bool { false }
-
-    /// Borrow raw buffer as mut slice.
-    pub fn as_mut_slice(&mut self) -> &mut [u8] {
-        self.buffer.as_mut_slice()
-    }
-}
index 189d07575f059eefc52dacaa848f084705f80e19..f438f6a377ad37ac99aa1b712ff1410707f3f2fb 100644 (file)
@@ -41,7 +41,7 @@ fn x509name_to_string(name: &openssl::x509::X509NameRef) -> Result<String, Error
 
 impl CertInfo {
     pub fn from_path(path: PathBuf) -> Result<Self, Error> {
-        Self::from_pem(&proxmox::tools::fs::file_get_contents(&path)?)
+        Self::from_pem(&proxmox_sys::fs::file_get_contents(&path)?)
             .map_err(|err| format_err!("failed to load certificate from {:?} - {}", path, err))
     }
 
diff --git a/pbs-tools/src/command.rs b/pbs-tools/src/command.rs
deleted file mode 100644 (file)
index 943435c..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-use anyhow::{bail, format_err, Error};
-
-/// Helper to check result from std::process::Command output
-///
-/// The exit_code_check() function should return true if the exit code
-/// is considered successful.
-pub fn command_output(
-    output: std::process::Output,
-    exit_code_check: Option<fn(i32) -> bool>,
-) -> Result<Vec<u8>, Error> {
-    if !output.status.success() {
-        match output.status.code() {
-            Some(code) => {
-                let is_ok = match exit_code_check {
-                    Some(check_fn) => check_fn(code),
-                    None => code == 0,
-                };
-                if !is_ok {
-                    let msg = String::from_utf8(output.stderr)
-                        .map(|m| {
-                            if m.is_empty() {
-                                String::from("no error message")
-                            } else {
-                                m
-                            }
-                        })
-                        .unwrap_or_else(|_| String::from("non utf8 error message (suppressed)"));
-
-                    bail!("status code: {} - {}", code, msg);
-                }
-            }
-            None => bail!("terminated by signal"),
-        }
-    }
-
-    Ok(output.stdout)
-}
-
-/// Helper to check result from std::process::Command output, returns String.
-///
-/// The exit_code_check() function should return true if the exit code
-/// is considered successful.
-pub fn command_output_as_string(
-    output: std::process::Output,
-    exit_code_check: Option<fn(i32) -> bool>,
-) -> Result<String, Error> {
-    let output = command_output(output, exit_code_check)?;
-    let output = String::from_utf8(output)?;
-    Ok(output)
-}
-
-pub fn run_command(
-    mut command: std::process::Command,
-    exit_code_check: Option<fn(i32) -> bool>,
-) -> Result<String, Error> {
-    let output = command
-        .output()
-        .map_err(|err| format_err!("failed to execute {:?} - {}", command, err))?;
-
-    let output = command_output_as_string(output, exit_code_check)
-        .map_err(|err| format_err!("command {:?} failed - {}", command, err))?;
-
-    Ok(output)
-}
diff --git a/pbs-tools/src/fs.rs b/pbs-tools/src/fs.rs
deleted file mode 100644 (file)
index 1a0635d..0000000
+++ /dev/null
@@ -1,372 +0,0 @@
-//! File system helper utilities.
-
-use std::borrow::{Borrow, BorrowMut};
-use std::fs::File;
-use std::io::{self, BufRead};
-use std::ops::{Deref, DerefMut};
-use std::os::unix::io::{AsRawFd, RawFd};
-use std::path::Path;
-
-use anyhow::{bail, format_err, Error};
-use nix::dir;
-use nix::dir::Dir;
-use nix::fcntl::OFlag;
-use nix::sys::stat::Mode;
-
-use regex::Regex;
-
-use proxmox::sys::error::SysError;
-use proxmox_borrow::Tied;
-
-pub type DirLockGuard = Dir;
-
-/// This wraps nix::dir::Entry with the parent directory's file descriptor.
-pub struct ReadDirEntry {
-    entry: dir::Entry,
-    parent_fd: RawFd,
-}
-
-impl Into<dir::Entry> for ReadDirEntry {
-    fn into(self) -> dir::Entry {
-        self.entry
-    }
-}
-
-impl Deref for ReadDirEntry {
-    type Target = dir::Entry;
-
-    fn deref(&self) -> &Self::Target {
-        &self.entry
-    }
-}
-
-impl DerefMut for ReadDirEntry {
-    fn deref_mut(&mut self) -> &mut Self::Target {
-        &mut self.entry
-    }
-}
-
-impl AsRef<dir::Entry> for ReadDirEntry {
-    fn as_ref(&self) -> &dir::Entry {
-        &self.entry
-    }
-}
-
-impl AsMut<dir::Entry> for ReadDirEntry {
-    fn as_mut(&mut self) -> &mut dir::Entry {
-        &mut self.entry
-    }
-}
-
-impl Borrow<dir::Entry> for ReadDirEntry {
-    fn borrow(&self) -> &dir::Entry {
-        &self.entry
-    }
-}
-
-impl BorrowMut<dir::Entry> for ReadDirEntry {
-    fn borrow_mut(&mut self) -> &mut dir::Entry {
-        &mut self.entry
-    }
-}
-
-impl ReadDirEntry {
-    #[inline]
-    pub fn parent_fd(&self) -> RawFd {
-        self.parent_fd
-    }
-
-    pub unsafe fn file_name_utf8_unchecked(&self) -> &str {
-        std::str::from_utf8_unchecked(self.file_name().to_bytes())
-    }
-}
-
-// Since Tied<T, U> implements Deref to U, a Tied<Dir, Iterator> already implements Iterator.
-// This is simply a wrapper with a shorter type name mapping nix::Error to anyhow::Error.
-/// Wrapper over a pair of `nix::dir::Dir` and `nix::dir::Iter`, returned by `read_subdir()`.
-pub struct ReadDir {
-    iter: Tied<Dir, dyn Iterator<Item = nix::Result<dir::Entry>> + Send>,
-    dir_fd: RawFd,
-}
-
-impl Iterator for ReadDir {
-    type Item = Result<ReadDirEntry, Error>;
-
-    fn next(&mut self) -> Option<Self::Item> {
-        self.iter.next().map(|res| {
-            res.map(|entry| ReadDirEntry { entry, parent_fd: self.dir_fd })
-                .map_err(Error::from)
-        })
-    }
-}
-
-/// Create an iterator over sub directory entries.
-/// This uses `openat` on `dirfd`, so `path` can be relative to that or an absolute path.
-pub fn read_subdir<P: ?Sized + nix::NixPath>(dirfd: RawFd, path: &P) -> nix::Result<ReadDir> {
-    let dir = Dir::openat(dirfd, path, OFlag::O_RDONLY, Mode::empty())?;
-    let fd = dir.as_raw_fd();
-    let iter = Tied::new(dir, |dir| {
-        Box::new(unsafe { (*dir).iter() })
-            as Box<dyn Iterator<Item = nix::Result<dir::Entry>> + Send>
-    });
-    Ok(ReadDir { iter, dir_fd: fd })
-}
-
-/// Scan through a directory with a regular expression. This is simply a shortcut filtering the
-/// results of `read_subdir`. Non-UTF8 compatible file names are silently ignored.
-pub fn scan_subdir<'a, P: ?Sized + nix::NixPath>(
-    dirfd: RawFd,
-    path: &P,
-    regex: &'a regex::Regex,
-) -> Result<impl Iterator<Item = Result<ReadDirEntry, Error>> + 'a, nix::Error> {
-    Ok(read_subdir(dirfd, path)?.filter_file_name_regex(regex))
-}
-
-/// Scan directory for matching file names with a callback.
-///
-/// Scan through all directory entries and call `callback()` function
-/// if the entry name matches the regular expression. This function
-/// used unix `openat()`, so you can pass absolute or relative file
-/// names. This function simply skips non-UTF8 encoded names.
-pub fn scandir<P, F>(
-    dirfd: RawFd,
-    path: &P,
-    regex: &regex::Regex,
-    mut callback: F,
-) -> Result<(), Error>
-where
-    F: FnMut(RawFd, &str, nix::dir::Type) -> Result<(), Error>,
-    P: ?Sized + nix::NixPath,
-{
-    for entry in scan_subdir(dirfd, path, regex)? {
-        let entry = entry?;
-        let file_type = match entry.file_type() {
-            Some(file_type) => file_type,
-            None => bail!("unable to detect file type"),
-        };
-
-        callback(
-            entry.parent_fd(),
-            unsafe { entry.file_name_utf8_unchecked() },
-            file_type,
-        )?;
-    }
-    Ok(())
-}
-
-
-/// Helper trait to provide a combinators for directory entry iterators.
-pub trait FileIterOps<T, E>
-where
-    Self: Sized + Iterator<Item = Result<T, E>>,
-    T: Borrow<dir::Entry>,
-    E: Into<Error> + Send + Sync,
-{
-    /// Filter by file type. This is more convenient than using the `filter` method alone as this
-    /// also includes error handling and handling of files without a type (via an error).
-    fn filter_file_type(self, ty: dir::Type) -> FileTypeFilter<Self, T, E> {
-        FileTypeFilter { inner: self, ty }
-    }
-
-    /// Filter by file name. Note that file names which aren't valid utf-8 will be treated as if
-    /// they do not match the pattern.
-    fn filter_file_name_regex(self, regex: &Regex) -> FileNameRegexFilter<Self, T, E> {
-        FileNameRegexFilter { inner: self, regex }
-    }
-}
-
-impl<I, T, E> FileIterOps<T, E> for I
-where
-    I: Iterator<Item = Result<T, E>>,
-    T: Borrow<dir::Entry>,
-    E: Into<Error> + Send + Sync,
-{
-}
-
-/// This filters files from its inner iterator by a file type. Files with no type produce an error.
-pub struct FileTypeFilter<I, T, E>
-where
-    I: Iterator<Item = Result<T, E>>,
-    T: Borrow<dir::Entry>,
-    E: Into<Error> + Send + Sync,
-{
-    inner: I,
-    ty: nix::dir::Type,
-}
-
-impl<I, T, E> Iterator for FileTypeFilter<I, T, E>
-where
-    I: Iterator<Item = Result<T, E>>,
-    T: Borrow<dir::Entry>,
-    E: Into<Error> + Send + Sync,
-{
-    type Item = Result<T, Error>;
-
-    fn next(&mut self) -> Option<Self::Item> {
-        loop {
-            let item = self.inner.next()?.map_err(|e| e.into());
-            match item {
-                Ok(ref entry) => match entry.borrow().file_type() {
-                    Some(ty) => {
-                        if ty == self.ty {
-                            return Some(item);
-                        } else {
-                            continue;
-                        }
-                    }
-                    None => return Some(Err(format_err!("unable to detect file type"))),
-                },
-                Err(_) => return Some(item),
-            }
-        }
-    }
-}
-
-/// This filters files by name via a Regex. Files whose file name aren't valid utf-8 are skipped
-/// silently.
-pub struct FileNameRegexFilter<'a, I, T, E>
-where
-    I: Iterator<Item = Result<T, E>>,
-    T: Borrow<dir::Entry>,
-{
-    inner: I,
-    regex: &'a Regex,
-}
-
-impl<I, T, E> Iterator for FileNameRegexFilter<'_, I, T, E>
-where
-    I: Iterator<Item = Result<T, E>>,
-    T: Borrow<dir::Entry>,
-{
-    type Item = Result<T, E>;
-
-    fn next(&mut self) -> Option<Self::Item> {
-        loop {
-            let item = self.inner.next()?;
-            match item {
-                Ok(ref entry) => {
-                    if let Ok(name) = entry.borrow().file_name().to_str() {
-                        if self.regex.is_match(name) {
-                            return Some(item);
-                        }
-                    }
-                    // file did not match regex or isn't valid utf-8
-                    continue;
-                },
-                Err(_) => return Some(item),
-            }
-        }
-    }
-}
-
-// /usr/include/linux/fs.h: #define FS_IOC_GETFLAGS _IOR('f', 1, long)
-// read Linux file system attributes (see man chattr)
-nix::ioctl_read!(read_attr_fd, b'f', 1, libc::c_long);
-nix::ioctl_write_ptr!(write_attr_fd, b'f', 2, libc::c_long);
-
-// /usr/include/linux/msdos_fs.h: #define FAT_IOCTL_GET_ATTRIBUTES _IOR('r', 0x10, __u32)
-// read FAT file system attributes
-nix::ioctl_read!(read_fat_attr_fd, b'r', 0x10, u32);
-nix::ioctl_write_ptr!(write_fat_attr_fd, b'r', 0x11, u32);
-
-// From /usr/include/linux/fs.h
-// #define FS_IOC_FSGETXATTR _IOR('X', 31, struct fsxattr)
-// #define FS_IOC_FSSETXATTR _IOW('X', 32, struct fsxattr)
-nix::ioctl_read!(fs_ioc_fsgetxattr, b'X', 31, FSXAttr);
-nix::ioctl_write_ptr!(fs_ioc_fssetxattr, b'X', 32, FSXAttr);
-
-#[repr(C)]
-#[derive(Debug)]
-pub struct FSXAttr {
-    pub fsx_xflags: u32,
-    pub fsx_extsize: u32,
-    pub fsx_nextents: u32,
-    pub fsx_projid: u32,
-    pub fsx_cowextsize: u32,
-    pub fsx_pad: [u8; 8],
-}
-
-impl Default for FSXAttr {
-    fn default() -> Self {
-        FSXAttr {
-            fsx_xflags: 0u32,
-            fsx_extsize: 0u32,
-            fsx_nextents: 0u32,
-            fsx_projid: 0u32,
-            fsx_cowextsize: 0u32,
-            fsx_pad: [0u8; 8],
-        }
-    }
-}
-
-/// Attempt to acquire a shared flock on the given path, 'what' and
-/// 'would_block_message' are used for error formatting.
-pub fn lock_dir_noblock_shared(
-    path: &std::path::Path,
-    what: &str,
-    would_block_msg: &str,
-) -> Result<DirLockGuard, Error> {
-    do_lock_dir_noblock(path, what, would_block_msg, false)
-}
-
-/// Attempt to acquire an exclusive flock on the given path, 'what' and
-/// 'would_block_message' are used for error formatting.
-pub fn lock_dir_noblock(
-    path: &std::path::Path,
-    what: &str,
-    would_block_msg: &str,
-) -> Result<DirLockGuard, Error> {
-    do_lock_dir_noblock(path, what, would_block_msg, true)
-}
-
-fn do_lock_dir_noblock(
-    path: &std::path::Path,
-    what: &str,
-    would_block_msg: &str,
-    exclusive: bool,
-) -> Result<DirLockGuard, Error> {
-    let mut handle = Dir::open(path, OFlag::O_RDONLY, Mode::empty())
-        .map_err(|err| {
-            format_err!("unable to open {} directory {:?} for locking - {}", what, path, err)
-        })?;
-
-    // acquire in non-blocking mode, no point in waiting here since other
-    // backups could still take a very long time
-    proxmox::tools::fs::lock_file(&mut handle, exclusive, Some(std::time::Duration::from_nanos(0)))
-        .map_err(|err| {
-            format_err!(
-                "unable to acquire lock on {} directory {:?} - {}", what, path,
-                if err.would_block() {
-                    String::from(would_block_msg)
-                } else {
-                    err.to_string()
-                }
-            )
-        })?;
-
-    Ok(handle)
-}
-
-/// Get an iterator over lines of a file, skipping empty lines and comments (lines starting with a
-/// `#`).
-pub fn file_get_non_comment_lines<P: AsRef<Path>>(
-    path: P,
-) -> Result<impl Iterator<Item = io::Result<String>>, Error> {
-    let path = path.as_ref();
-
-    Ok(io::BufReader::new(
-        File::open(path).map_err(|err| format_err!("error opening {:?}: {}", path, err))?,
-    )
-    .lines()
-    .filter_map(|line| match line {
-        Ok(line) => {
-            let line = line.trim();
-            if line.is_empty() || line.starts_with('#') {
-                None
-            } else {
-                Some(Ok(line.to_string()))
-            }
-        }
-        Err(err) => Some(Err(err)),
-    }))
-}
index 1b5e3cc7cf3451d47c5426a399357613328960a0..dfc0ea185d75042c2af254d1f3decf2f36e44705 100644 (file)
@@ -1,6 +1,6 @@
 //! I/O utilities.
 
-use proxmox::tools::fd::Fd;
+use proxmox_sys::fd::Fd;
 
 /// The `BufferedRead` trait provides a single function
 /// `buffered_read`. It returns a reference to an internal buffer. The
index 9ea4ea5c940e258b3b5b5011538ebea012bcd119..bd5885cf5be5c3b40973bc6c13c627a9785d53aa 100644 (file)
@@ -1,9 +1,7 @@
-pub mod acl;
 pub mod cert;
 pub mod cli;
 pub mod crypt_config;
 pub mod format;
-pub mod fs;
 pub mod io;
 pub mod json;
 pub mod lru_cache;
@@ -14,9 +12,5 @@ pub mod str;
 pub mod sync;
 pub mod sys;
 pub mod ticket;
-pub mod xattr;
 
 pub mod async_lru_cache;
-
-mod command;
-pub use command::{command_output, command_output_as_string, run_command};
index d2f6444ebce59f5d0a0c41d55efa3bfaf3a1d5b7..eb2170599f92e3dca653fd3a4a29b27816451d29 100644 (file)
@@ -18,7 +18,7 @@ impl Write for StdChannelWriter {
     fn write(&mut self, buf: &[u8]) -> Result<usize, std::io::Error> {
         self.0
             .send(Ok(buf.to_vec()))
-            .map_err(proxmox::sys::error::io_err_other)
+            .map_err(proxmox_sys::error::io_err_other)
             .and(Ok(buf.len()))
     }
 
diff --git a/pbs-tools/src/xattr.rs b/pbs-tools/src/xattr.rs
deleted file mode 100644 (file)
index 4763735..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-//! Wrapper functions for the libc xattr calls
-
-use std::ffi::CStr;
-use std::os::unix::io::RawFd;
-
-use nix::errno::Errno;
-
-use proxmox_io::vec;
-use proxmox_lang::c_str;
-
-/// `"security.capability"` as a CStr to avoid typos.
-///
-/// This cannot be `const` until `const_cstr_unchecked` is stable.
-#[inline]
-pub fn xattr_name_fcaps() -> &'static CStr {
-    c_str!("security.capability")
-}
-
-/// `"system.posix_acl_access"` as a CStr to avoid typos.
-///
-/// This cannot be `const` until `const_cstr_unchecked` is stable.
-#[inline]
-pub fn xattr_acl_access() -> &'static CStr {
-    c_str!("system.posix_acl_access")
-}
-
-/// `"system.posix_acl_default"` as a CStr to avoid typos.
-///
-/// This cannot be `const` until `const_cstr_unchecked` is stable.
-#[inline]
-pub fn xattr_acl_default() -> &'static CStr {
-    c_str!("system.posix_acl_default")
-}
-
-/// Result of `flistxattr`, allows iterating over the attributes as a list of `&CStr`s.
-///
-/// Listing xattrs produces a list separated by zeroes, inherently making them available as `&CStr`
-/// already, so we make use of this fact and reflect this in the interface.
-pub struct ListXAttr {
-    data: Vec<u8>,
-}
-
-impl ListXAttr {
-    fn new(data: Vec<u8>) -> Self {
-        Self { data }
-    }
-}
-
-impl<'a> IntoIterator for &'a ListXAttr {
-    type Item = &'a CStr;
-    type IntoIter = ListXAttrIter<'a>;
-
-    fn into_iter(self) -> Self::IntoIter {
-        ListXAttrIter {
-            data: &self.data,
-            at: 0,
-        }
-    }
-}
-
-/// Iterator over the extended attribute entries in a `ListXAttr`.
-pub struct ListXAttrIter<'a> {
-    data: &'a [u8],
-    at: usize,
-}
-
-impl<'a> Iterator for ListXAttrIter<'a> {
-    type Item = &'a CStr;
-
-    fn next(&mut self) -> Option<&'a CStr> {
-        let data = &self.data[self.at..];
-        let next = data.iter().position(|b| *b == 0)? + 1;
-        self.at += next;
-        Some(unsafe { CStr::from_bytes_with_nul_unchecked(&data[..next]) })
-    }
-}
-
-/// Return a list of extended attributes accessible as an iterator over items of type `&CStr`.
-pub fn flistxattr(fd: RawFd) -> Result<ListXAttr, nix::errno::Errno> {
-    // Initial buffer size for the attribute list, if content does not fit
-    // it gets dynamically increased until big enough.
-    let mut size = 256;
-    let mut buffer = vec::undefined(size);
-    let mut bytes = unsafe {
-        libc::flistxattr(fd, buffer.as_mut_ptr() as *mut libc::c_char, buffer.len())
-    };
-    while bytes < 0 {
-        let err = Errno::last();
-        match err {
-            Errno::ERANGE => {
-                // Buffer was not big enough to fit the list, retry with double the size
-                size = size.checked_mul(2).ok_or(Errno::ENOMEM)?;
-            },
-            _ => return Err(err),
-        }
-        // Retry to read the list with new buffer
-        buffer.resize(size, 0);
-        bytes = unsafe {
-            libc::flistxattr(fd, buffer.as_mut_ptr() as *mut libc::c_char, buffer.len())
-        };
-    }
-    buffer.truncate(bytes as usize);
-
-    Ok(ListXAttr::new(buffer))
-}
-
-/// Get an extended attribute by name.
-///
-/// Extended attributes may not contain zeroes, which we enforce in the API by using a `&CStr`
-/// type.
-pub fn fgetxattr(fd: RawFd, name: &CStr) -> Result<Vec<u8>, nix::errno::Errno> {
-    let mut size = 256;
-    let mut buffer = vec::undefined(size);
-    let mut bytes = unsafe {
-        libc::fgetxattr(fd, name.as_ptr(), buffer.as_mut_ptr() as *mut core::ffi::c_void, buffer.len())
-    };
-    while bytes < 0 {
-        let err = Errno::last();
-        match err {
-            Errno::ERANGE => {
-                // Buffer was not big enough to fit the value, retry with double the size
-                size = size.checked_mul(2).ok_or(Errno::ENOMEM)?;
-            },
-            _ => return Err(err),
-        }
-        buffer.resize(size, 0);
-        bytes = unsafe {
-            libc::fgetxattr(fd, name.as_ptr() as *const libc::c_char, buffer.as_mut_ptr() as *mut core::ffi::c_void, buffer.len())
-        };
-    }
-    buffer.resize(bytes as usize, 0);
-
-    Ok(buffer)
-}
-
-/// Set an extended attribute on a file descriptor.
-pub fn fsetxattr(fd: RawFd, name: &CStr, data: &[u8]) -> Result<(), nix::errno::Errno> {
-    let flags = 0 as libc::c_int;
-    let result = unsafe {
-        libc::fsetxattr(fd, name.as_ptr(), data.as_ptr() as *const libc::c_void, data.len(), flags)
-    };
-    if result < 0 {
-        return Err(Errno::last());
-    }
-
-    Ok(())
-}
-
-pub fn fsetxattr_fcaps(fd: RawFd, fcaps: &[u8]) -> Result<(), nix::errno::Errno> {
-    // TODO casync checks and removes capabilities if they are set
-    fsetxattr(fd, xattr_name_fcaps(), fcaps)
-}
-
-pub fn is_security_capability(name: &CStr) -> bool {
-    name.to_bytes() == xattr_name_fcaps().to_bytes()
-}
-
-pub fn is_acl(name: &CStr) -> bool {
-    name.to_bytes() == xattr_acl_access().to_bytes()
-    || name.to_bytes() == xattr_acl_default().to_bytes()
-}
-
-/// Check if the passed name buffer starts with a valid xattr namespace prefix
-/// and is within the length limit of 255 bytes
-pub fn is_valid_xattr_name(c_name: &CStr) -> bool {
-    let name = c_name.to_bytes();
-    if name.is_empty() || name.len() > 255 {
-        return false;
-    }
-    if name.starts_with(b"user.") || name.starts_with(b"trusted.") {
-        return true;
-    }
-    // samba saves windows ACLs there
-    if name == b"security.NTACL" {
-        return true;
-    }
-    is_security_capability(c_name)
-}
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-
-    use std::ffi::CString;
-    use std::fs::OpenOptions;
-    use std::os::unix::io::AsRawFd;
-
-    use nix::errno::Errno;
-
-    use proxmox_lang::c_str;
-
-    #[test]
-    fn test_fsetxattr_fgetxattr() {
-        let path = "./test-xattrs.txt";
-        let file = OpenOptions::new()
-            .write(true)
-            .create(true)
-            .open(&path)
-            .unwrap();
-
-        let fd = file.as_raw_fd();
-
-        assert!(fsetxattr(fd, c_str!("user.attribute0"), b"value0").is_ok());
-        assert!(fsetxattr(fd, c_str!("user.empty"), b"").is_ok());
-
-        if nix::unistd::Uid::current() != nix::unistd::ROOT {
-            assert_eq!(fsetxattr(fd, c_str!("trusted.attribute0"), b"value0"), Err(Errno::EPERM));
-        }
-
-        let v0 = fgetxattr(fd, c_str!("user.attribute0")).unwrap();
-        let v1 = fgetxattr(fd, c_str!("user.empty")).unwrap();
-
-        assert_eq!(v0, b"value0".as_ref());
-        assert_eq!(v1, b"".as_ref());
-        assert_eq!(fgetxattr(fd, c_str!("user.attribute1")), Err(Errno::ENODATA));
-
-        std::fs::remove_file(&path).unwrap();
-    }
-
-    #[test]
-    fn test_is_valid_xattr_name() {
-        let too_long = CString::new(vec![b'a'; 265]).unwrap();
-
-        assert!(!is_valid_xattr_name(&too_long));
-        assert!(!is_valid_xattr_name(c_str!("system.attr")));
-        assert!(is_valid_xattr_name(c_str!("user.attr")));
-        assert!(is_valid_xattr_name(c_str!("trusted.attr")));
-        assert!(is_valid_xattr_name(super::xattr_name_fcaps()));
-    }
-}
index fcc86384f21470a53c227f3fcc750730dc35a11d..7a28959296f034ee6281b12b3b85a49133000900 100644 (file)
@@ -22,11 +22,12 @@ zstd = { version = "0.6", features = [ "bindgen" ] }
 pathpatterns = "0.1.2"
 pxar = { version = "0.10.1", features = [ "tokio-io" ] }
 
-proxmox = { version = "0.15.3", features = [ "sortable-macro" ] }
-proxmox-async = "0.2"
+proxmox-async = "0.3"
 proxmox-router = { version = "1.1", features = [ "cli" ] }
 proxmox-schema = { version = "1", features = [ "api-macro" ] }
 proxmox-time = "1"
+proxmox-sys = { version = "0.2",  features = [ "sortable-macro" ] }
+
 
 pbs-api-types = { path = "../pbs-api-types" }
 pbs-buildcfg = { path = "../pbs-buildcfg" }
index 58cdb4ad35b44b9feb92955ebf76daeafb5d824e..6a97b117c7132395d105830d4ed40deddb2d4df0 100644 (file)
@@ -267,7 +267,7 @@ fn test_crypt_speed(
 
     let crypt_config = CryptConfig::new(testkey)?;
 
-    //let random_data = proxmox::sys::linux::random_data(1024*1024)?;
+    //let random_data = proxmox_sys::linux::random_data(1024*1024)?;
     let mut random_data = vec![];
         // generate pseudo random byte sequence
         for i in 0..256*1024 {
index 0b99a888e3f6f62b7defad559a85f6f51b9750e8..427a58dfd4001b5cfa0fd1b0eec454126c2615df 100644 (file)
@@ -4,8 +4,8 @@ use std::path::PathBuf;
 use anyhow::{bail, format_err, Error};
 use serde_json::Value;
 
-use proxmox::sys::linux::tty;
-use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
+use proxmox_sys::linux::tty;
+use proxmox_sys::fs::{file_get_contents, replace_file, CreateOptions};
 use proxmox_router::cli::{
     complete_file_name, format_and_print_result_full, get_output_format,
     CliCommand, CliCommandMap, ColumnConfig,
@@ -54,7 +54,7 @@ fn create(kdf: Option<Kdf>, path: Option<String>, hint: Option<String>) -> Resul
     let kdf = kdf.unwrap_or_default();
 
     let mut key = [0u8; 32];
-    proxmox::sys::linux::fill_with_random_data(&mut key)?;
+    proxmox_sys::linux::fill_with_random_data(&mut key)?;
 
     match kdf {
         Kdf::None => {
index 199ab5820f2464084eb6ecb5f740606b36d5334a..3136f3f8e376ae45966114dbc9fd9007141eccec 100644 (file)
@@ -13,7 +13,7 @@ use tokio_stream::wrappers::ReceiverStream;
 use xdg::BaseDirectories;
 
 use pathpatterns::{MatchEntry, MatchType, PatternFlag};
-use proxmox::tools::fs::{file_get_json, replace_file, CreateOptions, image_size};
+use proxmox_sys::fs::{file_get_json, replace_file, CreateOptions, image_size};
 use proxmox_router::{ApiMethod, RpcEnvironment, cli::*};
 use proxmox_schema::api;
 use proxmox_time::{strftime_local, epoch_i64};
@@ -654,7 +654,7 @@ async fn create_backup(
 
     let crypto = crypto_parameters(&param)?;
 
-    let backup_id = param["backup-id"].as_str().unwrap_or(&proxmox::tools::nodename());
+    let backup_id = param["backup-id"].as_str().unwrap_or(&proxmox_sys::nodename());
 
     let backup_type = param["backup-type"].as_str().unwrap_or("host");
 
@@ -751,7 +751,7 @@ async fn create_backup(
 
     println!("Starting backup: {}/{}/{}", backup_type, backup_id, BackupDir::backup_time_to_string(backup_time)?);
 
-    println!("Client name: {}", proxmox::tools::nodename());
+    println!("Client name: {}", proxmox_sys::nodename());
 
     let start_time = std::time::Instant::now();
 
index f0759d1b69ebe65aa9bed788a95c3e6361692083..bc0bc8d5909efc0dc854ce9a1091ff4dafb835d6 100644 (file)
@@ -13,8 +13,8 @@ use nix::unistd::{fork, ForkResult};
 use serde_json::Value;
 use tokio::signal::unix::{signal, SignalKind};
 
-use proxmox::{sortable, identity};
-use proxmox::tools::fd::Fd;
+use proxmox_sys::{sortable, identity};
+use proxmox_sys::fd::Fd;
 use proxmox_router::{ApiHandler, ApiMethod, RpcEnvironment, cli::*};
 use proxmox_schema::*;
 
@@ -119,7 +119,7 @@ fn complete_mapping_names<S: BuildHasher>(_arg: &str, _param: &HashMap<String, S
     match pbs_fuse_loop::find_all_mappings() {
         Ok(mappings) => mappings
             .filter_map(|(name, _)| {
-                proxmox::tools::systemd::unescape_unit(&name).ok()
+                proxmox_sys::systemd::unescape_unit(&name).ok()
             }).collect(),
         Err(_) => Vec::new()
     }
@@ -280,7 +280,7 @@ async fn mount_do(param: Value, pipe: Option<Fd>) -> Result<Value, Error> {
         let reader = CachedChunkReader::new(chunk_reader, index, 8).seekable();
 
         let name = &format!("{}:{}/{}", repo.to_string(), path, archive_name);
-        let name_escaped = proxmox::tools::systemd::escape_unit(name, false);
+        let name_escaped = proxmox_sys::systemd::escape_unit(name, false);
 
         let mut session = pbs_fuse_loop::FuseLoopSession::map_loop(size, reader, &name_escaped, options).await?;
         let loopdev = session.loopdev_path.clone();
@@ -342,7 +342,7 @@ fn unmap(
             pbs_fuse_loop::cleanup_unused_run_files(None);
             let mut any = false;
             for (backing, loopdev) in pbs_fuse_loop::find_all_mappings()? {
-                let name = proxmox::tools::systemd::unescape_unit(&backing)?;
+                let name = proxmox_sys::systemd::unescape_unit(&backing)?;
                 println!("{}:\t{}", loopdev.unwrap_or_else(|| "(unmapped)".to_string()), name);
                 any = true;
             }
@@ -361,7 +361,7 @@ fn unmap(
     if name.starts_with("/dev/loop") {
         pbs_fuse_loop::unmap_loopdev(name)?;
     } else {
-        let name = proxmox::tools::systemd::escape_unit(&name, false);
+        let name = proxmox_sys::systemd::escape_unit(&name, false);
         pbs_fuse_loop::unmap_name(name)?;
     }
 
index a9976fbe2e01cc1fb6c12e172356530cbeed0a26..55c4c33370ba73b8d33467e6b2b0095d96f73200 100644 (file)
@@ -3,7 +3,7 @@ use std::sync::Arc;
 use anyhow::Error;
 use serde_json::{json, Value};
 
-use proxmox::tools::fs::file_get_contents;
+use proxmox_sys::fs::file_get_contents;
 use proxmox_router::cli::*;
 use proxmox_schema::api;
 
index b76400e8548e050f3c820b61a59772f2f0744b9c..0fe98efbe56924cc362a2eca5856540c2f553ee0 100644 (file)
@@ -16,14 +16,14 @@ tokio = { version = "1.6", features = [ "io-std", "rt", "rt-multi-thread", "time
 
 pxar = { version = "0.10.1", features = [ "tokio-io" ] }
 
-proxmox = { version = "0.15.3" }
-proxmox-async = "0.2"
+#proxmox = { version = "0.15.3" }
+proxmox-async = "0.3"
 proxmox-lang = "1"
 proxmox-router = { version = "1.1", features = [ "cli" ] }
 proxmox-schema = { version = "1", features = [ "api-macro" ] }
 proxmox-time = "1"
 proxmox-uuid = "1"
-proxmox-sys = "0.1.2"
+proxmox-sys = "0.2"
 
 pbs-api-types = { path = "../pbs-api-types" }
 pbs-buildcfg = { path = "../pbs-buildcfg" }
index 74296ab64ad243a52b70405d48ebea3708b1fab4..25a9b3fe444616afa51db12f546f2747f8ea1605 100644 (file)
@@ -8,7 +8,7 @@ use futures::FutureExt;
 use serde::{Deserialize, Serialize};
 use serde_json::json;
 
-use proxmox::tools::fs::lock_file;
+use proxmox_sys::fs::lock_file;
 
 use pbs_client::{DEFAULT_VSOCK_PORT, BackupRepository, VsockClient};
 use pbs_datastore::backup_info::BackupDir;
@@ -80,7 +80,7 @@ impl VMStateMap {
 
 fn make_name(repo: &BackupRepository, snap: &BackupDir) -> String {
     let full = format!("qemu_{}/{}", repo, snap);
-    proxmox::tools::systemd::escape_unit(&full, false)
+    proxmox_sys::systemd::escape_unit(&full, false)
 }
 
 /// remove non-responsive VMs from given map, returns 'true' if map was modified
@@ -257,7 +257,7 @@ impl BlockRestoreDriver for QemuBlockDriver {
                 let resp = client
                     .get("api2/json/status", Some(json!({"keep-timeout": true})))
                     .await;
-                let name = proxmox::tools::systemd::unescape_unit(n)
+                let name = proxmox_sys::systemd::unescape_unit(n)
                     .unwrap_or_else(|_| "<invalid name>".to_owned());
                 let mut extra = json!({"pid": s.pid, "cid": s.cid});
 
@@ -295,7 +295,7 @@ impl BlockRestoreDriver for QemuBlockDriver {
 
     fn stop(&self, id: String) -> Async<Result<(), Error>> {
         async move {
-            let name = proxmox::tools::systemd::escape_unit(&id, false);
+            let name = proxmox_sys::systemd::escape_unit(&id, false);
             let mut map = VMStateMap::load()?;
             let map_mod = cleanup_map(&mut map.map).await;
             match map.map.get(&name) {
@@ -325,7 +325,7 @@ impl BlockRestoreDriver for QemuBlockDriver {
         match VMStateMap::load_read_only() {
             Ok(state) => state
                 .iter()
-                .filter_map(|(name, _)| proxmox::tools::systemd::unescape_unit(&name).ok())
+                .filter_map(|(name, _)| proxmox_sys::systemd::unescape_unit(&name).ok())
                 .collect(),
             Err(_) => Vec::new(),
         }
index c266d014bf3e98c43ab2452c4d910151bdf1d622..84aacf6579c9f58fa29f62bf90a80f1b41c1cd4f 100644 (file)
@@ -6,7 +6,7 @@ use std::sync::Arc;
 use anyhow::{bail, format_err, Error};
 use serde_json::{json, Value};
 
-use proxmox::tools::fs::{create_path, CreateOptions};
+use proxmox_sys::fs::{create_path, CreateOptions};
 use proxmox_router::cli::{
     complete_file_name, default_table_format_options,
     format_and_print_result_full, get_output_format,
index 6b82c5eed957f5b96daa0c7acc076d16dcfd5124..eb68f78e2baf30b3206b1e076c89f79f770de9de 100644 (file)
@@ -11,8 +11,8 @@ use tokio::time;
 use nix::sys::signal::{kill, Signal};
 use nix::unistd::Pid;
 
-use proxmox::tools::fs::{create_path, file_read_string, make_tmp_file, CreateOptions};
-use proxmox::tools::fd::fd_change_cloexec;
+use proxmox_sys::fs::{create_path, file_read_string, make_tmp_file, CreateOptions};
+use proxmox_sys::fd::fd_change_cloexec;
 use proxmox_sys::logrotate::LogRotate;
 
 use pbs_client::{VsockClient, DEFAULT_VSOCK_PORT};
index 4102bc0aa21155a76b91a5d1b14f585795610754..c355368f883e3cdd15ccfd0b5050653f119ce813 100644 (file)
@@ -30,12 +30,12 @@ tokio-openssl = "0.6.1"
 tower-service = "0.3.0"
 url = "2.1"
 
-proxmox = "0.15.3"
-proxmox-async = "0.2"
+#proxmox = "0.15.3"
+proxmox-async = "0.3"
 proxmox-io = "1"
 proxmox-lang = "1"
-proxmox-http = { version = "0.5.0", features = [ "client" ] }
+proxmox-http = { version = "0.6", features = [ "client" ] }
 proxmox-router = "1.1"
 proxmox-schema = { version = "1", features = [ "api-macro", "upid-api-impl" ] }
 proxmox-time = "1"
-proxmox-sys = "0.1.2"
+proxmox-sys = "0.2"
index 990315dd9eb23f941d83357ff8d9478838f1fdfd..4c56f6575ba9e7b87243f9a7fbdfc3413f67c842 100644 (file)
@@ -12,7 +12,7 @@ use hyper::http::request::Parts;
 use handlebars::Handlebars;
 use serde::Serialize;
 
-use proxmox::tools::fs::{create_path, CreateOptions};
+use proxmox_sys::fs::{create_path, CreateOptions};
 use proxmox_router::{ApiMethod, Router, RpcEnvironmentType, UserInformation};
 
 use crate::{ServerAdapter, AuthError, FileLogger, FileLogOptions, CommandSocket, RestEnvironment};
index c533b0f4e0f18ec0348e192daa61fa13de099f37..973cd30656b42ca327f3c7b8e47a0b750de1d32b 100644 (file)
@@ -13,7 +13,7 @@ use anyhow::{bail, format_err, Error};
 use futures::future::{self, Either};
 use nix::unistd::{fork, ForkResult};
 
-use proxmox::tools::fd::{fd_change_cloexec, Fd};
+use proxmox_sys::fd::{fd_change_cloexec, Fd};
 use proxmox_io::{ReadExt, WriteExt};
 
 // Unfortunately FnBox is nightly-only and Box<FnOnce> is unusable, so just use Box<Fn>...
@@ -129,14 +129,14 @@ impl Reloader {
                             let ident = ident.as_bytes();
                             let fd = unsafe { sd_journal_stream_fd(ident.as_ptr(), libc::LOG_INFO, 1) };
                             if fd >= 0 && fd != 1 {
-                                let fd = proxmox::tools::fd::Fd(fd); // add drop handler
+                                let fd = proxmox_sys::fd::Fd(fd); // add drop handler
                                 nix::unistd::dup2(fd.as_raw_fd(), 1)?;
                             } else {
                                 log::error!("failed to update STDOUT journal redirection ({})", fd);
                             }
                             let fd = unsafe { sd_journal_stream_fd(ident.as_ptr(), libc::LOG_ERR, 1) };
                             if fd >= 0 && fd != 2 {
-                                let fd = proxmox::tools::fd::Fd(fd); // add drop handler
+                                let fd = proxmox_sys::fd::Fd(fd); // add drop handler
                                 nix::unistd::dup2(fd.as_raw_fd(), 2)?;
                             } else {
                                 log::error!("failed to update STDERR journal redirection ({})", fd);
index c74968744920aeb19cdae386808bdcf7bfc6fb9e..7d4d3f86bf326717ef0188c2d212c3cf3fe777d0 100644 (file)
@@ -3,7 +3,7 @@ use std::io::Write;
 use anyhow::Error;
 use nix::fcntl::OFlag;
 
-use proxmox::tools::fs::{CreateOptions, atomic_open_or_create_file};
+use proxmox_sys::fs::{CreateOptions, atomic_open_or_create_file};
 
 /// Options to control the behavior of a [FileLogger] instance
 #[derive(Default)]
index 1a6d827db45f3e435cd68acda2f2f2af9b35efcc..474827a3ca0770f9d43ab8d44f45fc3d7de3972c 100644 (file)
@@ -25,9 +25,9 @@ use hyper::{Body, Response, Method};
 use http::request::Parts;
 use http::HeaderMap;
 
-use proxmox::tools::fd::Fd;
-use proxmox::sys::linux::procfs::PidStat;
-use proxmox::tools::fs::CreateOptions;
+use proxmox_sys::fd::Fd;
+use proxmox_sys::linux::procfs::PidStat;
+use proxmox_sys::fs::CreateOptions;
 use proxmox_router::UserInformation;
 
 mod compression;
@@ -117,12 +117,12 @@ pub(crate) fn pstart() -> u64 {
 /// Helper to write the PID into a file
 pub fn write_pid(pid_fn: &str) -> Result<(), Error> {
     let pid_str = format!("{}\n", *PID);
-    proxmox::tools::fs::replace_file(pid_fn, pid_str.as_bytes(), CreateOptions::new(), false)
+    proxmox_sys::fs::replace_file(pid_fn, pid_str.as_bytes(), CreateOptions::new(), false)
 }
 
 /// Helper to read the PID from a file
 pub fn read_pid(pid_fn: &str) -> Result<i32, Error> {
-    let pid = proxmox::tools::fs::file_get_contents(pid_fn)?;
+    let pid = proxmox_sys::fs::file_get_contents(pid_fn)?;
     let pid = std::str::from_utf8(&pid)?.trim();
     pid.parse().map_err(|err| format_err!("could not parse pid - {}", err))
 }
index 3a091026e85fcf1335fe40e29697732c5f3c7c2b..86bdcbbeb9d714f01c534586c6d923ccf14bce8f 100644 (file)
@@ -479,7 +479,7 @@ pub(crate) async fn handle_api_request<Env: RpcEnvironment, S: 'static + BuildHa
             resp.map(|body| {
                 Body::wrap_stream(DeflateEncoder::with_quality(
                     TryStreamExt::map_err(body, |err| {
-                        proxmox::io_format_err!("error during compression: {}", err)
+                        proxmox_sys::io_format_err!("error during compression: {}", err)
                     }),
                     Level::Default,
                 ))
index a83679deee7711bbe4be16c316c542cfd891ace5..febd545a4c436f9053d1ca64cd0b0b81fca35273 100644 (file)
@@ -16,12 +16,12 @@ use tokio::sync::oneshot;
 use nix::fcntl::OFlag;
 use once_cell::sync::OnceCell;
 
-use proxmox::sys::linux::procfs;
-use proxmox::tools::fs::{create_path, replace_file, atomic_open_or_create_file, CreateOptions};
+use proxmox_sys::linux::procfs;
+use proxmox_sys::fs::{create_path, replace_file, atomic_open_or_create_file, CreateOptions};
 use proxmox_lang::try_block;
 use proxmox_schema::upid::UPID;
 
-use proxmox_sys::worker_task_context::{WorkerTaskContext};
+use proxmox_sys::WorkerTaskContext;
 use proxmox_sys::logrotate::{LogRotate, LogRotateFiles};
 
 use crate::{CommandSocket, FileLogger, FileLogOptions};
@@ -79,7 +79,7 @@ impl WorkerTaskSetup {
 
         let timeout = std::time::Duration::new(10, 0);
 
-        let file = proxmox::tools::fs::open_file_locked(
+        let file = proxmox_sys::fs::open_file_locked(
             &self.task_lock_fn,
             timeout,
             exclusive,
index 1484439d880026c5057d02c5e77a404ddd13059e..fe8b031f144b5a346f6681178f4e3c799ac0f42e 100644 (file)
@@ -26,11 +26,11 @@ tokio-util = { version = "0.6", features = [ "codec", "io" ] }
 pathpatterns = "0.1.2"
 pxar = { version = "0.10.1", features = [ "tokio-io" ] }
 
-proxmox = { version = "0.15.3", features = [ "sortable-macro" ] }
-proxmox-async = "0.2"
+proxmox-async = "0.3"
 proxmox-router = { version = "1.1", features = [ "cli" ] }
 proxmox-schema = { version = "1", features = [ "api-macro" ] }
 proxmox-time = "1"
+proxmox-sys = { version = "0.2",  features = [ "sortable-macro" ] }
 
 pbs-api-types = { path = "../pbs-api-types" }
 pbs-tools = { path = "../pbs-tools" }
index 129a18facff2815beb2e3e22cdd5892599a758ff..224b1b90d9ac370260f774dad7704aa0f2eeb609 100644 (file)
@@ -13,18 +13,18 @@ use serde_json::Value;
 use tokio::sync::Semaphore;
 
 use pathpatterns::{MatchEntry, MatchPattern, MatchType, Pattern};
-use proxmox::{identity, sortable};
 use proxmox_router::{
     list_subdirs_api_method,
     ApiHandler, ApiMethod, ApiResponseFuture, Permission, Router, RpcEnvironment, SubdirMap,
 };
 use proxmox_schema::*;
 use proxmox_async::zip::zip_directory;
+use proxmox_sys::fs::read_subdir;
+use proxmox_sys::{identity, sortable};
 
 use pbs_api_types::file_restore::RestoreDaemonStatus;
 use pbs_client::pxar::{create_archive, Flags, PxarCreateOptions, ENCODER_MAX_ENTRIES};
 use pbs_datastore::catalog::{ArchiveEntry, DirEntryAttribute};
-use pbs_tools::fs::read_subdir;
 use pbs_tools::json::required_string_param;
 
 use pxar::encoder::aio::TokioWriter;
index b1b247aa40887c315fa4aa61b2b3b5c9c5e00ff3..b68700b0298d724a6c3e5f17a846eeeab6355e2a 100644 (file)
@@ -9,11 +9,11 @@ use anyhow::{bail, format_err, Error};
 use lazy_static::lazy_static;
 use log::{info, warn};
 
-use proxmox::tools::fs;
+use proxmox_sys::fs;
+use proxmox_sys::command::run_command;
 use proxmox_schema::const_regex;
 
 use pbs_api_types::BLOCKDEVICE_NAME_REGEX;
-use pbs_tools::run_command;
 
 const_regex! {
     VIRTIO_PART_REGEX = r"^vd[a-z]+(\d+)$";
@@ -371,7 +371,7 @@ impl DiskState {
 
         // create mapping for virtio drives and .fidx files (via serial description)
         // note: disks::DiskManager relies on udev, which we don't have
-        for entry in pbs_tools::fs::scan_subdir(
+        for entry in proxmox_sys::fs::scan_subdir(
             libc::AT_FDCWD,
             "/sys/block",
             &BLOCKDEVICE_NAME_REGEX,
@@ -416,7 +416,7 @@ impl DiskState {
             }
 
             let mut parts = Vec::new();
-            for entry in pbs_tools::fs::scan_subdir(
+            for entry in proxmox_sys::fs::scan_subdir(
                 libc::AT_FDCWD,
                 sys_path,
                 &VIRTIO_PART_REGEX,
index 8e9d1b77122f53e264530bf0dc197618740dc024..3e47ea00fb5e445ac0e0cebcfd13a87fc219764a 100644 (file)
@@ -19,6 +19,7 @@ serde = { version = "1.0", features = ["derive"] }
 serde_json = "1.0"
 serde_cbor = "0.11.1"
 
-proxmox = { version = "0.15.3" }
+#proxmox = { version = "0.15.3" }
 proxmox-time = "1"
 proxmox-schema = { version = "1", features = [ "api-macro" ] }
+proxmox-sys = "0.2"
\ No newline at end of file
index e00e5a0e290189115d3c82e8cb7cccc4bc647de6..6b6f59cef148c121bd333d9d65531f7b0ca31f2b 100644 (file)
@@ -11,7 +11,7 @@ use proxmox_router::cli::{run_cli_command, complete_file_name, CliCommand, CliCo
 use proxmox_schema::{api, parse_property_string};
 use proxmox_schema::{ApiStringFormat, ApiType, IntegerSchema, Schema, StringSchema};
 
-use proxmox::tools::fs::CreateOptions;
+use proxmox_sys::fs::CreateOptions;
 
 use proxmox_rrd::rrd::{CF, DST, RRA, RRD};
 
index 9bbd89ded905f3d70ba8ab523c070520043081c3..b786f14f8a95e8c95cc87e21f8999d72dd06d72c 100644 (file)
@@ -10,7 +10,7 @@ use std::collections::BTreeSet;
 use crossbeam_channel::{bounded, TryRecvError};
 use anyhow::{format_err, bail, Error};
 
-use proxmox::tools::fs::{create_path, CreateOptions};
+use proxmox_sys::fs::{create_path, CreateOptions};
 
 use crate::rrd::{DST, CF, RRD, RRA};
 
index a85154a4ed68d9159ef1c9fd12e01277f51ca337..fbc8773cd90646a2b5d066ff189ea10141f8befd 100644 (file)
@@ -10,7 +10,7 @@ use anyhow::{bail, format_err, Error};
 use nix::fcntl::OFlag;
 use crossbeam_channel::Receiver;
 
-use proxmox::tools::fs::atomic_open_or_create_file;
+use proxmox_sys::fs::atomic_open_or_create_file;
 
 const RRD_JOURNAL_NAME: &str = "rrd.journal";
 
index 6f7686d614b41c99a2e0e2606c4ce0e26016dc23..6577fb2e820e9f1aaf119b283730f6a1b1cd736f 100644 (file)
@@ -4,7 +4,7 @@ use std::collections::HashMap;
 
 use anyhow::{bail, Error};
 
-use proxmox::tools::fs::create_path;
+use proxmox_sys::fs::create_path;
 
 use crate::rrd::{CF, DST, RRD};
 
index 2fab9df33ed618d5dad1d7c20583b1765b918328..2aebe1ae78890adf782bce9a25e4d1b18fa74777 100644 (file)
@@ -18,7 +18,7 @@ use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd};
 use anyhow::{bail, format_err, Error};
 use serde::{Serialize, Deserialize};
 
-use proxmox::tools::fs::{make_tmp_file, CreateOptions};
+use proxmox_sys::fs::{make_tmp_file, CreateOptions};
 use proxmox_schema::api;
 
 use crate::rrd_v1;
index b0e0e894f118d9e3167d62282f325de46249a5d6..81e49ca3f1deaab9abca70ef0e026b78fb2908a3 100644 (file)
@@ -4,7 +4,7 @@ use std::process::Command;
 use anyhow::{bail, Error};
 
 use proxmox_rrd::rrd::RRD;
-use proxmox::tools::fs::CreateOptions;
+use proxmox_sys::fs::CreateOptions;
 
 fn compare_file(fn1: &str, fn2: &str) -> Result<(), Error> {
 
index ca86e601dc9737d20bf707f735aa358293a9dcd0..4f0298451953115233d48c6720e2c32c630b3497 100644 (file)
@@ -16,10 +16,11 @@ serde_json = "1.0"
 tokio = { version = "1.6", features = [ "rt", "rt-multi-thread" ] }
 
 pathpatterns = "0.1.2"
-proxmox = "0.15.3"
-proxmox-async = "0.2"
+#proxmox = "0.15.3"
+proxmox-async = "0.3"
 proxmox-schema = { version = "1", features = [ "api-macro" ] }
 proxmox-router = "1.1"
+proxmox-sys = "0.2"
 pxar = { version = "0.10.1", features = [ "tokio-io" ] }
 
 pbs-client = { path = "../pbs-client" }
index cb31bf75c07e98c0457e0bd08332ca71c2fffef5..5bbd4e6da8df653dc777ace6a2ed4a2d1845c282 100644 (file)
@@ -150,7 +150,7 @@ fn extract_archive(
 
     let mut match_list = Vec::new();
     if let Some(filename) = &files_from {
-        for line in pbs_tools::fs::file_get_non_comment_lines(filename)? {
+        for line in proxmox_sys::fs::file_get_non_comment_lines(filename)? {
             let line = line
                 .map_err(|err| format_err!("error reading {}: {}", filename, err))?;
             match_list.push(
index 8d6cf6bd5c1da1ea37a2fad1d67adb688422d861..be07b26f8c5c07a4b328f6a8d6fbc2ed28faf556 100644 (file)
@@ -10,7 +10,7 @@ use hyper::{Body, Request};
 use nix::sys::stat::Mode;
 use serde::{Deserialize, Serialize};
 
-use proxmox::tools::fs::{replace_file, CreateOptions};
+use proxmox_sys::fs::{replace_file, CreateOptions};
 use proxmox_acme_rs::account::AccountCreator;
 use proxmox_acme_rs::account::AccountData as AcmeAccountData;
 use proxmox_acme_rs::order::{Order, OrderData};
index 8562b7359ab5254feb5db68b031ba4f8e130a2ea..41810cc31bba53080038d68e22069b46e0544761 100644 (file)
@@ -1,6 +1,7 @@
 //! Manage Access Control Lists
 
 use anyhow::{bail, Error};
+use hex::FromHex;
 
 use proxmox_router::{Router, RpcEnvironment, Permission};
 use proxmox_schema::api;
@@ -126,7 +127,7 @@ pub fn read_acl(
         extract_acl_node_data(&tree.root, "", &mut list, exact, &auth_id_filter);
     }
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(list)
 }
@@ -210,7 +211,7 @@ pub fn update_acl(
     let (mut tree, expected_digest) = pbs_config::acl::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
index 0d95a65ddefc46616e4e6e9981dde9c28f159efe..fda6baa5772bcad5fa22b3881912d217391553a9 100644 (file)
@@ -89,7 +89,7 @@ fn list_domains(mut rpcenv: &mut dyn RpcEnvironment) -> Result<Vec<BasicRealmInf
         list.push(serde_json::from_value(entry)?);
     }
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(list)
 }
index 71eb760e63277b2a12c46c702f5fb9f45e5a1c02..d78f0fa03fc88e6dbf433c836ba2481862cb82ee 100644 (file)
@@ -6,7 +6,7 @@ use serde_json::{json, Value};
 use std::collections::HashMap;
 use std::collections::HashSet;
 
-use proxmox::{identity, sortable};
+use proxmox_sys::{identity, sortable};
 use proxmox_router::{
     http_err, list_subdirs_api_method, Router, RpcEnvironment, SubdirMap, Permission,
 };
index 6424b47f8e9e05960338ec558d45da1ab238a47a..0d9bc8426ab057122417d757148796d99571500c 100644 (file)
@@ -2,10 +2,9 @@
 use std::convert::TryFrom;
 
 use anyhow::{bail, format_err, Error};
-
 use serde_json::{json, Value};
 
-use proxmox::{identity, sortable};
+use proxmox_sys::{identity, sortable};
 use proxmox_router::{
     http_err, list_subdirs_api_method, Router, RpcEnvironment, SubdirMap, Permission,
 };
index 37fce461f09647cd79f1de3abc1038f8b69f3154..a0ecbd89588584a32c82efc60206e17e2c826353 100644 (file)
@@ -4,6 +4,7 @@ use anyhow::{bail, format_err, Error};
 use serde::{Serialize, Deserialize};
 use serde_json::{json, Value};
 use std::collections::HashMap;
+use hex::FromHex;
 
 use proxmox_router::{ApiMethod, Router, RpcEnvironment, SubdirMap, Permission};
 use proxmox_schema::api;
@@ -80,7 +81,7 @@ pub fn list_users(
 
     let list:Vec<User> = config.convert_to_typed_array("user")?;
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     let iter = list.into_iter().filter(filter_by_privs);
     let list = if include_tokens {
@@ -187,7 +188,7 @@ pub fn create_user(
 pub fn read_user(userid: Userid, mut rpcenv: &mut dyn RpcEnvironment) -> Result<User, Error> {
     let (config, digest) = pbs_config::user::config()?;
     let user = config.lookup("user", userid.as_str())?;
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
     Ok(user)
 }
 
@@ -258,7 +259,7 @@ pub fn update_user(
     let (mut config, expected_digest) = pbs_config::user::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
@@ -351,7 +352,7 @@ pub fn delete_user(userid: Userid, digest: Option<String>) -> Result<(), Error>
     let (mut config, expected_digest) = pbs_config::user::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
@@ -421,7 +422,7 @@ pub fn read_token(
 
     let tokenid = Authid::from((userid, Some(token_name)));
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
     config.lookup("token", &tokenid.to_string())
 }
 
@@ -488,7 +489,7 @@ pub fn generate_token(
     let (mut config, expected_digest) = pbs_config::user::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
@@ -569,7 +570,7 @@ pub fn update_token(
     let (mut config, expected_digest) = pbs_config::user::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
@@ -637,7 +638,7 @@ pub fn delete_token(
     let (mut config, expected_digest) = pbs_config::user::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
@@ -703,7 +704,7 @@ pub fn list_tokens(
 
     let list:Vec<ApiToken> = config.convert_to_typed_array("token")?;
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     let filter_by_owner = |token: ApiToken| {
         if token.tokenid.is_token() && token.tokenid.user() == &userid {
index 5e5051b8403075a4a0d6b6494b1134a1160ae796..d36d793de4c1e5975a194b8990418f48b6cd5e30 100644 (file)
@@ -12,8 +12,8 @@ use hyper::{header, Body, Response, StatusCode};
 use serde_json::{json, Value};
 use tokio_stream::wrappers::ReceiverStream;
 
-use proxmox::{identity, sortable};
-use proxmox::tools::fs::{
+use proxmox_sys::{identity, sortable};
+use proxmox_sys::fs::{
     file_read_firstline, file_read_optional_string, replace_file, CreateOptions,
 };
 use proxmox_router::{
index 12a358d15232b7a8a48cb7e4fa319e027140356a..a5e107e98dd465dd51172604f9d071923f5d9637 100644 (file)
@@ -3,7 +3,7 @@
 use anyhow::{bail, format_err, Error};
 use serde_json::Value;
 
-use proxmox::sortable;
+use proxmox_sys::sortable;
 use proxmox_router::{
     list_subdirs_api_method, ApiMethod, Router, RpcEnvironment, RpcEnvironmentType, SubdirMap,
     Permission,
@@ -87,7 +87,7 @@ pub fn list_sync_jobs(
         list.push(SyncJobStatus { config: job, status });
     }
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(list)
 }
index a3958e062150b14ae1fd6608e3c4bc2143636b5b..8585986f229a444a82d3a62f5513cce16b371d41 100644 (file)
@@ -66,7 +66,7 @@ pub fn show_current_traffic(
     }
 
     // also return the configuration digest
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(list)
 }
index 2a217b65025132d069f1635a071ff6c1343d4793..8e481cc301d5a596f7d890dba455bb5214935a11 100644 (file)
@@ -3,7 +3,7 @@
 use anyhow::{format_err, Error};
 use serde_json::Value;
 
-use proxmox::sortable;
+use proxmox_sys::sortable;
 use proxmox_router::{
     list_subdirs_api_method, ApiMethod, Router, RpcEnvironment, RpcEnvironmentType, SubdirMap,
     Permission,
@@ -87,7 +87,7 @@ pub fn list_verification_jobs(
         list.push(VerificationJobStatus { config: job, status });
     }
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(list)
 }
index 9cfc55342ee6ed29dca3ef2b33d28c1e401250b6..c15af07a0f50333a3d76a6533571e0c7c53196e9 100644 (file)
@@ -6,8 +6,7 @@ use nix::dir::Dir;
 use ::serde::{Serialize};
 use serde_json::{json, Value};
 
-use proxmox::tools::digest_to_hex;
-use proxmox::tools::fs::{replace_file, CreateOptions};
+use proxmox_sys::fs::{replace_file, CreateOptions};
 use proxmox_router::{RpcEnvironment, RpcEnvironmentType};
 
 use pbs_datastore::{DataStore, DataBlob};
@@ -331,8 +330,8 @@ impl BackupEnvironment {
 
     fn log_upload_stat(&self, archive_name:  &str, csum: &[u8; 32], uuid: &[u8; 16], size: u64, chunk_count: u64, upload_stat: &UploadStatistic) {
         self.log(format!("Upload statistics for '{}'", archive_name));
-        self.log(format!("UUID: {}", digest_to_hex(uuid)));
-        self.log(format!("Checksum: {}", digest_to_hex(csum)));
+        self.log(format!("UUID: {}", hex::encode(uuid)));
+        self.log(format!("Checksum: {}", hex::encode(csum)));
         self.log(format!("Size: {}", size));
         self.log(format!("Chunk count: {}", chunk_count));
 
index 3a902e7af9a72341507576762f4a56fcbb264307..6570d164be6394d5623c651e7aee1d5d851b880b 100644 (file)
@@ -6,8 +6,9 @@ use hyper::header::{HeaderValue, UPGRADE};
 use hyper::http::request::Parts;
 use hyper::{Body, Response, Request, StatusCode};
 use serde_json::{json, Value};
+use hex::FromHex;
 
-use proxmox::{sortable, identity};
+use proxmox_sys::{sortable, identity};
 use proxmox_router::list_subdirs_api_method;
 use proxmox_router::{
     ApiResponseFuture, ApiHandler, ApiMethod, Router, RpcEnvironment, SubdirMap, Permission,
@@ -19,7 +20,7 @@ use pbs_api_types::{
     BACKUP_ID_SCHEMA, BACKUP_TIME_SCHEMA, BACKUP_TYPE_SCHEMA, DATASTORE_SCHEMA,
     CHUNK_DIGEST_SCHEMA, PRIV_DATASTORE_BACKUP, BACKUP_ARCHIVE_NAME_SCHEMA,
 };
-use pbs_tools::fs::lock_dir_noblock_shared;
+use proxmox_sys::fs::lock_dir_noblock_shared;
 use pbs_tools::json::{required_array_param, required_integer_param, required_string_param};
 use pbs_config::CachedUserInfo;
 use pbs_datastore::{DataStore, PROXMOX_BACKUP_PROTOCOL_ID_V1};
@@ -433,7 +434,7 @@ fn create_fixed_index(
         };
 
         let (old_csum, _) = index.compute_csum();
-        let old_csum = proxmox::tools::digest_to_hex(&old_csum);
+        let old_csum = hex::encode(&old_csum);
         if old_csum != csum {
             bail!("expected csum ({}) doesn't match last backup's ({}), cannot do incremental backup",
                 csum, old_csum);
@@ -508,7 +509,7 @@ fn dynamic_append (
 
     for (i, item) in digest_list.iter().enumerate() {
         let digest_str = item.as_str().unwrap();
-        let digest = proxmox::tools::hex_to_digest(digest_str)?;
+        let digest = <[u8; 32]>::from_hex(digest_str)?;
         let offset = offset_list[i].as_u64().unwrap();
         let size = env.lookup_chunk(&digest).ok_or_else(|| format_err!("no such chunk {}", digest_str))?;
 
@@ -573,7 +574,7 @@ fn fixed_append (
 
     for (i, item) in digest_list.iter().enumerate() {
         let digest_str = item.as_str().unwrap();
-        let digest = proxmox::tools::hex_to_digest(digest_str)?;
+        let digest = <[u8; 32]>::from_hex(digest_str)?;
         let offset = offset_list[i].as_u64().unwrap();
         let size = env.lookup_chunk(&digest).ok_or_else(|| format_err!("no such chunk {}", digest_str))?;
 
@@ -628,7 +629,7 @@ fn close_dynamic_index (
     let chunk_count = required_integer_param(&param, "chunk-count")? as u64;
     let size = required_integer_param(&param, "size")? as u64;
     let csum_str = required_string_param(&param, "csum")?;
-    let csum = proxmox::tools::hex_to_digest(csum_str)?;
+    let csum = <[u8; 32]>::from_hex(csum_str)?;
 
     let env: &BackupEnvironment = rpcenv.as_ref();
 
@@ -682,7 +683,7 @@ fn close_fixed_index (
     let chunk_count = required_integer_param(&param, "chunk-count")? as u64;
     let size = required_integer_param(&param, "size")? as u64;
     let csum_str = required_string_param(&param, "csum")?;
-    let csum = proxmox::tools::hex_to_digest(csum_str)?;
+    let csum = <[u8; 32]>::from_hex(csum_str)?;
 
     let env: &BackupEnvironment = rpcenv.as_ref();
 
index 604a4edeecee1e6aff276c1aecb1cbb16031eb78..c867259a4fbbbe61d7663f489591d8e54f98c89b 100644 (file)
@@ -7,8 +7,9 @@ use futures::*;
 use hyper::Body;
 use hyper::http::request::Parts;
 use serde_json::{json, Value};
+use hex::FromHex;
 
-use proxmox::{sortable, identity};
+use proxmox_sys::{sortable, identity};
 use proxmox_router::{ApiResponseFuture, ApiHandler, ApiMethod, RpcEnvironment};
 use proxmox_schema::*;
 
@@ -127,7 +128,7 @@ fn upload_fixed_chunk(
         let encoded_size = required_integer_param(&param, "encoded-size")? as u32;
 
         let digest_str = required_string_param(&param, "digest")?;
-        let digest = proxmox::tools::hex_to_digest(digest_str)?;
+        let digest = <[u8; 32]>::from_hex(digest_str)?;
 
         let env: &BackupEnvironment = rpcenv.as_ref();
 
@@ -135,7 +136,7 @@ fn upload_fixed_chunk(
             UploadChunk::new(req_body, env.datastore.clone(), digest, size, encoded_size).await?;
 
         env.register_fixed_chunk(wid, digest, size, compressed_size, is_duplicate)?;
-        let digest_str = proxmox::tools::digest_to_hex(&digest);
+        let digest_str = hex::encode(&digest);
         env.debug(format!("upload_chunk done: {} bytes, {}", size, digest_str));
 
         let result = Ok(json!(digest_str));
@@ -185,7 +186,7 @@ fn upload_dynamic_chunk(
         let encoded_size = required_integer_param(&param, "encoded-size")? as u32;
 
         let digest_str = required_string_param(&param, "digest")?;
-        let digest = proxmox::tools::hex_to_digest(digest_str)?;
+        let digest = <[u8; 32]>::from_hex(digest_str)?;
 
         let env: &BackupEnvironment = rpcenv.as_ref();
 
@@ -194,7 +195,7 @@ fn upload_dynamic_chunk(
             .await?;
 
         env.register_dynamic_chunk(wid, digest, size, compressed_size, is_duplicate)?;
-        let digest_str = proxmox::tools::digest_to_hex(&digest);
+        let digest_str = hex::encode(&digest);
         env.debug(format!("upload_chunk done: {} bytes, {}", size, digest_str));
 
         let result = Ok(json!(digest_str));
index 6b9a12b576de47f34402acb6c5c0090d60a4ed5f..8cb03cd76eeaa40f4906ff8764a0793e22679b1d 100644 (file)
@@ -1,6 +1,6 @@
 use proxmox_router::{Router, SubdirMap};
 use proxmox_router::list_subdirs_api_method;
-use proxmox::{identity, sortable};
+use proxmox_sys::{identity, sortable};
 
 pub mod tfa;
 pub mod openid;
index b5501f67ce6a8309dc136dcccd1f430a031c77cf..25dfffbf900201c3407972a2fcc4b6fabd7f3edc 100644 (file)
@@ -3,6 +3,7 @@
 use anyhow::{bail, Error};
 use serde_json::Value;
 use ::serde::{Deserialize, Serialize};
+use hex::FromHex;
 
 use proxmox_router::{Router, RpcEnvironment, Permission};
 use proxmox_schema::api;
@@ -37,7 +38,7 @@ pub fn list_openid_realms(
 
     let list = config.convert_to_typed_array("openid")?;
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(list)
 }
@@ -106,7 +107,7 @@ pub fn delete_openid_realm(
     let (mut domains, expected_digest) = domains::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
@@ -142,7 +143,7 @@ pub fn read_openid_realm(
 
     let config = domains.lookup("openid", &realm)?;
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(config)
 }
@@ -211,7 +212,7 @@ pub fn update_openid_realm(
     let (mut domains, expected_digest) = domains::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
index e84016e369c87d6a6a63ff1f2d54a74dd94ba5d5..f4720f41f3a64920f9f5131801f50d2ce72419d0 100644 (file)
@@ -2,6 +2,7 @@
 //! If we add more, it should be moved into a sub module.
 
 use anyhow::Error;
+use hex::FromHex;
 
 use proxmox_router::{Router, RpcEnvironment, Permission, SubdirMap};
 use proxmox_schema::api;
@@ -42,7 +43,7 @@ pub fn get_webauthn_config(
         Some(c) => c,
         None => return Ok(None),
     };
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
     Ok(Some(config))
 }
 
@@ -72,7 +73,7 @@ pub fn update_webauthn_config(
 
     if let Some(wa) = &mut tfa.webauthn {
         if let Some(ref digest) = digest {
-            let digest = proxmox::tools::hex_to_digest(digest)?;
+            let digest = <[u8; 32]>::from_hex(digest)?;
             crate::tools::detect_modified_configuration_file(
                 &digest,
                 &crate::config::tfa::webauthn_config_digest(&wa)?,
index c917122110cff06d43969869b7b82c5b611d5e66..e8fab85c7271db142552eb19ce90342781a9eff0 100644 (file)
@@ -8,6 +8,7 @@ use anyhow::{bail, format_err, Error};
 use lazy_static::lazy_static;
 use serde::{Deserialize, Serialize};
 use serde_json::{json, Value};
+use hex::FromHex;
 
 use proxmox_router::{
     http_bail, list_subdirs_api_method, Permission, Router, RpcEnvironment, SubdirMap,
@@ -520,7 +521,7 @@ fn modify_cfg_for_api(id: &str, ty: &str, data: &Value) -> PluginConfig {
 /// List ACME challenge plugins.
 pub fn list_plugins(mut rpcenv: &mut dyn RpcEnvironment) -> Result<Vec<PluginConfig>, Error> {
     let (plugins, digest) = plugin::config()?;
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
     Ok(plugins
         .iter()
         .map(|(id, (ty, data))| modify_cfg_for_api(&id, &ty, data))
@@ -542,7 +543,7 @@ pub fn list_plugins(mut rpcenv: &mut dyn RpcEnvironment) -> Result<Vec<PluginCon
 /// List ACME challenge plugins.
 pub fn get_plugin(id: String, mut rpcenv: &mut dyn RpcEnvironment) -> Result<PluginConfig, Error> {
     let (plugins, digest) = plugin::config()?;
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     match plugins.get(&id) {
         Some((ty, data)) => Ok(modify_cfg_for_api(&id, &ty, &data)),
@@ -695,7 +696,7 @@ pub fn update_plugin(
     let (mut plugins, expected_digest) = plugin::config()?;
 
     if let Some(digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(&digest)?;
+        let digest = <[u8; 32]>::from_hex(&digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
index b9526ed39b973fd8b040aebaa006c16f88140fc8..e6673bcdb88b31afeae747a848c1210fbce390c3 100644 (file)
@@ -1,6 +1,7 @@
 use anyhow::{bail, Error};
 use ::serde::{Deserialize, Serialize};
 use serde_json::Value;
+use hex::FromHex;
 
 use proxmox_router::{Router, RpcEnvironment, Permission};
 use proxmox_schema::{api, parse_property_string};
@@ -83,7 +84,7 @@ pub fn get_config(
 
     let data: ScsiTapeChanger = config.lookup("changer", &name)?;
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(data)
 }
@@ -124,7 +125,7 @@ pub fn list_changers(
         })
         .collect();
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(list)
 }
@@ -181,7 +182,7 @@ pub fn update_changer(
     let (mut config, expected_digest) = pbs_config::drive::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
index 5352877ef3baec434bd74b6d72d89bb72bd21345..c502c4e3b0adda19611e1212d232affa3a5d5349 100644 (file)
@@ -3,11 +3,12 @@ use std::path::PathBuf;
 use anyhow::{bail, Error};
 use serde_json::Value;
 use ::serde::{Deserialize, Serialize};
+use hex::FromHex;
 
 use proxmox_router::{Router, RpcEnvironment, RpcEnvironmentType, Permission};
 use proxmox_schema::{api, ApiType, parse_property_string};
 use proxmox_section_config::SectionConfigData;
-use proxmox_sys::worker_task_context::WorkerTaskContext;
+use proxmox_sys::WorkerTaskContext;
 
 use pbs_datastore::chunk_store::ChunkStore;
 use pbs_config::BackupLockGuard;
@@ -55,7 +56,7 @@ pub fn list_datastores(
     let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
     let user_info = CachedUserInfo::new()?;
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     let list:Vec<DataStoreConfig> = config.convert_to_typed_array("datastore")?;
     let filter_by_privs = |store: &DataStoreConfig| {
@@ -148,7 +149,7 @@ pub fn read_datastore(
     let (config, digest) = pbs_config::datastore::config()?;
 
     let store_config = config.lookup("datastore", &name)?;
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(store_config)
 }
@@ -228,7 +229,7 @@ pub fn update_datastore(
     let (mut config, expected_digest) = pbs_config::datastore::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
@@ -347,7 +348,7 @@ pub async fn delete_datastore(
     let (mut config, expected_digest) = pbs_config::datastore::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
index 2840fe8f6123db6d0a36cd3b6fdfd0792c2dde0a..1c92e4c36b14b903a00446d7f1c32a5e9beb809e 100644 (file)
@@ -1,6 +1,7 @@
 use anyhow::{bail, Error};
 use ::serde::{Deserialize, Serialize};
 use serde_json::Value;
+use hex::FromHex;
 
 use proxmox_router::{Router, RpcEnvironment, Permission};
 use proxmox_schema::api;
@@ -82,7 +83,7 @@ pub fn get_config(
 
     let data: LtoTapeDrive = config.lookup("lto", &name)?;
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(data)
 }
@@ -123,7 +124,7 @@ pub fn list_drives(
         })
         .collect();
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(drive_list)
 }
@@ -183,7 +184,7 @@ pub fn update_drive(
     let (mut config, expected_digest) = pbs_config::drive::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
index 6f72ac420994ac9a5a61e6968e08700b9dbcb4ea..7c3708c6893cde0fc1c1da6e468e9f8f06ae2645 100644 (file)
@@ -77,7 +77,7 @@ pub fn list_pools(
         })
         .collect();
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(list)
 }
index c43b30c44add7f8097dc046f24f5a3e1345f73bd..1846deaa96e8045186d73bff2b699002c093024d 100644 (file)
@@ -1,9 +1,10 @@
 use anyhow::{bail, format_err, Error};
-use proxmox::sortable;
+use proxmox_sys::sortable;
 use proxmox_router::SubdirMap;
 use proxmox_router::list_subdirs_api_method;
 use serde_json::Value;
 use ::serde::{Deserialize, Serialize};
+use hex::FromHex;
 
 use proxmox_router::{http_err, ApiMethod, Router, RpcEnvironment, Permission};
 use proxmox_schema::api;
@@ -57,7 +58,7 @@ pub fn list_remotes(
         })
         .collect();
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
     Ok(list)
 }
 
@@ -128,7 +129,7 @@ pub fn read_remote(
     let (config, digest) = pbs_config::remote::config()?;
     let mut data: Remote = config.lookup("remote", &name)?;
     data.password = "".to_string(); // do not return password in api
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
     Ok(data)
 }
 
@@ -193,7 +194,7 @@ pub fn update_remote(
     let (mut config, expected_digest) = pbs_config::remote::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
@@ -265,7 +266,7 @@ pub fn delete_remote(name: String, digest: Option<String>) -> Result<(), Error>
     let (mut config, expected_digest) = pbs_config::remote::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
index 0f16bb0609afab9aeab08b0a675a3ada141156fb..ada53d689ef6b0ca1d597d85178c5c932bfd43a2 100644 (file)
@@ -1,6 +1,7 @@
 use anyhow::{bail, Error};
 use serde_json::Value;
 use ::serde::{Deserialize, Serialize};
+use hex::FromHex;
 
 use proxmox_router::{Router, RpcEnvironment, Permission};
 use proxmox_schema::api;
@@ -91,7 +92,7 @@ pub fn list_sync_jobs(
 
     let list = config.convert_to_typed_array("sync")?;
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     let list = list
         .into_iter()
@@ -173,7 +174,7 @@ pub fn read_sync_job(
         bail!("permission check failed");
     }
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(sync_job)
 }
@@ -251,7 +252,7 @@ pub fn update_sync_job(
     let (mut config, expected_digest) = sync::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
@@ -355,7 +356,7 @@ pub fn delete_sync_job(
     let (mut config, expected_digest) = sync::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
index 3be80f6a13efbf2e5ed35a0a7cb2e09279e48a72..21ac32f8c1fa3e07bbb18820eb1baa087df7e16f 100644 (file)
@@ -1,6 +1,7 @@
 use anyhow::{bail, Error};
 use serde_json::Value;
 use ::serde::{Deserialize, Serialize};
+use hex::FromHex;
 
 use proxmox_router::{Router, RpcEnvironment, Permission};
 use proxmox_schema::api;
@@ -47,7 +48,7 @@ pub fn list_tape_backup_jobs(
         })
         .collect();
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(list)
 }
@@ -111,7 +112,7 @@ pub fn read_tape_backup_job(
 
     let job = config.lookup("backup", &id)?;
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(job)
 }
@@ -180,7 +181,7 @@ pub fn update_tape_backup_job(
     let mut data: TapeBackupJobConfig = config.lookup("backup", &id)?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
@@ -259,7 +260,7 @@ pub fn delete_tape_backup_job(
     let (mut config, expected_digest) = pbs_config::tape_job::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
index 03c39c58dffc60712cd1975a44cdc65861e363be..1ad99377a46c00cd927c81a313b721127f8cf2ba 100644 (file)
@@ -1,5 +1,6 @@
 use anyhow::{bail, Error};
 use serde_json::Value;
+use hex::FromHex;
 
 use proxmox_router::{ApiMethod, Router, RpcEnvironment, Permission};
 use proxmox_schema::api;
@@ -50,7 +51,7 @@ pub fn list_keys(
         list.push(item.into());
     }
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(list)
 }
@@ -109,7 +110,7 @@ pub fn change_passphrase(
     let (mut config_map, expected_digest) = load_key_configs()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
@@ -245,7 +246,7 @@ pub fn delete_key(
     let (mut key_map, _) = load_keys()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
index aca3b5c4bfd6ad241a32473a20b7f7c31d157cde..f7f1cd65c8d8313bb12d2c1441e7280420c804ff 100644 (file)
@@ -1,6 +1,7 @@
 use anyhow::{bail, Error};
 use serde_json::Value;
 use ::serde::{Deserialize, Serialize};
+use hex::FromHex;
 
 use proxmox_router::{ApiMethod, Router, RpcEnvironment, Permission};
 use proxmox_schema::api;
@@ -34,7 +35,7 @@ pub fn list_traffic_controls(
 
     let list: Vec<TrafficControlRule> = config.convert_to_typed_array("rule")?;
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(list)
 }
@@ -92,7 +93,7 @@ pub fn read_traffic_control(
 ) -> Result<TrafficControlRule, Error> {
     let (config, digest) = pbs_config::traffic_control::config()?;
     let data: TrafficControlRule = config.lookup("rule", &name)?;
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
     Ok(data)
 }
 
@@ -159,7 +160,7 @@ pub fn update_traffic_control(
     let (mut config, expected_digest) = pbs_config::traffic_control::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
@@ -238,7 +239,7 @@ pub fn delete_traffic_control(name: String, digest: Option<String>) -> Result<()
     let (mut config, expected_digest) = pbs_config::traffic_control::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
index d1a283227adbe7699c0bc4b93a1a972d042cdc5b..1431244bafdbb8809b250821ad3f55552690ec1a 100644 (file)
@@ -1,6 +1,7 @@
 use anyhow::{bail, Error};
 use serde_json::Value;
 use ::serde::{Deserialize, Serialize};
+use hex::FromHex;
 
 use proxmox_router::{Router, RpcEnvironment, Permission};
 use proxmox_schema::api;
@@ -48,7 +49,7 @@ pub fn list_verification_jobs(
             privs & required_privs != 00
         }).collect();
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(list)
 }
@@ -125,7 +126,7 @@ pub fn read_verification_job(
     let required_privs = PRIV_DATASTORE_AUDIT | PRIV_DATASTORE_VERIFY;
     user_info.check_privs(&auth_id, &["datastore", &verification_job.store], required_privs, true)?;
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(verification_job)
 }
@@ -193,7 +194,7 @@ pub fn update_verification_job(
     let (mut config, expected_digest) = verify::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
@@ -280,7 +281,7 @@ pub fn delete_verification_job(
     user_info.check_privs(&auth_id, &["datastore", &job.store], PRIV_DATASTORE_VERIFY, true)?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
index 564748a9153f5f34a541f421c6f912e7ab561c70..d9a29313ec06edf1eda9bccb6e3ad3c73fe047b5 100644 (file)
@@ -2,7 +2,7 @@ use anyhow::{Error, bail, format_err};
 use serde_json::{json, Value};
 use std::collections::HashMap;
 
-use proxmox::tools::fs::{replace_file, CreateOptions};
+use proxmox_sys::fs::{replace_file, CreateOptions};
 use proxmox_router::{
     list_subdirs_api_method, RpcEnvironment, RpcEnvironmentType, Permission, Router, SubdirMap
 };
@@ -277,7 +277,7 @@ fn apt_get_changelog(
         command.arg("changelog");
         command.arg("-qq"); // don't display download progress
         command.arg(name);
-        let output = pbs_tools::run_command(command, None)?;
+        let output = proxmox_sys::command::run_command(command, None)?;
         Ok(json!(output))
     }
 }
@@ -447,7 +447,7 @@ pub fn get_versions() -> Result<Vec<APTUpdateInfo>, Error> {
 /// Get APT repository information.
 pub fn get_repositories() -> Result<Value, Error> {
     let (files, errors, digest) = proxmox_apt::repositories::repositories()?;
-    let digest = proxmox::tools::digest_to_hex(&digest);
+    let digest = hex::encode(&digest);
 
     let suite = proxmox_apt::repositories::get_current_release_codename()?;
 
@@ -493,7 +493,7 @@ pub fn add_repository(handle: APTRepositoryHandle, digest: Option<String>) -> Re
     let suite = proxmox_apt::repositories::get_current_release_codename()?;
 
     if let Some(expected_digest) = digest {
-        let current_digest = proxmox::tools::digest_to_hex(&current_digest);
+        let current_digest = hex::encode(&current_digest);
         crate::tools::assert_if_modified(&expected_digest, &current_digest)?;
     }
 
@@ -583,7 +583,7 @@ pub fn change_repository(
     let (mut files, errors, current_digest) = proxmox_apt::repositories::repositories()?;
 
     if let Some(expected_digest) = digest {
-        let current_digest = proxmox::tools::digest_to_hex(&current_digest);
+        let current_digest = hex::encode(&current_digest);
         crate::tools::assert_if_modified(&expected_digest, &current_digest)?;
     }
 
index d961eb3d4d2b007b2d32fb5d6825e41ca821edb9..4f196327f38eda10df3f80da79d077ee632bb4ca 100644 (file)
@@ -133,7 +133,7 @@ impl TryFrom<&cert::CertInfo> for CertificateInfo {
 
 fn get_certificate_pem() -> Result<String, Error> {
     let cert_path = configdir!("/proxy.pem");
-    let cert_pem = proxmox::tools::fs::file_get_contents(&cert_path)?;
+    let cert_pem = proxmox_sys::fs::file_get_contents(&cert_path)?;
     String::from_utf8(cert_pem)
         .map_err(|_| format_err!("certificate in {:?} is not a valid PEM file", cert_path))
 }
index fe99bad933606773a5aa7940725f483959b4f9a2..0b45f34c076835470c1ee1194349624bbba64716 100644 (file)
@@ -1,5 +1,6 @@
 use anyhow::Error;
 use ::serde::{Deserialize, Serialize};
+use hex::FromHex;
 
 use proxmox_router::{Permission, Router, RpcEnvironment};
 use proxmox_schema::api;
@@ -29,7 +30,7 @@ pub const ROUTER: Router = Router::new()
 /// Get the node configuration
 pub fn get_node_config(mut rpcenv: &mut dyn RpcEnvironment) -> Result<NodeConfig, Error> {
     let (config, digest) = crate::config::node::config()?;
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
     Ok(config)
 }
 
@@ -94,7 +95,7 @@ pub fn update_node_config(
     if let Some(digest) = digest {
         // FIXME: GUI doesn't handle our non-inlined digest part here properly...
         if !digest.is_empty() {
-            let digest = proxmox::tools::hex_to_digest(&digest)?;
+            let digest = <[u8; 32]>::from_hex(&digest)?;
             crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
         }
     }
index 67c610979f3ec3ec0a258eb160be2e39b46023ea..d8e81c52f8e33d72df40e5a4d39c49c0bb1a6ebd 100644 (file)
@@ -78,7 +78,7 @@ pub fn  list_datastore_mounts() -> Result<Vec<DatastoreMountInfo>, Error> {
     let mut list = Vec::new();
 
     let basedir = "/etc/systemd/system";
-    for item in pbs_tools::fs::scan_subdir(libc::AT_FDCWD, basedir, &MOUNT_NAME_REGEX)? {
+    for item in proxmox_sys::fs::scan_subdir(libc::AT_FDCWD, basedir, &MOUNT_NAME_REGEX)? {
         let item = item?;
         let name = item.file_name().to_string_lossy().to_string();
 
@@ -243,7 +243,7 @@ pub fn delete_datastore_disk(name: String) -> Result<(), Error> {
     }
 
     // disable systemd mount-unit
-    let mut mount_unit_name = proxmox::tools::systemd::escape_unit(&path, true);
+    let mut mount_unit_name = proxmox_sys::systemd::escape_unit(&path, true);
     mount_unit_name.push_str(".mount");
     crate::tools::systemd::disable_unit(&mount_unit_name)?;
 
@@ -256,7 +256,7 @@ pub fn delete_datastore_disk(name: String) -> Result<(), Error> {
     // try to unmount, if that fails tell the user to reboot or unmount manually
     let mut command = std::process::Command::new("umount");
     command.arg(&path);
-    match pbs_tools::run_command(command, None) {
+    match proxmox_sys::command::run_command(command, None) {
         Err(_) => bail!(
             "Could not umount '{}' since it is busy. It will stay mounted \
              until the next reboot or until unmounted manually!",
@@ -282,7 +282,7 @@ fn create_datastore_mount_unit(
     what: &str,
 ) -> Result<String, Error> {
 
-    let mut mount_unit_name = proxmox::tools::systemd::escape_unit(&mount_point, true);
+    let mut mount_unit_name = proxmox_sys::systemd::escape_unit(&mount_point, true);
     mount_unit_name.push_str(".mount");
 
     let mount_unit_path = format!("/etc/systemd/system/{}", mount_unit_name);
index 7721313c9efc5c061d9b513d7a1a2d239b117aa2..0701b94493c48eb6018c319397c2dac5dd10e5ea 100644 (file)
@@ -1,7 +1,7 @@
 use anyhow::{bail, Error};
 use serde_json::{json, Value};
 
-use proxmox::{sortable, identity};
+use proxmox_sys::{sortable, identity};
 use proxmox_router::{
     list_subdirs_api_method, Router, RpcEnvironment, RpcEnvironmentType, SubdirMap, Permission,
 };
index c9a6ac72d9ba3cb877f3ce2edb7abe676d87ef2a..3682d82fd24fb66760769550eb14af59788e643f 100644 (file)
@@ -265,11 +265,11 @@ pub fn create_zpool(
 
             task_log!(worker, "# {:?}", command);
 
-            let output = pbs_tools::run_command(command, None)?;
+            let output = proxmox_sys::command::run_command(command, None)?;
             task_log!(worker, "{}", output);
 
             if std::path::Path::new("/lib/systemd/system/zfs-import@.service").exists() {
-                let import_unit = format!("zfs-import@{}.service", proxmox::tools::systemd::escape_unit(&name, false));
+                let import_unit = format!("zfs-import@{}.service", proxmox_sys::systemd::escape_unit(&name, false));
                 crate::tools::systemd::enable_unit(&import_unit)?;
             }
 
@@ -277,7 +277,7 @@ pub fn create_zpool(
                 let mut command = std::process::Command::new("zfs");
                 command.args(&["set", &format!("compression={}", compression), &name]);
                 task_log!(worker, "# {:?}", command);
-                let output = pbs_tools::run_command(command, None)?;
+                let output = proxmox_sys::command::run_command(command, None)?;
                 task_log!(worker, "{}", output);
             }
 
index ff04a5e3b49c37d3d775e84dec25228270cd7490..18312e31a3d4adade08e3db4a15ea9b5902beb90 100644 (file)
@@ -9,8 +9,8 @@ use ::serde::{Deserialize, Serialize};
 
 use proxmox_router::{ApiMethod, Router, RpcEnvironment, Permission};
 use proxmox_schema::api;
-use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
-use proxmox::{IPRE, IPV4RE, IPV6RE, IPV4OCTET, IPV6H16, IPV6LS32};
+use proxmox_sys::fs::{file_get_contents, replace_file, CreateOptions};
+use pbs_api_types::{IPRE, IPV4RE, IPV6RE, IPV4OCTET, IPV6H16, IPV6LS32};
 
 use pbs_api_types::{
     PROXMOX_CONFIG_DIGEST_SCHEMA, FIRST_DNS_SERVER_SCHEMA, SECOND_DNS_SERVER_SCHEMA,
@@ -41,7 +41,7 @@ pub fn read_etc_resolv_conf() -> Result<Value, Error> {
 
     let raw = file_get_contents(RESOLV_CONF_FN)?;
 
-    result["digest"] = Value::from(proxmox::tools::digest_to_hex(&sha::sha256(&raw)));
+    result["digest"] = Value::from(hex::encode(&sha::sha256(&raw)));
 
     let data = String::from_utf8(raw)?;
 
index ec6ff18616babf0e7f98a9f81d4b0fcd90273fc3..b60ea9e7e72719d41684e84bc2ed7a9934b7973a 100644 (file)
@@ -12,8 +12,8 @@ use hyper::Request;
 use serde_json::{json, Value};
 use tokio::io::{AsyncBufReadExt, BufReader};
 
-use proxmox::{identity, sortable};
-use proxmox::tools::fd::fd_change_cloexec;
+use proxmox_sys::{identity, sortable};
+use proxmox_sys::fd::fd_change_cloexec;
 
 use proxmox_router::{
     ApiHandler, ApiMethod, ApiResponseFuture, Permission, RpcEnvironment, Router, SubdirMap,
@@ -319,7 +319,7 @@ fn upgrade_to_websocket(
 #[api]
 /// List Nodes (only for compatiblity)
 fn list_nodes() -> Result<Value, Error> {
-    Ok(json!([ { "node": proxmox::tools::nodename().to_string() } ]))
+    Ok(json!([ { "node": proxmox_sys::nodename().to_string() } ]))
 }
 
 pub const SUBDIRS: SubdirMap = &[
index 1becf1070f02c0c77f1a19ea8b7ef2d35da330f6..811030dc538b512cd578f2cdf50ea78609338b0a 100644 (file)
@@ -1,6 +1,7 @@
 use anyhow::{Error, bail};
 use serde_json::{Value, to_value};
 use ::serde::{Deserialize, Serialize};
+use hex::FromHex;
 
 use proxmox_router::{ApiMethod, Router, RpcEnvironment, Permission};
 use proxmox_schema::{api, parse_property_string};
@@ -92,7 +93,7 @@ pub fn list_network_devices(
 ) -> Result<Value, Error> {
 
     let (config, digest) = network::config()?;
-    let digest = proxmox::tools::digest_to_hex(&digest);
+    let digest = hex::encode(&digest);
 
     let mut list = Vec::new();
 
@@ -136,7 +137,7 @@ pub fn read_interface(iface: String) -> Result<Value, Error> {
     let interface = config.lookup(&iface)?;
 
     let mut data: Value = to_value(interface)?;
-    data["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    data["digest"] = hex::encode(&digest).into();
 
     Ok(data)
 }
@@ -528,7 +529,7 @@ pub fn update_interface(
     let (mut config, expected_digest) = network::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
@@ -668,7 +669,7 @@ pub fn delete_interface(iface: String, digest: Option<String>) -> Result<(), Err
     let (mut config, expected_digest) = network::config()?;
 
     if let Some(ref digest) = digest {
-        let digest = proxmox::tools::hex_to_digest(digest)?;
+        let digest = <[u8; 32]>::from_hex(digest)?;
         crate::tools::detect_modified_configuration_file(&digest, &expected_digest)?;
     }
 
index 19a1d8a1a07823eb330581421fdf0a9490c15055..9a50d4e797868577a16f3ccc1b171c5c2f19b450 100644 (file)
@@ -3,7 +3,7 @@ use std::process::{Command, Stdio};
 use anyhow::{bail, Error};
 use serde_json::{json, Value};
 
-use proxmox::{sortable, identity};
+use proxmox_sys::{sortable, identity};
 use proxmox_router::{list_subdirs_api_method, Router, Permission, RpcEnvironment, SubdirMap};
 use proxmox_schema::api;
 
index f9b1ca727ad3bcb1b8eabd532caa094273470459..9559dda630d488ad28a347b27df8ff3de14d7e73 100644 (file)
@@ -4,7 +4,7 @@ use std::path::Path;
 use anyhow::{Error, format_err, bail};
 use serde_json::Value;
 
-use proxmox::sys::linux::procfs;
+use proxmox_sys::linux::procfs;
 
 use proxmox_router::{ApiMethod, Router, RpcEnvironment, Permission};
 use proxmox_schema::api;
index 7689ef216d8e75e2f676ba8921ca42ae0d334674..55ea80831dfbc5ffeadc61e68417a8b84aa544f3 100644 (file)
@@ -4,7 +4,7 @@ use std::io::{BufRead, BufReader};
 use anyhow::{bail, Error};
 use serde_json::{json, Value};
 
-use proxmox::{identity, sortable};
+use proxmox_sys::{identity, sortable};
 use proxmox_router::{list_subdirs_api_method, Router, RpcEnvironment, Permission, SubdirMap};
 use proxmox_schema::api;
 
index b58f1dd22b6c1540cbb8f10184a023cd80f64377..88f64117da7a307e18e5cdd1615118231a05dda3 100644 (file)
@@ -1,7 +1,7 @@
 use anyhow::{bail, format_err, Error};
 use serde_json::{json, Value};
 
-use proxmox::tools::fs::{file_read_firstline, replace_file, CreateOptions};
+use proxmox_sys::fs::{file_read_firstline, replace_file, CreateOptions};
 use proxmox_router::{Router, Permission};
 use proxmox_schema::api;
 
index 169ba6133552d49e8614a39cc6bdd797785fc85b..698a0b5016f9f63b19b72ee817668c242e633e48 100644 (file)
@@ -6,8 +6,9 @@ use hyper::header::{self, HeaderValue, UPGRADE};
 use hyper::http::request::Parts;
 use hyper::{Body, Response, Request, StatusCode};
 use serde_json::Value;
+use hex::FromHex;
 
-use proxmox::{identity, sortable};
+use proxmox_sys::{identity, sortable};
 use proxmox_router::{
     http_err, list_subdirs_api_method, ApiHandler, ApiMethod, ApiResponseFuture, Permission,
     Router, RpcEnvironment, SubdirMap,
@@ -19,7 +20,7 @@ use pbs_api_types::{
     CHUNK_DIGEST_SCHEMA, PRIV_DATASTORE_READ, PRIV_DATASTORE_BACKUP,
     BACKUP_ARCHIVE_NAME_SCHEMA,
 };
-use pbs_tools::fs::lock_dir_noblock_shared;
+use proxmox_sys::fs::lock_dir_noblock_shared;
 use pbs_tools::json::{required_integer_param, required_string_param};
 use pbs_datastore::{DataStore, PROXMOX_BACKUP_READER_PROTOCOL_ID_V1};
 use pbs_datastore::backup_info::BackupDir;
@@ -277,7 +278,7 @@ fn download_chunk(
         let env: &ReaderEnvironment = rpcenv.as_ref();
 
         let digest_str = required_string_param(&param, "digest")?;
-        let digest = proxmox::tools::hex_to_digest(digest_str)?;
+        let digest = <[u8; 32]>::from_hex(digest_str)?;
 
         if !env.check_chunk_access(digest) {
             env.log(format!("attempted to download chunk {} which is not in registered chunk list", digest_str));
@@ -316,7 +317,7 @@ fn download_chunk_old(
     let env2 = env.clone();
 
     let digest_str = required_string_param(&param, "digest")?;
-    let digest = proxmox::tools::hex_to_digest(digest_str)?;
+    let digest = <[u8; 32]>::from_hex(digest_str)?;
 
     let (path, _) = env.datastore.chunk_path(&digest);
 
index cb748399ecd38feb97a9b56394d38541a39e560f..dc15908ff7f1efaddfcc11fa7a906ce36079b9cd 100644 (file)
@@ -7,7 +7,7 @@ use serde_json::Value;
 use proxmox_lang::try_block;
 use proxmox_router::{Permission, Router, RpcEnvironment, RpcEnvironmentType};
 use proxmox_schema::api;
-use proxmox_sys::{task_log, task_warn, worker_task_context::WorkerTaskContext};
+use proxmox_sys::{task_log, task_warn, WorkerTaskContext};
 
 use pbs_api_types::{
     Authid, Userid, TapeBackupJobConfig, TapeBackupJobSetup, TapeBackupJobStatus, MediaPoolConfig,
@@ -147,7 +147,7 @@ pub fn list_tape_backup_jobs(
         list.push(TapeBackupJobStatus { config: job, status, next_media_label });
     }
 
-    rpcenv["digest"] = proxmox::tools::digest_to_hex(&digest).into();
+    rpcenv["digest"] = hex::encode(&digest).into();
 
     Ok(list)
 }
index ba2dad7051b17e4a81bb39bff30a2d7394be48da..cedc2003e8c132f2dd024ec0f6102301c7efaaa5 100644 (file)
@@ -6,7 +6,7 @@ use std::collections::HashMap;
 use anyhow::{bail, format_err, Error};
 use serde_json::Value;
 
-use proxmox::{sortable, identity};
+use proxmox_sys::{sortable, identity};
 use proxmox_router::{
     list_subdirs_api_method, Permission, Router, RpcEnvironment, RpcEnvironmentType, SubdirMap,
 };
index 513d4ae600d19632c46650927e2d7e595cf96515..e1c9999cdc2fd899a9c68dc606c459922d5d18be 100644 (file)
@@ -8,13 +8,13 @@ use std::sync::Arc;
 use anyhow::{bail, format_err, Error};
 use serde_json::Value;
 
-use proxmox::tools::fs::{replace_file, CreateOptions};
+use proxmox_sys::fs::{replace_file, CreateOptions};
 use proxmox_io::ReadExt;
 use proxmox_router::{Permission, Router, RpcEnvironment, RpcEnvironmentType};
 use proxmox_schema::{api, parse_property_string};
 use proxmox_section_config::SectionConfigData;
 use proxmox_uuid::Uuid;
-use proxmox_sys::{task_log, task_warn, worker_task_context::WorkerTaskContext};
+use proxmox_sys::{task_log, task_warn, WorkerTaskContext};
 
 use pbs_api_types::{
     Authid, Userid, CryptMode,
@@ -1158,7 +1158,7 @@ fn scan_chunk_archive<'a>(
         worker.check_abort()?;
 
         if verbose {
-            task_log!(worker, "Found chunk: {}", proxmox::tools::digest_to_hex(&digest));
+            task_log!(worker, "Found chunk: {}", hex::encode(&digest));
         }
 
         chunks.push(digest);
@@ -1193,10 +1193,10 @@ fn restore_chunk_archive<'a>(
             let chunk_exists = datastore2.cond_touch_chunk(&digest, false)?;
             if !chunk_exists {
                 if verbose {
-                    task_log!(worker2, "Insert chunk: {}", proxmox::tools::digest_to_hex(&digest));
+                    task_log!(worker2, "Insert chunk: {}", hex::encode(&digest));
                 }
                 bytes2.fetch_add(chunk.raw_size(), std::sync::atomic::Ordering::SeqCst);
-                // println!("verify and write {}", proxmox::tools::digest_to_hex(&digest));
+                // println!("verify and write {}", hex::encode(&digest));
                 chunk.verify_crc()?;
                 if chunk.crypt_mode()? == CryptMode::None {
                     chunk.decode(None, Some(&digest))?; // verify digest
@@ -1204,7 +1204,7 @@ fn restore_chunk_archive<'a>(
 
                 datastore2.insert_chunk(&chunk, &digest)?;
             } else if verbose {
-                task_log!(worker2, "Found existing chunk: {}", proxmox::tools::digest_to_hex(&digest));
+                task_log!(worker2, "Found existing chunk: {}", hex::encode(&digest));
             }
             Ok(())
         },
index 3c2b84eb5b22764200f19dc81bc798269f7d92b8..6e7d65790bc7826312e3331261b96c666300f64c 100644 (file)
@@ -75,7 +75,7 @@ const SHADOW_CONFIG_FILENAME: &str = configdir!("/shadow.json");
 impl ProxmoxAuthenticator for PBS {
 
     fn authenticate_user(&self, username: &UsernameRef, password: &str) -> Result<(), Error> {
-        let data = proxmox::tools::fs::file_get_json(SHADOW_CONFIG_FILENAME, Some(json!({})))?;
+        let data = proxmox_sys::fs::file_get_json(SHADOW_CONFIG_FILENAME, Some(json!({})))?;
         match data[username.as_str()].as_str() {
             None => bail!("no password set"),
             Some(enc_password) => proxmox_sys::crypt::verify_crypt_pw(password, enc_password)?,
@@ -85,35 +85,35 @@ impl ProxmoxAuthenticator for PBS {
 
     fn store_password(&self, username: &UsernameRef, password: &str) -> Result<(), Error> {
         let enc_password = proxmox_sys::crypt::encrypt_pw(password)?;
-        let mut data = proxmox::tools::fs::file_get_json(SHADOW_CONFIG_FILENAME, Some(json!({})))?;
+        let mut data = proxmox_sys::fs::file_get_json(SHADOW_CONFIG_FILENAME, Some(json!({})))?;
         data[username.as_str()] = enc_password.into();
 
         let mode = nix::sys::stat::Mode::from_bits_truncate(0o0600);
-        let options =  proxmox::tools::fs::CreateOptions::new()
+        let options =  proxmox_sys::fs::CreateOptions::new()
             .perm(mode)
             .owner(nix::unistd::ROOT)
             .group(nix::unistd::Gid::from_raw(0));
 
         let data = serde_json::to_vec_pretty(&data)?;
-        proxmox::tools::fs::replace_file(SHADOW_CONFIG_FILENAME, &data, options, true)?;
+        proxmox_sys::fs::replace_file(SHADOW_CONFIG_FILENAME, &data, options, true)?;
 
         Ok(())
     }
 
     fn remove_password(&self, username: &UsernameRef) -> Result<(), Error> {
-        let mut data = proxmox::tools::fs::file_get_json(SHADOW_CONFIG_FILENAME, Some(json!({})))?;
+        let mut data = proxmox_sys::fs::file_get_json(SHADOW_CONFIG_FILENAME, Some(json!({})))?;
         if let Some(map) = data.as_object_mut() {
             map.remove(username.as_str());
         }
 
         let mode = nix::sys::stat::Mode::from_bits_truncate(0o0600);
-        let options =  proxmox::tools::fs::CreateOptions::new()
+        let options =  proxmox_sys::fs::CreateOptions::new()
             .perm(mode)
             .owner(nix::unistd::ROOT)
             .group(nix::unistd::Gid::from_raw(0));
 
         let data = serde_json::to_vec_pretty(&data)?;
-        proxmox::tools::fs::replace_file(SHADOW_CONFIG_FILENAME, &data, options, true)?;
+        proxmox_sys::fs::replace_file(SHADOW_CONFIG_FILENAME, &data, options, true)?;
 
         Ok(())
     }
index f15c0eab5cc947758abfdcd0a78ea897eac2c2d4..973c1224a1232a1c9a88c5b7f28456cfc5361501 100644 (file)
@@ -6,7 +6,7 @@ use openssl::pkey::{PKey, Private, Public};
 use openssl::rsa::Rsa;
 use openssl::sha;
 
-use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
+use proxmox_sys::fs::{file_get_contents, replace_file, CreateOptions};
 use proxmox_lang::try_block;
 
 use pbs_buildcfg::configdir;
index a1d8a838b49a2a71bfd251f33472ca4c80f1b2c4..6e8cfc1f3b347cc289401e798151206354de48cd 100644 (file)
@@ -6,14 +6,14 @@ use std::time::Instant;
 
 use anyhow::{bail, format_err, Error};
 
-use proxmox_sys::{task_log, worker_task_context::WorkerTaskContext};
+use proxmox_sys::{task_log, WorkerTaskContext};
 
 use pbs_api_types::{Authid, CryptMode, VerifyState, UPID, SnapshotVerifyState};
 use pbs_datastore::{DataStore, DataBlob, StoreProgress};
 use pbs_datastore::backup_info::{BackupGroup, BackupDir, BackupInfo};
 use pbs_datastore::index::IndexFile;
 use pbs_datastore::manifest::{archive_type, ArchiveType, BackupManifest, FileInfo};
-use pbs_tools::fs::lock_dir_noblock_shared;
+use proxmox_sys::fs::lock_dir_noblock_shared;
 
 use crate::tools::ParallelHandler;
 
@@ -158,7 +158,7 @@ fn verify_index_chunks(
         if verify_worker.verified_chunks.lock().unwrap().contains(digest) {
             true
         } else if verify_worker.corrupt_chunks.lock().unwrap().contains(digest) {
-            let digest_str = proxmox::tools::digest_to_hex(digest);
+            let digest_str = hex::encode(digest);
             task_log!(verify_worker.worker, "chunk {} was marked as corrupt", digest_str);
             errors.fetch_add(1, Ordering::SeqCst);
             true
index c5afe9dc425896d58823c123e8037604e1389ea3..e6fc5f23e107e705b6a1056b9a93579e4515ca5d 100644 (file)
@@ -10,7 +10,7 @@ use http::HeaderMap;
 
 use proxmox_lang::try_block;
 use proxmox_router::{RpcEnvironmentType, UserInformation};
-use proxmox::tools::fs::CreateOptions;
+use proxmox_sys::fs::CreateOptions;
 
 use proxmox_rest_server::{daemon, AuthError, ApiConfig, RestServer, RestEnvironment, ServerAdapter};
 
index fa075e2ee49a2ba9272556de29b57b67f3f26c48..4a055032953ab0e5929b1635fef3164ff2decc29 100644 (file)
@@ -4,7 +4,7 @@ use std::io::{self, Write};
 use anyhow::Error;
 use serde_json::{json, Value};
 
-use proxmox::tools::fs::CreateOptions;
+use proxmox_sys::fs::CreateOptions;
 use proxmox_router::{cli::*, RpcEnvironment};
 use proxmox_schema::api;
 
index 932b0d78af5b936bf4dd0e8d05b91c60b32feb99..0d852a7a1e16bd15d62dd9f4e132ee22df949349 100644 (file)
@@ -17,8 +17,8 @@ use tokio_stream::wrappers::ReceiverStream;
 use serde_json::{json, Value};
 use http::{Method, HeaderMap};
 
-use proxmox::sys::linux::socket::set_tcp_keepalive;
-use proxmox::tools::fs::CreateOptions;
+use proxmox_sys::linux::socket::set_tcp_keepalive;
+use proxmox_sys::fs::CreateOptions;
 use proxmox_lang::try_block;
 use proxmox_router::{RpcEnvironment, RpcEnvironmentType, UserInformation};
 use proxmox_http::client::{RateLimitedStream, ShareableRateLimit};
@@ -145,7 +145,7 @@ async fn get_index_future(
         None => (None, None),
     };
 
-    let nodename = proxmox::tools::nodename();
+    let nodename = proxmox_sys::nodename();
     let user = userid.as_ref().map(|u| u.as_str()).unwrap_or("");
 
     let csrf_token = csrf_token.unwrap_or_else(|| String::from(""));
@@ -815,7 +815,7 @@ async fn schedule_task_log_rotate() {
                 let max_files = 20; // times twenty files gives > 100000 task entries
 
                 let user = pbs_config::backup_user()?;
-                let options = proxmox::tools::fs::CreateOptions::new()
+                let options = proxmox_sys::fs::CreateOptions::new()
                     .owner(user.uid)
                     .group(user.gid);
 
@@ -949,7 +949,7 @@ async fn generate_host_stats() {
 }
 
 fn generate_host_stats_sync() {
-    use proxmox::sys::linux::procfs::{
+    use proxmox_sys::linux::procfs::{
         read_meminfo, read_proc_stat, read_proc_net_dev, read_loadavg};
 
     match read_proc_stat() {
index 03e2ec023639a7613ec69c90ad6732e90960f5de..3333d55537f34837c8c96ef6244fe6a89bfec76d 100644 (file)
@@ -1,7 +1,7 @@
 use anyhow::Error;
 use serde_json::json;
 
-use proxmox::tools::fs::CreateOptions;
+use proxmox_sys::fs::CreateOptions;
 use proxmox_router::{cli::*, RpcEnvironment, ApiHandler};
 
 use proxmox_backup::api2;
index 43e30c235f8a1f16f249772a9574f46910cacacd..fccb182a8a9b46d2b4dd4c2a63a090562c62faa9 100644 (file)
@@ -6,6 +6,7 @@ use std::path::Path;
 use anyhow::{bail, format_err, Error};
 use serde_json::{json, Value};
 use walkdir::WalkDir;
+use hex::FromHex;
 
 use proxmox_router::cli::{
     format_and_print_result, get_output_format, CliCommand, CliCommandMap, CommandLineInterface,
@@ -116,7 +117,7 @@ fn inspect_chunk(
 
     let digest_raw: Option<[u8; 32]> = digest
         .map(|ref d| {
-            proxmox::tools::hex_to_digest(d)
+            <[u8; 32]>::from_hex(d)
                 .map_err(|e| format_err!("could not parse chunk - {}", e))
         })
         .map_or(Ok(None), |r| r.map(Some))?;
@@ -291,7 +292,7 @@ fn inspect_file(
 
             for pos in 0..index.index_count() {
                 let digest = index.index_digest(pos).unwrap();
-                chunk_digests.insert(proxmox::tools::digest_to_hex(digest));
+                chunk_digests.insert(hex::encode(digest));
             }
 
             json!({
index a8665cd16c57cceec22e9307a7648119f7fcaf08..ff3b13776b56f96e234cf167c9bb4bb1ad837d59 100644 (file)
@@ -5,7 +5,6 @@ use std::path::Path;
 use anyhow::{bail, format_err, Error};
 use serde_json::Value;
 
-use proxmox::tools::digest_to_hex;
 use proxmox_router::cli::{CliCommand, CliCommandMap, CommandLineInterface};
 use proxmox_schema::api;
 
@@ -87,7 +86,7 @@ fn recover_index(
     let mut data = Vec::with_capacity(4 * 1024 * 1024);
     for pos in 0..index.index_count() {
         let chunk_digest = index.index_digest(pos).unwrap();
-        let digest_str = digest_to_hex(chunk_digest);
+        let digest_str = hex::encode(chunk_digest);
         let digest_prefix = &digest_str[0..4];
         let chunk_path = chunks_path.join(digest_prefix).join(digest_str);
         let mut chunk_file = std::fs::File::open(&chunk_path)
index ecf7b2b2f0bdf12941ef94455a88e1f6f601031b..62eb07e23e29bc2b8aa14b6f3c0332401bbc6dbf 100644 (file)
@@ -3,7 +3,7 @@ use std::io::Write;
 use anyhow::{bail, Error};
 use serde_json::Value;
 
-use proxmox::tools::fs::file_get_contents;
+use proxmox_sys::fs::file_get_contents;
 use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
 use proxmox_schema::api;
 
index 3feb72ffbfdc26b462db5a582954db6940924f4f..3c2bade9f9a16d1267d3041573f00b605544db67 100644 (file)
@@ -3,7 +3,7 @@ use serde_json::Value;
 
 use proxmox_router::{cli::*, ApiHandler, RpcEnvironment};
 use proxmox_schema::api;
-use proxmox::sys::linux::tty;
+use proxmox_sys::linux::tty;
 
 use pbs_api_types::{
     Fingerprint, Kdf, DRIVE_NAME_SCHEMA, TAPE_ENCRYPTION_KEY_FINGERPRINT_SCHEMA,
index 861cb5797ba27d2ba42804f0b214ac4444910574..00b7a21db400f76c080874d88b5156e0a19bcf26 100644 (file)
@@ -5,8 +5,8 @@ use std::path::Path;
 use anyhow::{bail, format_err, Error};
 use serde_json::Value;
 
-use proxmox::sys::error::SysError;
-use proxmox::tools::fs::{CreateOptions, file_read_string};
+use proxmox_sys::error::SysError;
+use proxmox_sys::fs::{CreateOptions, file_read_string};
 
 use pbs_api_types::PROXMOX_SAFE_ID_REGEX;
 
@@ -32,7 +32,7 @@ fn root_only() -> CreateOptions {
 }
 
 fn create_acme_subdir(dir: &str) -> nix::Result<()> {
-    match proxmox::tools::fs::create_dir(dir, root_only()) {
+    match proxmox_sys::fs::create_dir(dir, root_only()) {
         Ok(()) => Ok(()),
         Err(err) if err.already_exists() => Ok(()),
         Err(err) => Err(err),
@@ -70,7 +70,7 @@ pub fn foreach_acme_account<F>(mut func: F) -> Result<(), Error>
 where
     F: FnMut(AcmeAccountName) -> ControlFlow<Result<(), Error>>,
 {
-    match pbs_tools::fs::scan_subdir(-1, ACME_ACCOUNT_DIR, &PROXMOX_SAFE_ID_REGEX) {
+    match proxmox_sys::fs::scan_subdir(-1, ACME_ACCOUNT_DIR, &PROXMOX_SAFE_ID_REGEX) {
         Ok(files) => {
             for file in files {
                 let file = file?;
index 6ba5bcf7e9f6a45c653dffcd60d0d9740825fd1f..5decc154fa5a8eb3d8328246c5281751f4518f57 100644 (file)
@@ -90,7 +90,7 @@ pub struct DnsPlugin {
 
     // We handle this property separately in the API calls.
     /// DNS plugin data (base64url encoded without padding).
-    #[serde(with = "proxmox::tools::serde::string_as_base64url_nopad")]
+    #[serde(with = "proxmox_serde::string_as_base64url_nopad")]
     pub data: String,
 }
 
@@ -141,7 +141,7 @@ pub fn lock() -> Result<BackupLockGuard, Error> {
 }
 
 pub fn config() -> Result<(PluginData, [u8; 32]), Error> {
-    let content = proxmox::tools::fs::file_read_optional_string(ACME_PLUGIN_CFG_FILENAME)?
+    let content = proxmox_sys::fs::file_read_optional_string(ACME_PLUGIN_CFG_FILENAME)?
         .unwrap_or_else(|| "".to_string());
 
     let digest = openssl::sha::sha256(content.as_bytes());
index f93dd14321e1bfa5e414b86f75038e3fafe431d0..77d6170a6fecb2eb38d0fd89c8de9680747aeaf3 100644 (file)
@@ -104,7 +104,7 @@ pub fn update_self_signed_cert(force: bool) -> Result<(), Error> {
     let expire = openssl::asn1::Asn1Time::days_from_now(365*1000)?;
     x509.set_not_after(&expire)?;
 
-    let nodename = proxmox::tools::nodename();
+    let nodename = proxmox_sys::nodename();
     let mut fqdn = nodename.to_owned();
 
     let resolv_conf = crate::api2::node::dns::read_etc_resolv_conf()?;
index 934442160f613187352ac1a414ebc1d9acf99cee..ebbd08bd2b214eed15bad2421104d4ab1380ad3c 100644 (file)
@@ -25,7 +25,7 @@ pub fn lock() -> Result<BackupLockGuard, Error> {
 /// Read the Node Config.
 pub fn config() -> Result<(NodeConfig, [u8; 32]), Error> {
     let content =
-        proxmox::tools::fs::file_read_optional_string(CONF_FILE)?.unwrap_or_else(|| "".to_string());
+        proxmox_sys::fs::file_read_optional_string(CONF_FILE)?.unwrap_or_else(|| "".to_string());
 
     let digest = openssl::sha::sha256(content.as_bytes());
     let data: NodeConfig = crate::tools::config::from_str(&content, &NodeConfig::API_SCHEMA)?;
index cb34f26cbea4e58ea3edb8f7940093bb453d6597..d8a1680e2df3d61badf1582d73d2af245570fa08 100644 (file)
@@ -7,8 +7,8 @@ use std::path::PathBuf;
 use anyhow::{bail, format_err, Error};
 use nix::sys::stat::Mode;
 
-use proxmox::sys::error::SysError;
-use proxmox::tools::fs::CreateOptions;
+use proxmox_sys::error::SysError;
+use proxmox_sys::fs::CreateOptions;
 use proxmox_tfa::totp::Totp;
 
 pub use proxmox_tfa::api::{
@@ -68,7 +68,7 @@ pub fn write(data: &TfaConfig) -> Result<(), Error> {
     let options = CreateOptions::new().perm(Mode::from_bits_truncate(0o0600));
 
     let json = serde_json::to_vec(data)?;
-    proxmox::tools::fs::replace_file(CONF_FILE, &json, options, true)
+    proxmox_sys::fs::replace_file(CONF_FILE, &json, options, true)
 }
 
 /// Cleanup non-existent users from the tfa config.
@@ -101,7 +101,7 @@ impl TfaUserChallengeData {
             );
         }
 
-        proxmox::c_try!(unsafe { libc::ftruncate(self.lock.as_raw_fd(), 0) });
+        proxmox_sys::c_try!(unsafe { libc::ftruncate(self.lock.as_raw_fd(), 0) });
 
         Ok(())
     }
@@ -224,7 +224,7 @@ impl proxmox_tfa::api::OpenUserChallengeData for UserAccess {
     fn open(&self, userid: &str) -> Result<Self::Data, Error> {
         crate::server::create_run_dir()?;
         let options = CreateOptions::new().perm(Mode::from_bits_truncate(0o0600));
-        proxmox::tools::fs::create_path(CHALLENGE_DATA_PATH, Some(options.clone()), Some(options))
+        proxmox_sys::fs::create_path(CHALLENGE_DATA_PATH, Some(options.clone()), Some(options))
             .map_err(|err| {
                 format_err!(
                     "failed to crate challenge data dir {:?}: {}",
@@ -244,7 +244,7 @@ impl proxmox_tfa::api::OpenUserChallengeData for UserAccess {
             .open(&path)
             .map_err(|err| format_err!("failed to create challenge file {:?}: {}", path, err))?;
 
-        proxmox::tools::fs::lock_file(&mut file, true, None)?;
+        proxmox_sys::fs::lock_file(&mut file, true, None)?;
 
         // the file may be empty, so read to a temporary buffer first:
         let mut data = Vec::with_capacity(4096);
@@ -291,7 +291,7 @@ impl proxmox_tfa::api::OpenUserChallengeData for UserAccess {
             Err(err) => return Err(err.into()),
         };
 
-        proxmox::tools::fs::lock_file(&mut file, true, None)?;
+        proxmox_sys::fs::lock_file(&mut file, true, None)?;
 
         let inner = serde_json::from_reader(&mut file).map_err(|err| {
             format_err!("failed to read challenge data for user {}: {}", userid, err)
index 4550810718a2ef26cb4ad4783ad6913661bf7906..f0fb34b7eb2487fba0617ce73b7d957a04736d2b 100644 (file)
@@ -3,7 +3,7 @@ use std::path::Path;
 use anyhow::{format_err, Error};
 use once_cell::sync::OnceCell;
 
-use proxmox::tools::fs::CreateOptions;
+use proxmox_sys::fs::CreateOptions;
 use proxmox_rrd::RRDCache;
 use proxmox_rrd::rrd::{RRD, DST, CF};
 
index 7c047630db2806b8a5a058bb9ad1b6a7ff163ff3..1e7650b042e28c856803ae8e97c50e18d6cb987f 100644 (file)
@@ -3,7 +3,7 @@ use serde_json::json;
 
 use handlebars::{Handlebars, Helper, Context, RenderError, RenderContext, Output, HelperResult, TemplateError};
 
-use proxmox::tools::email::sendmail;
+use proxmox_sys::email::sendmail;
 use proxmox_lang::try_block;
 use proxmox_schema::{parse_property_string, ApiType};
 
@@ -239,7 +239,7 @@ fn send_job_status_mail(
     // so we include html as well
     let html = format!("<html><body><pre>\n{}\n<pre>", handlebars::html_escape(text));
 
-    let nodename = proxmox::tools::nodename();
+    let nodename = proxmox_sys::nodename();
 
     let author = format!("Proxmox Backup Server - {}", nodename);
 
@@ -504,7 +504,7 @@ fn get_server_url() -> (String, usize) {
 
     // user will surely request that they can change this
 
-    let nodename = proxmox::tools::nodename();
+    let nodename = proxmox_sys::nodename();
     let mut fqdn = nodename.to_owned();
 
     if let Ok(resolv_conf) = crate::api2::node::dns::read_etc_resolv_conf() {
@@ -524,7 +524,7 @@ pub fn send_updates_available(
 ) -> Result<(), Error> {
     // update mails always go to the root@pam configured email..
     if let Some(email) = lookup_user_email(Userid::root_userid()) {
-        let nodename = proxmox::tools::nodename();
+        let nodename = proxmox_sys::nodename();
         let subject = format!("New software packages available ({})", nodename);
 
         let (fqdn, port) = get_server_url();
index f78875ca8a4ba96adae9c8cf5cae53b712b6cb89..adb1bbe21dfeb1f5ac9544136be6d0b7f3eb7cf9 100644 (file)
@@ -42,7 +42,7 @@ use std::path::{Path, PathBuf};
 use anyhow::{bail, format_err, Error};
 use serde::{Deserialize, Serialize};
 
-use proxmox::tools::fs::{
+use proxmox_sys::fs::{
     create_path, file_read_optional_string, replace_file, CreateOptions,
 };
 
index deeb3398e7c20853d3c8d637b034f4a3d74ce39e..2b54cdf0cc43ac20f8a1141d5d143c30ea8fb468 100644 (file)
@@ -7,7 +7,7 @@
 use anyhow::Error;
 use serde_json::Value;
 
-use proxmox::tools::fs::{create_path, CreateOptions};
+use proxmox_sys::fs::{create_path, CreateOptions};
 
 use pbs_buildcfg;
 
index fbd04ad4f82ca6acac37a3130babdd53f3bd5c52..8f9640091bb83f2bee87c0adfc42f9e194d5d2f5 100644 (file)
@@ -110,7 +110,7 @@ async fn pull_index_chunks<I: IndexFile>(
         "sync chunk writer",
         4,
         move |(chunk, digest, size): (DataBlob, [u8; 32], u64)| {
-            // println!("verify and write {}", proxmox::tools::digest_to_hex(&digest));
+            // println!("verify and write {}", hex::encode(&digest));
             chunk.verify_unencrypted(size as usize, &digest)?;
             target2.insert_chunk(&chunk, &digest)?;
             Ok(())
@@ -133,10 +133,10 @@ async fn pull_index_chunks<I: IndexFile>(
                     target.cond_touch_chunk(&info.digest, false)
                 })?;
                 if chunk_exists {
-                    //task_log!(worker, "chunk {} exists {}", pos, proxmox::tools::digest_to_hex(digest));
+                    //task_log!(worker, "chunk {} exists {}", pos, hex::encode(digest));
                     return Ok::<_, Error>(());
                 }
-                //task_log!(worker, "sync {} chunk {}", pos, proxmox::tools::digest_to_hex(digest));
+                //task_log!(worker, "sync {} chunk {}", pos, hex::encode(digest));
                 let chunk = chunk_reader.read_raw_chunk(&info.digest).await?;
                 let raw_size = chunk.raw_size() as usize;
 
index 27a9d89bdb0841091447677b969c219c30f1e127..1e7d60708243066697b39711302f8a5fc8faf948 100644 (file)
@@ -48,7 +48,7 @@ fn function_calls() -> Vec<FunctionMapping> {
 }
 
 pub fn generate_report() -> String {
-    use proxmox::tools::fs::file_read_optional_string;
+    use proxmox_sys::fs::file_read_optional_string;
 
     let file_contents = files()
         .iter()
index 1ca4c7b770f986425c687f6be52e988ba853a53a..a0febc2609bb902a4793a95fb61377b5907db762 100644 (file)
@@ -5,7 +5,7 @@ use std::time::{Instant, Duration};
 use anyhow::{bail, Error};
 use nix::sys::stat::Mode;
 
-use proxmox::tools::fs::{create_path, CreateOptions};
+use proxmox_sys::fs::{create_path, CreateOptions};
 
 use proxmox_http::client::{RateLimit, RateLimiter, ShareableRateLimit};
 use proxmox_shared_memory::{Init, SharedMemory, SharedMutex};
index 63c54b41b6d601351bdcf09a169c385a28c8ceb1..6b2477d2fa39fa085f308030b8fdf7bc447ff6f3 100644 (file)
@@ -9,7 +9,7 @@ use std::path::PathBuf;
 
 use anyhow::{bail, Error};
 
-use proxmox::tools::fs::{CreateOptions, replace_file, file_read_optional_string};
+use proxmox_sys::fs::{CreateOptions, replace_file, file_read_optional_string};
 
 use pbs_api_types::{ScsiTapeChanger, LtoTapeDrive};
 
index 7fcf4ad474238963171934094ab3a254307e53ed..796b782fda54c59c0ac25081074730a7bf903669 100644 (file)
@@ -1,6 +1,6 @@
 use anyhow::Error;
 
-use pbs_tools::run_command;
+use proxmox_sys::command::run_command;
 use pbs_api_types::ScsiTapeChanger;
 use pbs_tape::MtxStatus;
 
index 78413f94548ce453524a32a350edd574fc207072..5f4bc12e9c449322e1caac068c5c9a9fe4cb4de7 100644 (file)
@@ -23,7 +23,7 @@ use pbs_api_types::{
     Fingerprint, MamAttribute, LtoDriveAndMediaStatus, LtoTapeDrive, Lp17VolumeStatistics,
 };
 use pbs_config::key_config::KeyConfig;
-use pbs_tools::run_command;
+use proxmox_sys::command::run_command;
 use pbs_tape::{
     TapeWrite, TapeRead, BlockReadError, MediaContentHeader,
     sg_tape::{SgTape, TapeAlertFlags},
index a50a8a9a2012fb08485a51fde8fbe480b4e02cf1..7e7372c6cb55cfabe6863d730c11d746194d36e0 100644 (file)
@@ -13,21 +13,18 @@ use serde_json::Value;
 use nix::fcntl::OFlag;
 use nix::sys::stat::Mode;
 
-use proxmox::{
-    tools::{
-        fs::{
-            lock_file,
-            atomic_open_or_create_file,
-            file_read_optional_string,
-            replace_file,
-            CreateOptions,
-       }
-    },
+use proxmox_sys::fs::{
+    lock_file,
+    atomic_open_or_create_file,
+    file_read_optional_string,
+    replace_file,
+    CreateOptions,
 };
+
 use proxmox_io::ReadExt;
 use proxmox_section_config::SectionConfigData;
 use proxmox_uuid::Uuid;
-use proxmox_sys::{task_log, worker_task_context::WorkerTaskContext};
+use proxmox_sys::{task_log, WorkerTaskContext};
 
 use pbs_api_types::{VirtualTapeDrive, LtoTapeDrive, Fingerprint};
 use pbs_config::key_config::KeyConfig;
@@ -602,7 +599,7 @@ pub struct DeviceLockGuard(std::fs::File);
 // Uses systemd escape_unit to compute a file name from `device_path`, the try
 // to lock `/var/lock/<name>`.
 fn open_device_lock(device_path: &str) -> Result<std::fs::File, Error> {
-    let lock_name = proxmox::tools::systemd::escape_unit(device_path, true);
+    let lock_name = proxmox_sys::systemd::escape_unit(device_path, true);
 
     let mut path = std::path::PathBuf::from(crate::tape::DRIVE_LOCK_DIR);
     path.push(lock_name);
index 4f1fe4d8699a44599048b89671ce98279eba5437..186e87ac862aa7562054202fdd9a24f508557145 100644 (file)
@@ -6,7 +6,7 @@ use std::io;
 use anyhow::{bail, format_err, Error};
 use serde::{Serialize, Deserialize};
 
-use proxmox::tools::{
+use proxmox_sys::{
     fs::{replace_file, CreateOptions},
 };
 
@@ -48,7 +48,7 @@ pub fn open_virtual_tape_drive(config: &VirtualTapeDrive) -> Result<VirtualTapeH
 
         let options = CreateOptions::new();
         let timeout = std::time::Duration::new(10, 0);
-        let lock = proxmox::tools::fs::open_file_locked(&lock_path, timeout, true, options)?;
+        let lock = proxmox_sys::fs::open_file_locked(&lock_path, timeout, true, options)?;
 
         Ok(VirtualTapeHandle {
             _lock: lock,
@@ -104,7 +104,7 @@ impl VirtualTapeHandle {
 
     fn load_tape_index(&self, tape_name: &str) -> Result<TapeIndex, Error> {
         let path = self.tape_index_path(tape_name);
-        let raw = proxmox::tools::fs::file_get_contents(&path)?;
+        let raw = proxmox_sys::fs::file_get_contents(&path)?;
         if raw.is_empty() {
             return Ok(TapeIndex { files: 0 });
         }
@@ -147,7 +147,7 @@ impl VirtualTapeHandle {
             current_tape: None,
         })?;
 
-        let data = proxmox::tools::fs::file_get_json(&path, Some(default))?;
+        let data = proxmox_sys::fs::file_get_json(&path, Some(default))?;
         let status: VirtualDriveStatus = serde_json::from_value(data)?;
         Ok(status)
     }
@@ -309,7 +309,7 @@ impl TapeDriver for VirtualTapeHandle {
                 Ok(Box::new(reader))
             }
             None => {
-                return Err(BlockReadError::Error(proxmox::io_format_err!("drive is empty (no tape loaded).")));
+                return Err(BlockReadError::Error(proxmox_sys::io_format_err!("drive is empty (no tape loaded).")));
             }
         }
     }
@@ -362,7 +362,7 @@ impl TapeDriver for VirtualTapeHandle {
 
                 Ok(writer)
             }
-            None => proxmox::io_bail!("drive is empty (no tape loaded)."),
+            None => proxmox_sys::io_bail!("drive is empty (no tape loaded)."),
         }
     }
 
index b27adff04eb2be0af15e492da828ccca9bb6afec..04a60319a49cd134cfb292ddcc6cf141d687f616 100644 (file)
@@ -1,7 +1,7 @@
 use std::fs::File;
 use std::io::Read;
 
-use proxmox::sys::error::SysError;
+use proxmox_sys::error::SysError;
 use proxmox_uuid::Uuid;
 
 use pbs_tape::{
@@ -61,13 +61,13 @@ pub fn tape_write_catalog<'a>(
         while remaining != 0 {
             let got = file.read(&mut file_copy_buffer[..])?;
             if got as u64 > remaining {
-                proxmox::io_bail!("catalog '{}' changed while reading", uuid);
+                proxmox_sys::io_bail!("catalog '{}' changed while reading", uuid);
             }
             writer.write_all(&file_copy_buffer[..got])?;
             remaining -= got as u64;
         }
         if remaining > 0 {
-            proxmox::io_bail!("catalog '{}' shrunk while reading", uuid);
+            proxmox_sys::io_bail!("catalog '{}' shrunk while reading", uuid);
         }
         Ok(())
     });
index 9bd5c8144a429c4cd1413c33402236ce2ac9094a..404797007abd8f06aa9876eb4106e90fea9bfe78 100644 (file)
@@ -69,7 +69,7 @@ impl <'a> ChunkArchiveWriter<'a> {
     fn write_all(&mut self, data: &[u8]) -> Result<bool, std::io::Error> {
         match self.writer {
             Some(ref mut writer) => writer.write_all(data),
-            None => proxmox::io_bail!(
+            None => proxmox_sys::io_bail!(
                 "detected write after archive finished - internal error"),
         }
     }
index 83d19e79021346fefaa511e92a65ae7fd5692d98..cc0d52abf25d94f20bf93023ade1445be991f66b 100644 (file)
@@ -48,23 +48,23 @@ impl <'a> Read for MultiVolumeReader<'a> {
 
         if self.reader.is_none() {
             let mut reader = (self.next_reader_fn)()
-                .map_err(|err| proxmox::io_format_err!("multi-volume next failed: {}", err))?;
+                .map_err(|err| proxmox_sys::io_format_err!("multi-volume next failed: {}", err))?;
 
             proxmox_lang::try_block!({
                 let part_header: MediaContentHeader = unsafe { reader.read_le_value()? };
                 self.reader = Some(reader);
 
                 if part_header.uuid != self.header.uuid {
-                    proxmox::io_bail!("got wrong part uuid");
+                    proxmox_sys::io_bail!("got wrong part uuid");
                 }
                 if part_header.content_magic!= self.header.content_magic {
-                    proxmox::io_bail!("got wrong part content magic");
+                    proxmox_sys::io_bail!("got wrong part content magic");
                 }
 
                 let expect_part_number = self.header.part_number + 1;
 
                 if part_header.part_number != expect_part_number {
-                    proxmox::io_bail!("got wrong part number ({} != {})",
+                    proxmox_sys::io_bail!("got wrong part number ({} != {})",
                                       part_header.part_number, expect_part_number);
                 }
 
@@ -72,7 +72,7 @@ impl <'a> Read for MultiVolumeReader<'a> {
 
                 Ok(())
             }).map_err(|err| {
-                proxmox::io_format_err!("multi-volume read content header failed: {}", err)
+                proxmox_sys::io_format_err!("multi-volume read content header failed: {}", err)
             })?;
          }
 
index aef34ec595f7758a09fbf839518ea3b76de503ad..8d51969e1ace05097fed6bca37a222d58b2bf183 100644 (file)
@@ -53,16 +53,16 @@ impl <'a> TapeWrite for MultiVolumeWriter<'a> {
     fn write_all(&mut self, buf: &[u8]) -> Result<bool, std::io::Error> {
 
         if self.finished {
-            proxmox::io_bail!("multi-volume writer already finished: internal error");
+            proxmox_sys::io_bail!("multi-volume writer already finished: internal error");
         }
 
         if self.got_leom {
             if !self.wrote_header {
-                proxmox::io_bail!("multi-volume writer: got LEOM before writing anything - internal error");
+                proxmox_sys::io_bail!("multi-volume writer: got LEOM before writing anything - internal error");
             }
             let mut writer = match self.writer.take() {
                 Some(writer) => writer,
-                None =>  proxmox::io_bail!("multi-volume writer: no writer  -internal error"),
+                None =>  proxmox_sys::io_bail!("multi-volume writer: no writer  -internal error"),
             };
             self.bytes_written = writer.bytes_written();
             writer.finish(true)?;
@@ -70,11 +70,11 @@ impl <'a> TapeWrite for MultiVolumeWriter<'a> {
 
         if self.writer.is_none() {
             if self.header.part_number >= 255 {
-                proxmox::io_bail!("multi-volume writer: too many parts");
+                proxmox_sys::io_bail!("multi-volume writer: too many parts");
             }
             self.writer = Some(
                 (self.next_writer_fn)()
-                    .map_err(|err| proxmox::io_format_err!("multi-volume get next volume failed: {}", err))?
+                    .map_err(|err| proxmox_sys::io_format_err!("multi-volume get next volume failed: {}", err))?
             );
             self.got_leom = false;
             self.wrote_header = false;
@@ -107,12 +107,12 @@ impl <'a> TapeWrite for MultiVolumeWriter<'a> {
 
     fn finish(&mut self, incomplete: bool) -> Result<bool, std::io::Error> {
         if incomplete {
-            proxmox::io_bail!(
+            proxmox_sys::io_bail!(
                 "incomplete flag makes no sense for multi-volume stream: internal error");
         }
 
         match self.writer.take() {
-            None if self.finished => proxmox::io_bail!(
+            None if self.finished => proxmox_sys::io_bail!(
                 "multi-volume writer already finished: internal error"),
             None => Ok(false),
             Some(ref mut writer) => {
index 502b3cbbe260557217a090475ab834eea8cbb4e4..d3bd590ba65c278ea82f7e8177172215401952e5 100644 (file)
@@ -2,7 +2,7 @@ use std::io::{Read, Write};
 use std::pin::Pin;
 use std::task::{Context, Poll};
 
-use proxmox::sys::error::SysError;
+use proxmox_sys::error::SysError;
 use proxmox_uuid::Uuid;
 
 use pbs_tape::{
@@ -58,14 +58,14 @@ pub fn tape_write_snapshot_archive<'a>(
         for filename in file_list.iter() {
 
             let mut file = snapshot_reader.open_file(filename)
-                .map_err(|err| proxmox::io_format_err!("open file '{}' failed - {}", filename, err))?;
+                .map_err(|err| proxmox_sys::io_format_err!("open file '{}' failed - {}", filename, err))?;
             let metadata = file.metadata()?;
             let file_size = metadata.len();
 
             let metadata: pxar::Metadata = metadata.into();
 
             if !metadata.is_regular_file() {
-                proxmox::io_bail!("file '{}' is not a regular file", filename);
+                proxmox_sys::io_bail!("file '{}' is not a regular file", filename);
             }
 
             let mut remaining = file_size;
@@ -73,14 +73,14 @@ pub fn tape_write_snapshot_archive<'a>(
             while remaining != 0 {
                 let got = file.read(&mut file_copy_buffer[..])?;
                 if got as u64 > remaining {
-                    proxmox::io_bail!("file '{}' changed while reading", filename);
+                    proxmox_sys::io_bail!("file '{}' changed while reading", filename);
                 }
                 out.write_all(&file_copy_buffer[..got])?;
                 remaining -= got as u64;
 
             }
             if remaining > 0 {
-                proxmox::io_bail!("file '{}' shrunk while reading", filename);
+                proxmox_sys::io_bail!("file '{}' shrunk while reading", filename);
             }
         }
         encoder.finish()?;
index ae7ed31cc9db42ce4a0fb11add0867eae997145b..4ecbb42520f7ce9ba7aa0cd47ad2172d0e67b1cc 100644 (file)
@@ -30,7 +30,7 @@ use anyhow::{bail, Error};
 use serde::{Serialize, Deserialize};
 use serde_json::json;
 
-use proxmox::tools::fs::{replace_file, file_get_json, CreateOptions};
+use proxmox_sys::fs::{replace_file, file_get_json, CreateOptions};
 use proxmox_uuid::Uuid;
 
 use proxmox_time::compute_next_event;
index 8fff17f158a81fa196f17e37bd04044b6961b203..7ec622b8de38e8f34d85d856bc9fd071e20d0dff 100644 (file)
@@ -8,10 +8,10 @@ use std::collections::{HashSet, HashMap};
 use anyhow::{bail, format_err, Error};
 use endian_trait::Endian;
 
-use pbs_tools::fs::read_subdir;
+use proxmox_sys::fs::read_subdir;
 use pbs_datastore::backup_info::BackupDir;
 
-use proxmox::tools::fs::{
+use proxmox_sys::fs::{
     fchown,
     create_path,
     CreateOptions,
@@ -541,7 +541,7 @@ impl MediaCatalog {
         };
 
         if self.log_to_stdout {
-            println!("C|{}", proxmox::tools::digest_to_hex(digest));
+            println!("C|{}", hex::encode(digest));
         }
 
         self.pending.push(b'C');
index bcfdd70093dfd6ca4d8bae53787ae746c2a1ead4..00daa5b9e91f6f3d39593efa202d76b9410919be 100644 (file)
@@ -3,7 +3,7 @@ use std::io::{BufRead, BufReader};
 
 use anyhow::{format_err, bail, Error};
 
-use proxmox::tools::fs::CreateOptions;
+use proxmox_sys::fs::CreateOptions;
 
 use crate::tape::{MediaCatalog, MediaId};
 
@@ -98,7 +98,7 @@ fn write_snapshot_cache(
         .owner(backup_user.uid)
         .group(backup_user.gid);
 
-    proxmox::tools::fs::replace_file(
+    proxmox_sys::fs::replace_file(
         cache_path,
         data.as_bytes(),
         options,
index 897d15254baeab5a68c42f5af572b4fceed44a98..291d0b42119b39f66d61372a47b58bbb4d2ddbb7 100644 (file)
@@ -2,7 +2,7 @@
 
 use anyhow::{format_err, Error};
 
-use proxmox::tools::fs::{
+use proxmox_sys::fs::{
     create_path,
     CreateOptions,
 };
index 72ca5a92da8559659447088418787e5fea11359c..5d10e16b07a077914a03a763fa8742d720f48c10 100644 (file)
@@ -554,7 +554,7 @@ fn write_chunk_archive<'a>(
             Some(Err(err)) => bail!("{}", err),
         };
 
-        //println!("CHUNK {} size {}", proxmox::tools::digest_to_hex(digest), blob.raw_size());
+        //println!("CHUNK {} size {}", hex::encode(digest), blob.raw_size());
 
         match writer.try_write_chunk(&digest, &blob) {
             Ok(true) => {
index 71810a83274f625e42c18e33229f6b2d3bd71e82..8e759a2ffab9f4d242ab7aceed56ee97817ec122 100644 (file)
@@ -58,7 +58,7 @@ impl NewChunksIterator {
                     };
 
                     let blob = datastore.load_chunk(&digest)?;
-                    //println!("LOAD CHUNK {}", proxmox::tools::digest_to_hex(&digest));
+                    //println!("LOAD CHUNK {}", hex::encode(&digest));
                     match tx.send(Ok(Some((digest, blob)))) {
                         Ok(()) => {},
                         Err(err) => {
index e1e8add83a1bfdd82393784c48b1474ff1d398cd..3e016cfe8a252d7e00d4baa9cd8fd7da6f84420d 100644 (file)
@@ -4,7 +4,7 @@ use std::collections::HashMap;
 use anyhow::{Error, bail, format_err};
 use apt_pkg_native::Cache;
 
-use proxmox::tools::fs::{file_read_optional_string, replace_file, CreateOptions};
+use proxmox_sys::fs::{file_read_optional_string, replace_file, CreateOptions};
 use proxmox_schema::const_regex;
 
 use pbs_buildcfg::PROXMOX_BACKUP_STATE_DIR_M;
@@ -102,7 +102,7 @@ fn get_changelog_url(
         command.arg("changelog");
         command.arg("--print-uris");
         command.arg(package);
-        let output = pbs_tools::run_command(command, None)?; // format: 'http://foo/bar' package.changelog
+        let output = proxmox_sys::command::run_command(command, None)?; // format: 'http://foo/bar' package.changelog
         let output = match output.splitn(2, ' ').next() {
             Some(output) => {
                 if output.len() < 2 {
index fad09c282a27602e7d00ab97d51ffdc829b785d5..2aeabb6d421dca8dc032e99e51b03a11e429a977 100644 (file)
@@ -27,7 +27,7 @@ pub fn get_lvm_devices(
     let mut command = std::process::Command::new(PVS_BIN_PATH);
     command.args(&["--reportformat", "json", "--noheadings", "--readonly", "-o", "pv_name"]);
 
-    let output = pbs_tools::run_command(command, None)?;
+    let output = proxmox_sys::command::run_command(command, None)?;
 
     let mut device_set: HashSet<u64> = HashSet::new();
 
index d3e69c6d1bf28fdc7f2859efa801881cf99b10ab..867aa6245cb5f3c3d967375e91058f0b86ad17be 100644 (file)
@@ -14,9 +14,9 @@ use once_cell::sync::OnceCell;
 
 use ::serde::{Deserialize, Serialize};
 
-use proxmox::sys::error::io_err_other;
-use proxmox::sys::linux::procfs::{MountInfo, mountinfo::Device};
-use proxmox::{io_bail, io_format_err};
+use proxmox_sys::error::io_err_other;
+use proxmox_sys::linux::procfs::{MountInfo, mountinfo::Device};
+use proxmox_sys::{io_bail, io_format_err};
 use proxmox_schema::api;
 
 use pbs_api_types::{BLOCKDEVICE_NAME_REGEX, StorageStatus};
@@ -498,7 +498,7 @@ impl Disk {
 
         let mut map = HashMap::new();
 
-        for item in pbs_tools::fs::read_subdir(libc::AT_FDCWD, sys_path)? {
+        for item in proxmox_sys::fs::read_subdir(libc::AT_FDCWD, sys_path)? {
             let item = item?;
             let name = match item.file_name().to_str() {
                 Ok(name) => name,
@@ -574,7 +574,7 @@ pub fn get_lsblk_info() -> Result<Vec<LsblkInfo>, Error> {
     let mut command = std::process::Command::new("lsblk");
     command.args(&["--json", "-o", "path,parttype,fstype"]);
 
-    let output = pbs_tools::run_command(command, None)?;
+    let output = proxmox_sys::command::run_command(command, None)?;
 
     let mut output: serde_json::Value = output.parse()?;
 
@@ -680,7 +680,7 @@ fn scan_partitions(
     let mut found_dm = false;
     let mut found_partitions = false;
 
-    for item in pbs_tools::fs::read_subdir(libc::AT_FDCWD, &sys_path)? {
+    for item in proxmox_sys::fs::read_subdir(libc::AT_FDCWD, &sys_path)? {
         let item = item?;
         let name = match item.file_name().to_str() {
             Ok(name) => name,
@@ -770,7 +770,7 @@ pub fn get_disks(
 
     let mut result = HashMap::new();
 
-    for item in pbs_tools::fs::scan_subdir(libc::AT_FDCWD, "/sys/block", &BLOCKDEVICE_NAME_REGEX)? {
+    for item in proxmox_sys::fs::scan_subdir(libc::AT_FDCWD, "/sys/block", &BLOCKDEVICE_NAME_REGEX)? {
         let item = item?;
 
         let name = item.file_name().to_str().unwrap().to_string();
@@ -886,7 +886,7 @@ pub fn reread_partition_table(disk: &Disk) -> Result<(), Error> {
     command.arg("--rereadpt");
     command.arg(disk_path);
 
-    pbs_tools::run_command(command, None)?;
+    proxmox_sys::command::run_command(command, None)?;
 
     Ok(())
 }
@@ -905,7 +905,7 @@ pub fn inititialize_gpt_disk(disk: &Disk, uuid: Option<&str>) -> Result<(), Erro
     command.arg(disk_path);
     command.args(&["-U", uuid]);
 
-    pbs_tools::run_command(command, None)?;
+    proxmox_sys::command::run_command(command, None)?;
 
     Ok(())
 }
@@ -922,7 +922,7 @@ pub fn create_single_linux_partition(disk: &Disk) -> Result<Disk, Error> {
     command.args(&["-n1", "-t1:8300"]);
     command.arg(disk_path);
 
-    pbs_tools::run_command(command, None)?;
+    proxmox_sys::command::run_command(command, None)?;
 
     let mut partitions = disk.partitions()?;
 
@@ -975,7 +975,7 @@ pub fn create_file_system(disk: &Disk, fs_type: FileSystemType) -> Result<(), Er
     command.args(&["-t", &fs_type]);
     command.arg(disk_path);
 
-    pbs_tools::run_command(command, None)?;
+    proxmox_sys::command::run_command(command, None)?;
 
     Ok(())
 }
@@ -984,7 +984,7 @@ pub fn create_file_system(disk: &Disk, fs_type: FileSystemType) -> Result<(), Er
 pub fn complete_disk_name(_arg: &str, _param: &HashMap<String, String>) -> Vec<String> {
     let mut list = Vec::new();
 
-    let dir = match pbs_tools::fs::scan_subdir(libc::AT_FDCWD, "/sys/block", &BLOCKDEVICE_NAME_REGEX) {
+    let dir = match proxmox_sys::fs::scan_subdir(libc::AT_FDCWD, "/sys/block", &BLOCKDEVICE_NAME_REGEX) {
         Ok(dir) => dir,
         Err(_) => return list,
     };
@@ -1013,7 +1013,7 @@ pub fn get_fs_uuid(disk: &Disk) -> Result<String, Error> {
     command.args(&["-o", "export"]);
     command.arg(disk_path);
 
-    let output = pbs_tools::run_command(command, None)?;
+    let output = proxmox_sys::command::run_command(command, None)?;
 
     for line in output.lines() {
         if let Some(uuid) = line.strip_prefix("UUID=") {
index 20d9ceaa58774ee0f74897d9c2d8a4d7c0dc40cb..ee79d3e80c5738d59d948ea3d8f5b10a39df0e90 100644 (file)
@@ -91,7 +91,7 @@ pub fn get_smart_data(
     };
     command.arg(disk_path);
 
-    let output = pbs_tools::run_command(command, Some(|exitcode|
+    let output = proxmox_sys::command::run_command(command, Some(|exitcode|
         (exitcode & 0b0111) == 0 // only bits 0-2 are fatal errors
     ))?;
 
index 55e0aa30bb8c036b6f4699e53b896400d7013bfd..2f18919df0f9c3ac864fc7bba2ba16d5c2e81648 100644 (file)
@@ -34,7 +34,7 @@ pub fn zfs_pool_stats(pool: &OsStr) -> Result<Option<BlockDevStat>, Error> {
     path.push(pool);
     path.push("io");
 
-    let text = match proxmox::tools::fs::file_read_optional_string(&path)? {
+    let text = match proxmox_sys::fs::file_read_optional_string(&path)? {
         Some(text) => text,
         None => { return Ok(None); }
     };
index 957ef02ea00a1d754f176f022dc92c7985a7518e..e68cfef8000b0ae041fc369e3576a73fa9ebb7d8 100644 (file)
@@ -147,7 +147,7 @@ pub fn zpool_list(pool: Option<String>, verbose: bool) -> Result<Vec<ZFSPoolInfo
 
     if let Some(pool) = pool { command.arg(pool); }
 
-    let output = pbs_tools::run_command(command, None)?;
+    let output = proxmox_sys::command::run_command(command, None)?;
 
     parse_zpool_list(&output)
 }
index e7befa7dd2cf93c3fed413dc352ed5f776270db8..b2d8e35bef65d1f25afb4b20edfb04010cfef561 100644 (file)
@@ -364,7 +364,7 @@ pub fn zpool_status(pool: &str) -> Result<Vec<(String, String)>, Error> {
     let mut command = std::process::Command::new("zpool");
     command.args(&["status", "-p", "-P", pool]);
 
-    let output = pbs_tools::run_command(command, None)?;
+    let output = proxmox_sys::command::run_command(command, None)?;
 
     parse_zpool_status(&output)
 }
index dba8dc985419631a344c5cecd571fbc72512a782..490f0b3ce3fddf3c5cc6a1d625617991646efef5 100644 (file)
@@ -18,5 +18,5 @@ use tokio::{
 };
 use tokio_openssl::SslStream;
 
-use proxmox::sys::linux::socket::set_tcp_keepalive;
+use proxmox_sys::linux::socket::set_tcp_keepalive;
 use proxmox_http::http::{MaybeTlsStream, ProxyConfig};
index 03b9da863d53a157f82ea960d9dc81245a4bc65d..1f123848539c8d56c97f894e228f01f4f10179ef 100644 (file)
@@ -32,12 +32,12 @@ pub fn md5sum(data: &[u8]) -> Result<DigestBytes, Error> {
 pub fn get_hardware_address() -> Result<String, Error> {
     static FILENAME: &str = "/etc/ssh/ssh_host_rsa_key.pub";
 
-    let contents = proxmox::tools::fs::file_get_contents(FILENAME)
+    let contents = proxmox_sys::fs::file_get_contents(FILENAME)
         .map_err(|e| format_err!("Error getting host key - {}", e))?;
     let digest = md5sum(&contents)
         .map_err(|e| format_err!("Error digesting host key - {}", e))?;
 
-    Ok(proxmox::tools::bin_to_hex(&digest).to_uppercase())
+    Ok(hex::encode(&digest).to_uppercase())
 }
 
 pub fn assert_if_modified(digest1: &str, digest2: &str) -> Result<(), Error> {
index 85a37ce2cb1e669c33e7c8eb840f8480806444b4..e07fd358fd11e8bf1f3e6f6e27eee1e623c31e9b 100644 (file)
@@ -6,7 +6,7 @@ use serde_json::json;
 
 use proxmox_schema::api;
 
-use proxmox::tools::fs::{replace_file, CreateOptions};
+use proxmox_sys::fs::{replace_file, CreateOptions};
 use proxmox_http::client::SimpleHttp;
 
 use pbs_tools::json::json_object_to_query;
@@ -99,7 +99,7 @@ async fn register_subscription(
     checktime: i64
 ) -> Result<(String, String), Error> {
     // WHCMS sample code feeds the key into this, but it's just a challenge, so keep it simple
-    let rand = proxmox::tools::bin_to_hex(&proxmox::sys::linux::random_data(16)?);
+    let rand = hex::encode(&proxmox_sys::linux::random_data(16)?);
     let challenge = format!("{}{}", checktime, rand);
 
     let params = json!({
@@ -180,7 +180,7 @@ fn parse_register_response(
 
     if let SubscriptionStatus::ACTIVE = info.status {
         let response_raw = format!("{}{}", SHARED_KEY_DATA, challenge);
-        let expected = proxmox::tools::bin_to_hex(&tools::md5sum(response_raw.as_bytes())?);
+        let expected = hex::encode(&tools::md5sum(response_raw.as_bytes())?);
         if expected != md5hash {
             bail!("Subscription API challenge failed, expected {} != got {}", expected, md5hash);
         }
@@ -241,7 +241,7 @@ pub fn check_subscription(key: String, server_id: String) -> Result<Subscription
 /// reads in subscription information and does a basic integrity verification
 pub fn read_subscription() -> Result<Option<SubscriptionInfo>, Error> {
 
-    let cfg = proxmox::tools::fs::file_read_optional_string(&SUBSCRIPTION_FN)?;
+    let cfg = proxmox_sys::fs::file_read_optional_string(&SUBSCRIPTION_FN)?;
     let cfg = if let Some(cfg) = cfg { cfg } else { return Ok(None); };
 
     let mut cfg = cfg.lines();
index baf94e88dd155d340235ad31a0a46b6516bab222..f0e7f342263d2c8afa272bd821b475c62f15e713 100644 (file)
@@ -6,7 +6,7 @@ use super::types::*;
 use proxmox_schema::*;
 use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
 
-use proxmox::tools::{fs::replace_file, fs::CreateOptions};
+use proxmox_sys::{fs::replace_file, fs::CreateOptions};
 
 
 lazy_static! {
@@ -104,7 +104,7 @@ fn init_mount() -> SectionConfig {
 
 fn parse_systemd_config(config: &SectionConfig, filename: &str) -> Result<SectionConfigData, Error> {
 
-    let raw = proxmox::tools::fs::file_get_contents(filename)?;
+    let raw = proxmox_sys::fs::file_get_contents(filename)?;
     let input = String::from_utf8(raw)?;
 
     let data = config.parse(filename, &input)?;
index b31f2c3f2ba780f33f689002a139438eae76130f..f27ff6b1dc1c8522cee550ff993d79004bd1193a 100644 (file)
@@ -97,7 +97,7 @@ pub fn reload_unit(unit: &str) -> Result<(), Error> {
 fn test_escape_unit() -> Result<(), Error> {
     fn test_escape(i: &str, expected: &str, is_path: bool) {
 
-        use proxmox::tools::systemd::{escape_unit, unescape_unit};
+        use proxmox_sys::systemd::{escape_unit, unescape_unit};
 
         let escaped = escape_unit(i, is_path);
         assert_eq!(escaped, expected);
index cd4e9abbb1d1ca2e62220c6d1d8dd7594053fca9..7ebad16481ab5bdfce530c292f461bdb8eee5b8f 100644 (file)
@@ -5,9 +5,9 @@ extern crate proxmox_backup;
 extern crate tokio;
 extern crate nix;
 
-use proxmox::tools::fs::CreateOptions;
+use proxmox_sys::fs::CreateOptions;
 use proxmox_lang::try_block;
-use proxmox_sys::{task_log, worker_task_context::WorkerTaskContext};
+use proxmox_sys::{task_log, WorkerTaskContext};
 
 use pbs_api_types::{Authid, UPID};