split out pbs-buildcfg module
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
aceae32baa
commit
af06decd1b
@ -19,6 +19,11 @@ build = "build.rs"
|
|||||||
|
|
||||||
exclude = [ "build", "debian", "tests/catar_data/test_symlink/symlink1"]
|
exclude = [ "build", "debian", "tests/catar_data/test_symlink/symlink1"]
|
||||||
|
|
||||||
|
[workspace]
|
||||||
|
members = [
|
||||||
|
"pbs-buildcfg",
|
||||||
|
]
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "proxmox_backup"
|
name = "proxmox_backup"
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
@ -86,6 +91,8 @@ proxmox-http = { version = "0.2.1", features = [ "client", "http-helpers", "webs
|
|||||||
#proxmox-http = { version = "0.2.0", path = "../proxmox/proxmox-http", features = [ "client", "http-helpers", "websocket" ] }
|
#proxmox-http = { version = "0.2.0", path = "../proxmox/proxmox-http", features = [ "client", "http-helpers", "websocket" ] }
|
||||||
proxmox-openid = "0.6.0"
|
proxmox-openid = "0.6.0"
|
||||||
|
|
||||||
|
pbs-buildcfg = { path = "pbs-buildcfg" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
#valgrind = ["valgrind_request"]
|
#valgrind = ["valgrind_request"]
|
||||||
|
8
pbs-buildcfg/Cargo.toml
Normal file
8
pbs-buildcfg/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "pbs-buildcfg"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Proxmox Support Team <support@proxmox.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
description = "macros used for pbs related paths such as configdir and rundir"
|
||||||
|
|
||||||
|
[dependencies]
|
@ -70,6 +70,6 @@ macro_rules! configdir {
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! rundir {
|
macro_rules! rundir {
|
||||||
($subdir:expr) => {
|
($subdir:expr) => {
|
||||||
concat!(PROXMOX_BACKUP_RUN_DIR_M!(), $subdir)
|
concat!($crate::PROXMOX_BACKUP_RUN_DIR_M!(), $subdir)
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -11,6 +11,8 @@ use proxmox::api::router::SubdirMap;
|
|||||||
use proxmox::api::{api, Permission, Router, RpcEnvironment};
|
use proxmox::api::{api, Permission, Router, RpcEnvironment};
|
||||||
use proxmox::list_subdirs_api_method;
|
use proxmox::list_subdirs_api_method;
|
||||||
|
|
||||||
|
use pbs_buildcfg::configdir;
|
||||||
|
|
||||||
use crate::acme::AcmeClient;
|
use crate::acme::AcmeClient;
|
||||||
use crate::api2::types::Authid;
|
use crate::api2::types::Authid;
|
||||||
use crate::api2::types::NODE_SCHEMA;
|
use crate::api2::types::NODE_SCHEMA;
|
||||||
|
@ -9,6 +9,8 @@ use std::ffi::{CString, CStr};
|
|||||||
use anyhow::{bail, format_err, Error};
|
use anyhow::{bail, format_err, Error};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
|
use pbs_buildcfg::configdir;
|
||||||
|
|
||||||
use crate::api2::types::{Userid, UsernameRef, RealmRef};
|
use crate::api2::types::{Userid, UsernameRef, RealmRef};
|
||||||
|
|
||||||
pub trait ProxmoxAuthenticator {
|
pub trait ProxmoxAuthenticator {
|
||||||
|
@ -10,6 +10,8 @@ use std::path::PathBuf;
|
|||||||
use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
|
use proxmox::tools::fs::{file_get_contents, replace_file, CreateOptions};
|
||||||
use proxmox::try_block;
|
use proxmox::try_block;
|
||||||
|
|
||||||
|
use pbs_buildcfg::configdir;
|
||||||
|
|
||||||
use crate::api2::types::Userid;
|
use crate::api2::types::Userid;
|
||||||
|
|
||||||
fn compute_csrf_secret_digest(
|
fn compute_csrf_secret_digest(
|
||||||
|
@ -14,7 +14,6 @@ use proxmox_backup::server::{
|
|||||||
use proxmox_backup::tools::daemon;
|
use proxmox_backup::tools::daemon;
|
||||||
use proxmox_backup::auth_helpers::*;
|
use proxmox_backup::auth_helpers::*;
|
||||||
use proxmox_backup::config;
|
use proxmox_backup::config;
|
||||||
use proxmox_backup::buildcfg;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
proxmox_backup::tools::setup_safe_path_env();
|
proxmox_backup::tools::setup_safe_path_env();
|
||||||
@ -58,7 +57,7 @@ async fn run() -> Result<(), Error> {
|
|||||||
let _ = csrf_secret(); // load with lazy_static
|
let _ = csrf_secret(); // load with lazy_static
|
||||||
|
|
||||||
let mut config = server::ApiConfig::new(
|
let mut config = server::ApiConfig::new(
|
||||||
buildcfg::JS_DIR,
|
pbs_buildcfg::JS_DIR,
|
||||||
&proxmox_backup::api2::ROUTER,
|
&proxmox_backup::api2::ROUTER,
|
||||||
RpcEnvironmentType::PRIVILEGED,
|
RpcEnvironmentType::PRIVILEGED,
|
||||||
default_api_auth(),
|
default_api_auth(),
|
||||||
@ -66,7 +65,7 @@ async fn run() -> Result<(), Error> {
|
|||||||
|
|
||||||
let mut commando_sock = server::CommandoSocket::new(server::our_ctrl_sock());
|
let mut commando_sock = server::CommandoSocket::new(server::our_ctrl_sock());
|
||||||
|
|
||||||
config.enable_file_log(buildcfg::API_ACCESS_LOG_FN, &mut commando_sock)?;
|
config.enable_file_log(pbs_buildcfg::API_ACCESS_LOG_FN, &mut commando_sock)?;
|
||||||
|
|
||||||
let rest_server = RestServer::new(config);
|
let rest_server = RestServer::new(config);
|
||||||
|
|
||||||
@ -91,7 +90,7 @@ async fn run() -> Result<(), Error> {
|
|||||||
"proxmox-backup.service",
|
"proxmox-backup.service",
|
||||||
);
|
);
|
||||||
|
|
||||||
server::write_pid(buildcfg::PROXMOX_BACKUP_API_PID_FN)?;
|
server::write_pid(pbs_buildcfg::PROXMOX_BACKUP_API_PID_FN)?;
|
||||||
daemon::systemd_notify(daemon::SystemdNotify::Ready)?;
|
daemon::systemd_notify(daemon::SystemdNotify::Ready)?;
|
||||||
|
|
||||||
let init_result: Result<(), Error> = try_block!({
|
let init_result: Result<(), Error> = try_block!({
|
||||||
|
@ -32,10 +32,9 @@ use proxmox_backup::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use pbs_buildcfg::configdir;
|
||||||
|
|
||||||
use proxmox_backup::api2::types::Authid;
|
use proxmox_backup::api2::types::Authid;
|
||||||
use proxmox_backup::configdir;
|
|
||||||
use proxmox_backup::buildcfg;
|
|
||||||
use proxmox_backup::server;
|
use proxmox_backup::server;
|
||||||
use proxmox_backup::auth_helpers::*;
|
use proxmox_backup::auth_helpers::*;
|
||||||
use proxmox_backup::tools::{
|
use proxmox_backup::tools::{
|
||||||
@ -85,7 +84,7 @@ async fn run() -> Result<(), Error> {
|
|||||||
let _ = csrf_secret(); // load with lazy_static
|
let _ = csrf_secret(); // load with lazy_static
|
||||||
|
|
||||||
let mut config = ApiConfig::new(
|
let mut config = ApiConfig::new(
|
||||||
buildcfg::JS_DIR,
|
pbs_buildcfg::JS_DIR,
|
||||||
&proxmox_backup::api2::ROUTER,
|
&proxmox_backup::api2::ROUTER,
|
||||||
RpcEnvironmentType::PUBLIC,
|
RpcEnvironmentType::PUBLIC,
|
||||||
default_api_auth(),
|
default_api_auth(),
|
||||||
@ -100,14 +99,14 @@ async fn run() -> Result<(), Error> {
|
|||||||
config.add_alias("widgettoolkit", "/usr/share/javascript/proxmox-widget-toolkit");
|
config.add_alias("widgettoolkit", "/usr/share/javascript/proxmox-widget-toolkit");
|
||||||
config.add_alias("docs", "/usr/share/doc/proxmox-backup/html");
|
config.add_alias("docs", "/usr/share/doc/proxmox-backup/html");
|
||||||
|
|
||||||
let mut indexpath = PathBuf::from(buildcfg::JS_DIR);
|
let mut indexpath = PathBuf::from(pbs_buildcfg::JS_DIR);
|
||||||
indexpath.push("index.hbs");
|
indexpath.push("index.hbs");
|
||||||
config.register_template("index", &indexpath)?;
|
config.register_template("index", &indexpath)?;
|
||||||
config.register_template("console", "/usr/share/pve-xtermjs/index.html.hbs")?;
|
config.register_template("console", "/usr/share/pve-xtermjs/index.html.hbs")?;
|
||||||
|
|
||||||
let mut commando_sock = server::CommandoSocket::new(server::our_ctrl_sock());
|
let mut commando_sock = server::CommandoSocket::new(server::our_ctrl_sock());
|
||||||
|
|
||||||
config.enable_file_log(buildcfg::API_ACCESS_LOG_FN, &mut commando_sock)?;
|
config.enable_file_log(pbs_buildcfg::API_ACCESS_LOG_FN, &mut commando_sock)?;
|
||||||
|
|
||||||
let rest_server = RestServer::new(config);
|
let rest_server = RestServer::new(config);
|
||||||
|
|
||||||
@ -167,7 +166,7 @@ async fn run() -> Result<(), Error> {
|
|||||||
"proxmox-backup-proxy.service",
|
"proxmox-backup-proxy.service",
|
||||||
);
|
);
|
||||||
|
|
||||||
server::write_pid(buildcfg::PROXMOX_BACKUP_PROXY_PID_FN)?;
|
server::write_pid(pbs_buildcfg::PROXMOX_BACKUP_PROXY_PID_FN)?;
|
||||||
daemon::systemd_notify(daemon::SystemdNotify::Ready)?;
|
daemon::systemd_notify(daemon::SystemdNotify::Ready)?;
|
||||||
|
|
||||||
let init_result: Result<(), Error> = try_block!({
|
let init_result: Result<(), Error> = try_block!({
|
||||||
@ -696,7 +695,7 @@ async fn schedule_task_log_rotate() {
|
|||||||
|
|
||||||
let max_size = 32 * 1024 * 1024 - 1;
|
let max_size = 32 * 1024 * 1024 - 1;
|
||||||
let max_files = 14;
|
let max_files = 14;
|
||||||
let mut logrotate = LogRotate::new(buildcfg::API_ACCESS_LOG_FN, true)
|
let mut logrotate = LogRotate::new(pbs_buildcfg::API_ACCESS_LOG_FN, true)
|
||||||
.ok_or_else(|| format_err!("could not get API access log file names"))?;
|
.ok_or_else(|| format_err!("could not get API access log file names"))?;
|
||||||
|
|
||||||
if logrotate.rotate(max_size, None, Some(max_files))? {
|
if logrotate.rotate(max_size, None, Some(max_files))? {
|
||||||
@ -707,7 +706,7 @@ async fn schedule_task_log_rotate() {
|
|||||||
worker.log("API access log was not rotated".to_string());
|
worker.log("API access log was not rotated".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut logrotate = LogRotate::new(buildcfg::API_AUTH_LOG_FN, true)
|
let mut logrotate = LogRotate::new(pbs_buildcfg::API_AUTH_LOG_FN, true)
|
||||||
.ok_or_else(|| format_err!("could not get API auth log file names"))?;
|
.ok_or_else(|| format_err!("could not get API auth log file names"))?;
|
||||||
|
|
||||||
if logrotate.rotate(max_size, None, Some(max_files))? {
|
if logrotate.rotate(max_size, None, Some(max_files))? {
|
||||||
@ -739,7 +738,7 @@ async fn command_reopen_logfiles() -> Result<(), Error> {
|
|||||||
let sock = server::our_ctrl_sock();
|
let sock = server::our_ctrl_sock();
|
||||||
let f1 = server::send_command(sock, "{\"command\":\"api-access-log-reopen\"}\n");
|
let f1 = server::send_command(sock, "{\"command\":\"api-access-log-reopen\"}\n");
|
||||||
|
|
||||||
let pid = server::read_pid(buildcfg::PROXMOX_BACKUP_API_PID_FN)?;
|
let pid = server::read_pid(pbs_buildcfg::PROXMOX_BACKUP_API_PID_FN)?;
|
||||||
let sock = server::ctrl_sock_from_pid(pid);
|
let sock = server::ctrl_sock_from_pid(pid);
|
||||||
let f2 = server::send_command(sock, "{\"command\":\"api-access-log-reopen\"}\n");
|
let f2 = server::send_command(sock, "{\"command\":\"api-access-log-reopen\"}\n");
|
||||||
|
|
||||||
|
@ -10,10 +10,11 @@ use proxmox::{
|
|||||||
tools::fs::file_get_json,
|
tools::fs::file_get_json,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use pbs_buildcfg;
|
||||||
|
|
||||||
use proxmox_backup::api2::access::user::UserWithTokens;
|
use proxmox_backup::api2::access::user::UserWithTokens;
|
||||||
use proxmox_backup::api2::types::*;
|
use proxmox_backup::api2::types::*;
|
||||||
use proxmox_backup::backup::BackupDir;
|
use proxmox_backup::backup::BackupDir;
|
||||||
use proxmox_backup::buildcfg;
|
|
||||||
use proxmox_backup::client::*;
|
use proxmox_backup::client::*;
|
||||||
use proxmox_backup::tools;
|
use proxmox_backup::tools;
|
||||||
|
|
||||||
@ -379,7 +380,7 @@ pub fn place_xdg_file(
|
|||||||
/// "www-data", so we use a custom one in /run/proxmox-backup/<uid> instead.
|
/// "www-data", so we use a custom one in /run/proxmox-backup/<uid> instead.
|
||||||
pub fn get_user_run_dir() -> Result<std::path::PathBuf, Error> {
|
pub fn get_user_run_dir() -> Result<std::path::PathBuf, Error> {
|
||||||
let uid = nix::unistd::Uid::current();
|
let uid = nix::unistd::Uid::current();
|
||||||
let mut path: std::path::PathBuf = buildcfg::PROXMOX_BACKUP_RUN_DIR.into();
|
let mut path: std::path::PathBuf = pbs_buildcfg::PROXMOX_BACKUP_RUN_DIR.into();
|
||||||
path.push(uid.to_string());
|
path.push(uid.to_string());
|
||||||
tools::create_run_dir()?;
|
tools::create_run_dir()?;
|
||||||
std::fs::create_dir_all(&path)?;
|
std::fs::create_dir_all(&path)?;
|
||||||
|
@ -18,7 +18,7 @@ use proxmox::tools::{
|
|||||||
|
|
||||||
use proxmox_backup::backup::backup_user;
|
use proxmox_backup::backup::backup_user;
|
||||||
use proxmox_backup::client::{VsockClient, DEFAULT_VSOCK_PORT};
|
use proxmox_backup::client::{VsockClient, DEFAULT_VSOCK_PORT};
|
||||||
use proxmox_backup::{buildcfg, tools};
|
use proxmox_backup::tools;
|
||||||
|
|
||||||
use super::SnapRestoreDetails;
|
use super::SnapRestoreDetails;
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ const PBS_VM_NAME: &str = "pbs-restore-vm";
|
|||||||
const MAX_CID_TRIES: u64 = 32;
|
const MAX_CID_TRIES: u64 = 32;
|
||||||
|
|
||||||
fn create_restore_log_dir() -> Result<String, Error> {
|
fn create_restore_log_dir() -> Result<String, Error> {
|
||||||
let logpath = format!("{}/file-restore", buildcfg::PROXMOX_BACKUP_LOG_DIR);
|
let logpath = format!("{}/file-restore", pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR);
|
||||||
|
|
||||||
proxmox::try_block!({
|
proxmox::try_block!({
|
||||||
let backup_user = backup_user()?;
|
let backup_user = backup_user()?;
|
||||||
@ -38,7 +38,7 @@ fn create_restore_log_dir() -> Result<String, Error> {
|
|||||||
.owner(nix::unistd::ROOT)
|
.owner(nix::unistd::ROOT)
|
||||||
.group(nix::unistd::Gid::from_raw(0));
|
.group(nix::unistd::Gid::from_raw(0));
|
||||||
|
|
||||||
create_path(buildcfg::PROXMOX_BACKUP_LOG_DIR, None, Some(opts))?;
|
create_path(pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR, None, Some(opts))?;
|
||||||
create_path(&logpath, None, Some(opts_root))?;
|
create_path(&logpath, None, Some(opts_root))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
@ -48,11 +48,11 @@ fn create_restore_log_dir() -> Result<String, Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn validate_img_existance(debug: bool) -> Result<(), Error> {
|
fn validate_img_existance(debug: bool) -> Result<(), Error> {
|
||||||
let kernel = PathBuf::from(buildcfg::PROXMOX_BACKUP_KERNEL_FN);
|
let kernel = PathBuf::from(pbs_buildcfg::PROXMOX_BACKUP_KERNEL_FN);
|
||||||
let initramfs = PathBuf::from(if debug {
|
let initramfs = PathBuf::from(if debug {
|
||||||
buildcfg::PROXMOX_BACKUP_INITRAMFS_DBG_FN
|
pbs_buildcfg::PROXMOX_BACKUP_INITRAMFS_DBG_FN
|
||||||
} else {
|
} else {
|
||||||
buildcfg::PROXMOX_BACKUP_INITRAMFS_FN
|
pbs_buildcfg::PROXMOX_BACKUP_INITRAMFS_FN
|
||||||
});
|
});
|
||||||
if !kernel.exists() || !initramfs.exists() {
|
if !kernel.exists() || !initramfs.exists() {
|
||||||
bail!("cannot run file-restore VM: package 'proxmox-backup-restore-image' is not (correctly) installed");
|
bail!("cannot run file-restore VM: package 'proxmox-backup-restore-image' is not (correctly) installed");
|
||||||
@ -93,9 +93,9 @@ async fn create_temp_initramfs(ticket: &str, debug: bool) -> Result<(Fd, String)
|
|||||||
tools::fd_change_cloexec(tmp_fd.0, false)?;
|
tools::fd_change_cloexec(tmp_fd.0, false)?;
|
||||||
|
|
||||||
let initramfs = if debug {
|
let initramfs = if debug {
|
||||||
buildcfg::PROXMOX_BACKUP_INITRAMFS_DBG_FN
|
pbs_buildcfg::PROXMOX_BACKUP_INITRAMFS_DBG_FN
|
||||||
} else {
|
} else {
|
||||||
buildcfg::PROXMOX_BACKUP_INITRAMFS_FN
|
pbs_buildcfg::PROXMOX_BACKUP_INITRAMFS_FN
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut f = File::from_std(unsafe { std::fs::File::from_raw_fd(tmp_fd.0) });
|
let mut f = File::from_std(unsafe { std::fs::File::from_raw_fd(tmp_fd.0) });
|
||||||
@ -184,7 +184,7 @@ pub async fn start_vm(
|
|||||||
"none",
|
"none",
|
||||||
"-enable-kvm",
|
"-enable-kvm",
|
||||||
"-kernel",
|
"-kernel",
|
||||||
buildcfg::PROXMOX_BACKUP_KERNEL_FN,
|
pbs_buildcfg::PROXMOX_BACKUP_KERNEL_FN,
|
||||||
"-initrd",
|
"-initrd",
|
||||||
&ramfs_path,
|
&ramfs_path,
|
||||||
"-append",
|
"-append",
|
||||||
|
@ -13,7 +13,7 @@ use openssl::pkey::PKey;
|
|||||||
use proxmox::tools::fs::{CreateOptions, replace_file};
|
use proxmox::tools::fs::{CreateOptions, replace_file};
|
||||||
use proxmox::try_block;
|
use proxmox::try_block;
|
||||||
|
|
||||||
use crate::buildcfg;
|
use pbs_buildcfg::{self, configdir};
|
||||||
|
|
||||||
pub mod acl;
|
pub mod acl;
|
||||||
pub mod acme;
|
pub mod acme;
|
||||||
@ -39,7 +39,7 @@ pub mod domains;
|
|||||||
/// * owned by 'backup' user/group
|
/// * owned by 'backup' user/group
|
||||||
/// * nobody else can read (mode 0700)
|
/// * nobody else can read (mode 0700)
|
||||||
pub fn check_configdir_permissions() -> Result<(), Error> {
|
pub fn check_configdir_permissions() -> Result<(), Error> {
|
||||||
let cfgdir = buildcfg::CONFIGDIR;
|
let cfgdir = pbs_buildcfg::CONFIGDIR;
|
||||||
|
|
||||||
let backup_user = crate::backup::backup_user()?;
|
let backup_user = crate::backup::backup_user()?;
|
||||||
let backup_uid = backup_user.uid.as_raw();
|
let backup_uid = backup_user.uid.as_raw();
|
||||||
@ -71,7 +71,7 @@ pub fn check_configdir_permissions() -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_configdir() -> Result<(), Error> {
|
pub fn create_configdir() -> Result<(), Error> {
|
||||||
let cfgdir = buildcfg::CONFIGDIR;
|
let cfgdir = pbs_buildcfg::CONFIGDIR;
|
||||||
|
|
||||||
match nix::unistd::mkdir(cfgdir, Mode::from_bits_truncate(0o700)) {
|
match nix::unistd::mkdir(cfgdir, Mode::from_bits_truncate(0o700)) {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
|
@ -15,8 +15,8 @@ use crate::api2::types::{
|
|||||||
};
|
};
|
||||||
use crate::tools::ControlFlow;
|
use crate::tools::ControlFlow;
|
||||||
|
|
||||||
pub(crate) const ACME_DIR: &str = configdir!("/acme");
|
pub(crate) const ACME_DIR: &str = pbs_buildcfg::configdir!("/acme");
|
||||||
pub(crate) const ACME_ACCOUNT_DIR: &str = configdir!("/acme/accounts");
|
pub(crate) const ACME_ACCOUNT_DIR: &str = pbs_buildcfg::configdir!("/acme/accounts");
|
||||||
|
|
||||||
pub(crate) const ACME_DNS_SCHEMA_FN: &str = "/usr/share/proxmox-acme/dns-challenge-schema.json";
|
pub(crate) const ACME_DNS_SCHEMA_FN: &str = "/usr/share/proxmox-acme/dns-challenge-schema.json";
|
||||||
|
|
||||||
|
@ -140,8 +140,8 @@ fn init() -> SectionConfig {
|
|||||||
config
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
const ACME_PLUGIN_CFG_FILENAME: &str = configdir!("/acme/plugins.cfg");
|
const ACME_PLUGIN_CFG_FILENAME: &str = pbs_buildcfg::configdir!("/acme/plugins.cfg");
|
||||||
const ACME_PLUGIN_CFG_LOCKFILE: &str = configdir!("/acme/.plugins.lck");
|
const ACME_PLUGIN_CFG_LOCKFILE: &str = pbs_buildcfg::configdir!("/acme/.plugins.lck");
|
||||||
const LOCK_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10);
|
const LOCK_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(10);
|
||||||
|
|
||||||
pub fn lock() -> Result<std::fs::File, Error> {
|
pub fn lock() -> Result<std::fs::File, Error> {
|
||||||
|
@ -12,6 +12,8 @@ use proxmox::tools::fs::{replace_file, CreateOptions};
|
|||||||
|
|
||||||
use proxmox_http::ProxyConfig;
|
use proxmox_http::ProxyConfig;
|
||||||
|
|
||||||
|
use pbs_buildcfg::configdir;
|
||||||
|
|
||||||
use crate::acme::AcmeClient;
|
use crate::acme::AcmeClient;
|
||||||
use crate::api2::types::{
|
use crate::api2::types::{
|
||||||
AcmeAccountName, AcmeDomain, ACME_DOMAIN_PROPERTY_SCHEMA, HTTP_PROXY_SCHEMA,
|
AcmeAccountName, AcmeDomain, ACME_DOMAIN_PROPERTY_SCHEMA, HTTP_PROXY_SCHEMA,
|
||||||
|
@ -26,6 +26,8 @@ use proxmox::tools::tfa::u2f;
|
|||||||
use proxmox::tools::uuid::Uuid;
|
use proxmox::tools::uuid::Uuid;
|
||||||
use proxmox::tools::AsHex;
|
use proxmox::tools::AsHex;
|
||||||
|
|
||||||
|
use pbs_buildcfg::configdir;
|
||||||
|
|
||||||
use crate::api2::types::Userid;
|
use crate::api2::types::Userid;
|
||||||
|
|
||||||
/// Mapping of userid to TFA entry.
|
/// Mapping of userid to TFA entry.
|
||||||
@ -35,7 +37,7 @@ const CONF_FILE: &str = configdir!("/tfa.json");
|
|||||||
const LOCK_FILE: &str = configdir!("/tfa.json.lock");
|
const LOCK_FILE: &str = configdir!("/tfa.json.lock");
|
||||||
const LOCK_TIMEOUT: Duration = Duration::from_secs(5);
|
const LOCK_TIMEOUT: Duration = Duration::from_secs(5);
|
||||||
|
|
||||||
const CHALLENGE_DATA_PATH: &str = rundir!("/tfa/challenges");
|
const CHALLENGE_DATA_PATH: &str = pbs_buildcfg::rundir!("/tfa/challenges");
|
||||||
|
|
||||||
/// U2F registration challenges time out after 2 minutes.
|
/// U2F registration challenges time out after 2 minutes.
|
||||||
const CHALLENGE_TIMEOUT: i64 = 2 * 60;
|
const CHALLENGE_TIMEOUT: i64 = 2 * 60;
|
||||||
|
@ -10,8 +10,8 @@ use proxmox::tools::fs::{open_file_locked, CreateOptions};
|
|||||||
use crate::api2::types::Authid;
|
use crate::api2::types::Authid;
|
||||||
use crate::auth;
|
use crate::auth;
|
||||||
|
|
||||||
const LOCK_FILE: &str = configdir!("/token.shadow.lock");
|
const LOCK_FILE: &str = pbs_buildcfg::configdir!("/token.shadow.lock");
|
||||||
const CONF_FILE: &str = configdir!("/token.shadow");
|
const CONF_FILE: &str = pbs_buildcfg::configdir!("/token.shadow");
|
||||||
const LOCK_TIMEOUT: Duration = Duration::from_secs(5);
|
const LOCK_TIMEOUT: Duration = Duration::from_secs(5);
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
|
@ -5,9 +5,6 @@
|
|||||||
|
|
||||||
pub mod task;
|
pub mod task;
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
pub mod buildcfg;
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod tools;
|
pub mod tools;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ use serde_json::Value;
|
|||||||
|
|
||||||
use proxmox::sys::linux::procfs::PidStat;
|
use proxmox::sys::linux::procfs::PidStat;
|
||||||
|
|
||||||
use crate::buildcfg;
|
use pbs_buildcfg;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref PID: i32 = unsafe { libc::getpid() };
|
static ref PID: i32 = unsafe { libc::getpid() };
|
||||||
@ -39,7 +39,7 @@ pub fn read_pid(pid_fn: &str) -> Result<i32, Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn ctrl_sock_from_pid(pid: i32) -> String {
|
pub fn ctrl_sock_from_pid(pid: i32) -> String {
|
||||||
format!("\0{}/control-{}.sock", buildcfg::PROXMOX_BACKUP_RUN_DIR, pid)
|
format!("\0{}/control-{}.sock", pbs_buildcfg::PROXMOX_BACKUP_RUN_DIR, pid)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn our_ctrl_sock() -> String {
|
pub fn our_ctrl_sock() -> String {
|
||||||
@ -94,7 +94,7 @@ pub mod ticket;
|
|||||||
pub mod auth;
|
pub mod auth;
|
||||||
|
|
||||||
pub(crate) async fn reload_proxy_certificate() -> Result<(), Error> {
|
pub(crate) async fn reload_proxy_certificate() -> Result<(), Error> {
|
||||||
let proxy_pid = crate::server::read_pid(buildcfg::PROXMOX_BACKUP_PROXY_PID_FN)?;
|
let proxy_pid = crate::server::read_pid(pbs_buildcfg::PROXMOX_BACKUP_PROXY_PID_FN)?;
|
||||||
let sock = crate::server::ctrl_sock_from_pid(proxy_pid);
|
let sock = crate::server::ctrl_sock_from_pid(proxy_pid);
|
||||||
let _: Value = crate::server::send_raw_command(sock, "{\"command\":\"reload-certificate\"}\n")
|
let _: Value = crate::server::send_raw_command(sock, "{\"command\":\"reload-certificate\"}\n")
|
||||||
.await?;
|
.await?;
|
||||||
@ -102,7 +102,7 @@ pub(crate) async fn reload_proxy_certificate() -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn notify_datastore_removed() -> Result<(), Error> {
|
pub(crate) async fn notify_datastore_removed() -> Result<(), Error> {
|
||||||
let proxy_pid = crate::server::read_pid(buildcfg::PROXMOX_BACKUP_PROXY_PID_FN)?;
|
let proxy_pid = crate::server::read_pid(pbs_buildcfg::PROXMOX_BACKUP_PROXY_PID_FN)?;
|
||||||
let sock = crate::server::ctrl_sock_from_pid(proxy_pid);
|
let sock = crate::server::ctrl_sock_from_pid(proxy_pid);
|
||||||
let _: Value = crate::server::send_raw_command(sock, "{\"command\":\"datastore-removed\"}\n")
|
let _: Value = crate::server::send_raw_command(sock, "{\"command\":\"datastore-removed\"}\n")
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -201,7 +201,7 @@ pub fn auth_logger() -> Result<FileLogger, Error> {
|
|||||||
owned_by_backup: true,
|
owned_by_backup: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
FileLogger::new(crate::buildcfg::API_AUTH_LOG_FN, logger_options)
|
FileLogger::new(pbs_buildcfg::API_AUTH_LOG_FN, logger_options)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_proxied_peer(headers: &HeaderMap) -> Option<std::net::SocketAddr> {
|
fn get_proxied_peer(headers: &HeaderMap) -> Option<std::net::SocketAddr> {
|
||||||
|
@ -18,14 +18,15 @@ use proxmox::tools::fs::{create_path, open_file_locked, replace_file, CreateOpti
|
|||||||
|
|
||||||
use super::UPID;
|
use super::UPID;
|
||||||
|
|
||||||
use crate::buildcfg;
|
use pbs_buildcfg;
|
||||||
|
|
||||||
use crate::server;
|
use crate::server;
|
||||||
use crate::tools::logrotate::{LogRotate, LogRotateFiles};
|
use crate::tools::logrotate::{LogRotate, LogRotateFiles};
|
||||||
use crate::tools::{FileLogger, FileLogOptions};
|
use crate::tools::{FileLogger, FileLogOptions};
|
||||||
use crate::api2::types::{Authid, TaskStateType};
|
use crate::api2::types::{Authid, TaskStateType};
|
||||||
|
|
||||||
macro_rules! taskdir {
|
macro_rules! taskdir {
|
||||||
($subdir:expr) => (concat!(PROXMOX_BACKUP_LOG_DIR_M!(), "/tasks", $subdir))
|
($subdir:expr) => (concat!(pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!(), "/tasks", $subdir))
|
||||||
}
|
}
|
||||||
pub const PROXMOX_BACKUP_TASK_DIR: &str = taskdir!("/");
|
pub const PROXMOX_BACKUP_TASK_DIR: &str = taskdir!("/");
|
||||||
pub const PROXMOX_BACKUP_TASK_LOCK_FN: &str = taskdir!("/.active.lock");
|
pub const PROXMOX_BACKUP_TASK_LOCK_FN: &str = taskdir!("/.active.lock");
|
||||||
@ -162,9 +163,9 @@ pub fn create_task_log_dirs() -> Result<(), Error> {
|
|||||||
.owner(backup_user.uid)
|
.owner(backup_user.uid)
|
||||||
.group(backup_user.gid);
|
.group(backup_user.gid);
|
||||||
|
|
||||||
create_path(buildcfg::PROXMOX_BACKUP_LOG_DIR, None, Some(opts.clone()))?;
|
create_path(pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR, None, Some(opts.clone()))?;
|
||||||
create_path(PROXMOX_BACKUP_TASK_DIR, None, Some(opts.clone()))?;
|
create_path(PROXMOX_BACKUP_TASK_DIR, None, Some(opts.clone()))?;
|
||||||
create_path(buildcfg::PROXMOX_BACKUP_RUN_DIR, None, Some(opts))?;
|
create_path(pbs_buildcfg::PROXMOX_BACKUP_RUN_DIR, None, Some(opts))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}).map_err(|err: Error| format_err!("unable to create task log dir - {}", err))?;
|
}).map_err(|err: Error| format_err!("unable to create task log dir - {}", err))?;
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@ use proxmox::tools::fs::{
|
|||||||
CreateOptions,
|
CreateOptions,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use pbs_buildcfg::PROXMOX_BACKUP_RUN_DIR_M;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test;
|
mod test;
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ pub fn create_run_dir() -> Result<(), Error> {
|
|||||||
let opts = CreateOptions::new()
|
let opts = CreateOptions::new()
|
||||||
.owner(backup_user.uid)
|
.owner(backup_user.uid)
|
||||||
.group(backup_user.gid);
|
.group(backup_user.gid);
|
||||||
let _: bool = create_path(PROXMOX_BACKUP_RUN_DIR_M!(), None, Some(opts))?;
|
let _: bool = create_path(pbs_buildcfg::PROXMOX_BACKUP_RUN_DIR_M!(), None, Some(opts))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ use openssl::x509::{X509, GeneralName};
|
|||||||
use openssl::stack::Stack;
|
use openssl::stack::Stack;
|
||||||
use openssl::pkey::{Public, PKey};
|
use openssl::pkey::{Public, PKey};
|
||||||
|
|
||||||
use crate::configdir;
|
use pbs_buildcfg::configdir;
|
||||||
|
|
||||||
// C type:
|
// C type:
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
|
@ -31,7 +31,7 @@ struct Head {
|
|||||||
|
|
||||||
static INSTANCE: OnceCell<Arc<Memcom>> = OnceCell::new();
|
static INSTANCE: OnceCell<Arc<Memcom>> = OnceCell::new();
|
||||||
|
|
||||||
const MEMCOM_FILE_PATH: &str = rundir!("/proxmox-backup-memcom");
|
const MEMCOM_FILE_PATH: &str = pbs_buildcfg::rundir!("/proxmox-backup-memcom");
|
||||||
|
|
||||||
impl Memcom {
|
impl Memcom {
|
||||||
/// Open the memory based communication channel singleton.
|
/// Open the memory based communication channel singleton.
|
||||||
|
Loading…
Reference in New Issue
Block a user