update to proxmox-sys 0.2 crate
- 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>
This commit is contained in:
@ -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?;
|
||||
|
@ -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());
|
||||
|
@ -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()?;
|
||||
|
@ -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)?;
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user