Merge branch 'master' of ssh://proxdev.maurer-it.com/rust/proxmox-backup
This commit is contained in:
@ -898,7 +898,7 @@ async fn create_backup(
|
||||
}
|
||||
}
|
||||
|
||||
let backup_time = backup_time_opt.unwrap_or_else(|| epoch_i64());
|
||||
let backup_time = backup_time_opt.unwrap_or_else(epoch_i64);
|
||||
|
||||
let client = connect(&repo)?;
|
||||
record_repository(&repo);
|
||||
@ -917,7 +917,7 @@ async fn create_backup(
|
||||
let (key, created, fingerprint) = decrypt_key(&key, &key::get_encryption_key_password)?;
|
||||
println!("Encryption key fingerprint: {}", fingerprint);
|
||||
|
||||
let crypt_config = CryptConfig::new(key.clone())?;
|
||||
let crypt_config = CryptConfig::new(key)?;
|
||||
|
||||
match key::find_master_pubkey()? {
|
||||
Some(ref path) if path.exists() => {
|
||||
@ -1464,7 +1464,7 @@ async fn prune_async(mut param: Value) -> Result<Value, Error> {
|
||||
if quiet {
|
||||
let list: Vec<Value> = data.as_array().unwrap().iter().filter(|item| {
|
||||
item["keep"].as_bool() == Some(false)
|
||||
}).map(|v| v.clone()).collect();
|
||||
}).cloned().collect();
|
||||
data = list.into();
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ use std::os::unix::io::AsRawFd;
|
||||
|
||||
use anyhow::{bail, format_err, Error};
|
||||
use futures::*;
|
||||
use hyper;
|
||||
|
||||
use openssl::ssl::{SslMethod, SslAcceptor, SslFiletype};
|
||||
use tokio_stream::wrappers::ReceiverStream;
|
||||
|
||||
@ -218,10 +218,8 @@ fn accept_connections(
|
||||
|
||||
match result {
|
||||
Ok(Ok(())) => {
|
||||
if let Err(_) = sender.send(Ok(stream)).await {
|
||||
if debug {
|
||||
eprintln!("detect closed connection channel");
|
||||
}
|
||||
if sender.send(Ok(stream)).await.is_err() && debug {
|
||||
eprintln!("detect closed connection channel");
|
||||
}
|
||||
}
|
||||
Ok(Err(err)) => {
|
||||
@ -583,16 +581,16 @@ async fn schedule_task_log_rotate() {
|
||||
false,
|
||||
move |worker| {
|
||||
job.start(&worker.upid().to_string())?;
|
||||
worker.log(format!("starting task log rotation"));
|
||||
worker.log("starting task log rotation".to_string());
|
||||
|
||||
let result = try_block!({
|
||||
let max_size = 512 * 1024 - 1; // an entry has ~ 100b, so > 5000 entries/file
|
||||
let max_files = 20; // times twenty files gives > 100000 task entries
|
||||
let has_rotated = rotate_task_log_archive(max_size, true, Some(max_files))?;
|
||||
if has_rotated {
|
||||
worker.log(format!("task log archive was rotated"));
|
||||
worker.log("task log archive was rotated".to_string());
|
||||
} else {
|
||||
worker.log(format!("task log archive was not rotated"));
|
||||
worker.log("task log archive was not rotated".to_string());
|
||||
}
|
||||
|
||||
let max_size = 32 * 1024 * 1024 - 1;
|
||||
@ -603,18 +601,18 @@ async fn schedule_task_log_rotate() {
|
||||
if logrotate.rotate(max_size, None, Some(max_files))? {
|
||||
println!("rotated access log, telling daemons to re-open log file");
|
||||
proxmox_backup::tools::runtime::block_on(command_reopen_logfiles())?;
|
||||
worker.log(format!("API access log was rotated"));
|
||||
worker.log("API access log was rotated".to_string());
|
||||
} else {
|
||||
worker.log(format!("API access log was not rotated"));
|
||||
worker.log("API access log was not rotated".to_string());
|
||||
}
|
||||
|
||||
let mut logrotate = LogRotate::new(buildcfg::API_AUTH_LOG_FN, true)
|
||||
.ok_or_else(|| format_err!("could not get API auth log file names"))?;
|
||||
|
||||
if logrotate.rotate(max_size, None, Some(max_files))? {
|
||||
worker.log(format!("API authentication log was rotated"));
|
||||
worker.log("API authentication log was rotated".to_string());
|
||||
} else {
|
||||
worker.log(format!("API authentication log was not rotated"));
|
||||
worker.log("API authentication log was not rotated".to_string());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -751,7 +749,7 @@ async fn generate_host_stats(save: bool) {
|
||||
match datastore::config() {
|
||||
Ok((config, _)) => {
|
||||
let datastore_list: Vec<datastore::DataStoreConfig> =
|
||||
config.convert_to_typed_array("datastore").unwrap_or(Vec::new());
|
||||
config.convert_to_typed_array("datastore").unwrap_or_default();
|
||||
|
||||
for config in datastore_list {
|
||||
|
||||
|
@ -601,16 +601,14 @@ fn debug_scan(param: Value) -> Result<(), Error> {
|
||||
Ok(header) => {
|
||||
if header.magic != PROXMOX_BACKUP_CONTENT_HEADER_MAGIC_1_0 {
|
||||
println!("got MediaContentHeader with wrong magic: {:?}", header.magic);
|
||||
} else if let Some(name) = PROXMOX_BACKUP_CONTENT_NAME.get(&header.content_magic) {
|
||||
println!("got content header: {}", name);
|
||||
println!(" uuid: {}", header.content_uuid());
|
||||
println!(" ctime: {}", strftime_local("%c", header.ctime)?);
|
||||
println!(" hsize: {}", HumanByte::from(header.size as usize));
|
||||
println!(" part: {}", header.part_number);
|
||||
} else {
|
||||
if let Some(name) = PROXMOX_BACKUP_CONTENT_NAME.get(&header.content_magic) {
|
||||
println!("got content header: {}", name);
|
||||
println!(" uuid: {}", header.content_uuid());
|
||||
println!(" ctime: {}", strftime_local("%c", header.ctime)?);
|
||||
println!(" hsize: {}", HumanByte::from(header.size as usize));
|
||||
println!(" part: {}", header.part_number);
|
||||
} else {
|
||||
println!("got unknown content header: {:?}", header.content_magic);
|
||||
}
|
||||
println!("got unknown content header: {:?}", header.content_magic);
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
|
@ -293,7 +293,7 @@ fn test_crypt_speed(
|
||||
let speed = (bytes as f64)/start_time.elapsed().as_secs_f64();
|
||||
benchmark_result.sha256.speed = Some(speed);
|
||||
|
||||
eprintln!("SHA256 speed: {:.2} MB/s", speed/1_000_000_.0);
|
||||
eprintln!("SHA256 speed: {:.2} MB/s", speed/1_000_000.0);
|
||||
|
||||
|
||||
let start_time = std::time::Instant::now();
|
||||
@ -308,7 +308,7 @@ fn test_crypt_speed(
|
||||
let speed = (bytes as f64)/start_time.elapsed().as_secs_f64();
|
||||
benchmark_result.compress.speed = Some(speed);
|
||||
|
||||
eprintln!("Compression speed: {:.2} MB/s", speed/1_000_000_.0);
|
||||
eprintln!("Compression speed: {:.2} MB/s", speed/1_000_000.0);
|
||||
|
||||
|
||||
let start_time = std::time::Instant::now();
|
||||
@ -328,7 +328,7 @@ fn test_crypt_speed(
|
||||
let speed = (bytes as f64)/start_time.elapsed().as_secs_f64();
|
||||
benchmark_result.decompress.speed = Some(speed);
|
||||
|
||||
eprintln!("Decompress speed: {:.2} MB/s", speed/1_000_000_.0);
|
||||
eprintln!("Decompress speed: {:.2} MB/s", speed/1_000_000.0);
|
||||
|
||||
|
||||
let start_time = std::time::Instant::now();
|
||||
@ -343,7 +343,7 @@ fn test_crypt_speed(
|
||||
let speed = (bytes as f64)/start_time.elapsed().as_secs_f64();
|
||||
benchmark_result.aes256_gcm.speed = Some(speed);
|
||||
|
||||
eprintln!("AES256/GCM speed: {:.2} MB/s", speed/1_000_000_.0);
|
||||
eprintln!("AES256/GCM speed: {:.2} MB/s", speed/1_000_000.0);
|
||||
|
||||
|
||||
let start_time = std::time::Instant::now();
|
||||
@ -361,7 +361,7 @@ fn test_crypt_speed(
|
||||
let speed = (bytes as f64)/start_time.elapsed().as_secs_f64();
|
||||
benchmark_result.verify.speed = Some(speed);
|
||||
|
||||
eprintln!("Verify speed: {:.2} MB/s", speed/1_000_000_.0);
|
||||
eprintln!("Verify speed: {:.2} MB/s", speed/1_000_000.0);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -189,12 +189,12 @@ async fn mount_do(param: Value, pipe: Option<Fd>) -> Result<Value, Error> {
|
||||
};
|
||||
|
||||
let server_archive_name = if archive_name.ends_with(".pxar") {
|
||||
if let None = target {
|
||||
if target.is_none() {
|
||||
bail!("use the 'mount' command to mount pxar archives");
|
||||
}
|
||||
format!("{}.didx", archive_name)
|
||||
} else if archive_name.ends_with(".img") {
|
||||
if let Some(_) = target {
|
||||
if target.is_some() {
|
||||
bail!("use the 'map' command to map drive images");
|
||||
}
|
||||
format!("{}.fidx", archive_name)
|
||||
|
@ -239,7 +239,7 @@ async fn get_status(
|
||||
}
|
||||
let text = value.as_str().unwrap().to_string();
|
||||
if text.is_empty() {
|
||||
return Ok(String::from("--FULL--"));
|
||||
Ok(String::from("--FULL--"))
|
||||
} else {
|
||||
Ok(text)
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ fn get_tape_handle(param: &Value) -> Result<LinuxTapeHandle, Error> {
|
||||
let file = unsafe { File::from_raw_fd(fd) };
|
||||
check_tape_is_linux_tape_device(&file)?;
|
||||
LinuxTapeHandle::new(file)
|
||||
} else if let Some(name) = std::env::var("PROXMOX_TAPE_DRIVE").ok() {
|
||||
} else if let Ok(name) = std::env::var("PROXMOX_TAPE_DRIVE") {
|
||||
let (config, _digest) = config::drive::config()?;
|
||||
let drive: LinuxTapeDrive = config.lookup("linux", &name)?;
|
||||
eprintln!("using device {}", drive.path);
|
||||
@ -292,13 +292,11 @@ fn main() -> Result<(), Error> {
|
||||
bail!("this program needs to be run with setuid root");
|
||||
}
|
||||
|
||||
if !running_uid.is_root() {
|
||||
if running_uid != backup_uid || running_gid != backup_gid {
|
||||
bail!(
|
||||
"Not running as backup user or group (got uid {} gid {})",
|
||||
running_uid, running_gid,
|
||||
);
|
||||
}
|
||||
if !running_uid.is_root() && (running_uid != backup_uid || running_gid != backup_gid) {
|
||||
bail!(
|
||||
"Not running as backup user or group (got uid {} gid {})",
|
||||
running_uid, running_gid,
|
||||
);
|
||||
}
|
||||
|
||||
let cmd_def = CliCommandMap::new()
|
||||
|
Reference in New Issue
Block a user