feat: v0.6.50
This commit is contained in:
6
Cargo.lock
generated
6
Cargo.lock
generated
@@ -1556,9 +1556,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust_util"
|
name = "rust_util"
|
||||||
version = "0.6.49"
|
version = "0.6.50"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "753ff5a55fa0dcb75b1249a306b037537cfe5b9ff84f685c9a85d17974453a8a"
|
checksum = "01736dfb1c97fec6b874d4939aac6db3b748c61cfd62183c7b80c4f1db003635"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -1989,7 +1989,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tiny-encrypt"
|
name = "tiny-encrypt"
|
||||||
version = "1.9.9"
|
version = "1.9.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes-gcm-stream",
|
"aes-gcm-stream",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "tiny-encrypt"
|
name = "tiny-encrypt"
|
||||||
version = "1.9.9"
|
version = "1.9.10"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
description = "A simple and tiny file encrypt tool"
|
description = "A simple and tiny file encrypt tool"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use std::{env, fs};
|
use std::fs;
|
||||||
use std::env::temp_dir;
|
use std::env::temp_dir;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
@@ -16,6 +16,7 @@ use rust_util::{
|
|||||||
debugging, failure, iff, information, opt_result, opt_value_result, println_ex, simple_error, success,
|
debugging, failure, iff, information, opt_result, opt_value_result, println_ex, simple_error, success,
|
||||||
util_cmd, util_msg, util_size, util_time, warning, XResult,
|
util_cmd, util_msg, util_size, util_time, warning, XResult,
|
||||||
};
|
};
|
||||||
|
use rust_util::util_env as rust_util_env;
|
||||||
use rust_util::util_time::UnixEpochTime;
|
use rust_util::util_time::UnixEpochTime;
|
||||||
use x509_parser::prelude::FromDer;
|
use x509_parser::prelude::FromDer;
|
||||||
use x509_parser::x509::SubjectPublicKeyInfo;
|
use x509_parser::x509::SubjectPublicKeyInfo;
|
||||||
@@ -327,12 +328,12 @@ fn run_file_editor_and_wait_content(editor: &str, temp_file: &PathBuf, secure_ed
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_file_editor() -> (bool, String) {
|
fn get_file_editor() -> (bool, String) {
|
||||||
if let Ok(secure_editor) = env::var("SECURE_EDITOR") {
|
if let Some(secure_editor) = rust_util_env::env_var("SECURE_EDITOR") {
|
||||||
// cmd <file-name> "aes-256-gcm" <key-in-hex> <nonce-in-hex>
|
// cmd <file-name> "aes-256-gcm" <key-in-hex> <nonce-in-hex>
|
||||||
information!("Found secure editor: {}", &secure_editor);
|
information!("Found secure editor: {}", &secure_editor);
|
||||||
return (true, secure_editor);
|
return (true, secure_editor);
|
||||||
}
|
}
|
||||||
match env::var("EDITOR").ok() {
|
match rust_util_env::env_var("EDITOR") {
|
||||||
Some(editor) => (false, editor),
|
Some(editor) => (false, editor),
|
||||||
None => {
|
None => {
|
||||||
warning!("EDITOR is not assigned, use default editor vi");
|
warning!("EDITOR is not assigned, use default editor vi");
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ use std::collections::HashMap;
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::{env, fs};
|
use std::{env, fs};
|
||||||
|
use rust_util::util_env as rust_util_env;
|
||||||
use rust_util::util_file::resolve_file_path;
|
use rust_util::util_file::resolve_file_path;
|
||||||
use rust_util::{debugging, opt_result, simple_error, warning, XResult};
|
use rust_util::{debugging, opt_result, simple_error, warning, XResult};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::consts::{ENV_TINY_ENC_CONFIG_FILE, TINY_ENC_CONFIG_FILE, TINY_ENC_CONFIG_FILE_2, TINY_ENC_CONFIG_FILE_3, TINY_ENC_FILE_EXT};
|
use crate::consts::{ENV_TINY_ENC_CONFIG_FILE, TINY_ENC_CONFIG_FILE, TINY_ENC_CONFIG_FILE_2, TINY_ENC_CONFIG_FILE_3, TINY_ENC_FILE_EXT};
|
||||||
use crate::spec::TinyEncryptEnvelopType;
|
use crate::spec::TinyEncryptEnvelopType;
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ pub struct TinyEncryptConfigEnvelop {
|
|||||||
|
|
||||||
impl TinyEncryptConfig {
|
impl TinyEncryptConfig {
|
||||||
pub fn load_default() -> XResult<Self> {
|
pub fn load_default() -> XResult<Self> {
|
||||||
let resolved_file0 = env::var(ENV_TINY_ENC_CONFIG_FILE).ok();
|
let resolved_file0 = rust_util_env::env_var(ENV_TINY_ENC_CONFIG_FILE);
|
||||||
let resolved_file_1 = resolve_file_path(TINY_ENC_CONFIG_FILE);
|
let resolved_file_1 = resolve_file_path(TINY_ENC_CONFIG_FILE);
|
||||||
let resolved_file_2 = resolve_file_path(TINY_ENC_CONFIG_FILE_2);
|
let resolved_file_2 = resolve_file_path(TINY_ENC_CONFIG_FILE_2);
|
||||||
let resolved_file_3 = resolve_file_path(TINY_ENC_CONFIG_FILE_3);
|
let resolved_file_3 = resolve_file_path(TINY_ENC_CONFIG_FILE_3);
|
||||||
@@ -386,10 +386,10 @@ pub fn load_includes_and_merge(mut config: TinyEncryptConfig) -> TinyEncryptConf
|
|||||||
pub fn search_include_configs(includes_path: &str) -> Vec<TinyEncryptConfig> {
|
pub fn search_include_configs(includes_path: &str) -> Vec<TinyEncryptConfig> {
|
||||||
let includes_path = if includes_path.starts_with("$") {
|
let includes_path = if includes_path.starts_with("$") {
|
||||||
let includes_path_env_var = includes_path.chars().skip(1).collect::<String>();
|
let includes_path_env_var = includes_path.chars().skip(1).collect::<String>();
|
||||||
match env::var(&includes_path_env_var) {
|
match rust_util_env::env_var(&includes_path_env_var) {
|
||||||
Ok(includes_path) => includes_path,
|
Some(includes_path) => includes_path,
|
||||||
Err(e) => {
|
None => {
|
||||||
warning!("Cannot find env var: {}, failed: {}", &includes_path_env_var, e);
|
warning!("Cannot find env var: {}", &includes_path_env_var);
|
||||||
return vec![];
|
return vec![];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ pub const TINY_ENCRYPT_ENV_NO_DEFAULT_PIN_HINT: &str = "TINY_ENCRYPT_NO_DEFAULT_
|
|||||||
pub const TINY_ENCRYPT_ENV_PIN_ENTRY: &str = "TINY_ENCRYPT_PIN_ENTRY";
|
pub const TINY_ENCRYPT_ENV_PIN_ENTRY: &str = "TINY_ENCRYPT_PIN_ENTRY";
|
||||||
|
|
||||||
pub fn get_default_encryption_algorithm() -> Option<&'static str> {
|
pub fn get_default_encryption_algorithm() -> Option<&'static str> {
|
||||||
let env_default_algorithm = env::var(TINY_ENCRYPT_ENV_DEFAULT_ALGORITHM).ok();
|
let env_default_algorithm = rust_util_env::env_var(TINY_ENCRYPT_ENV_DEFAULT_ALGORITHM);
|
||||||
debugging!("Environment variable {} = {:?}", TINY_ENCRYPT_ENV_DEFAULT_ALGORITHM, env_default_algorithm);
|
debugging!("Environment variable {} = {:?}", TINY_ENCRYPT_ENV_DEFAULT_ALGORITHM, env_default_algorithm);
|
||||||
if let Some(env_algorithm) = env_default_algorithm {
|
if let Some(env_algorithm) = env_default_algorithm {
|
||||||
let lower_default_algorithm = env_algorithm.to_lowercase();
|
let lower_default_algorithm = env_algorithm.to_lowercase();
|
||||||
@@ -36,11 +36,11 @@ pub fn get_pin() -> Option<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_key_id() -> Option<String> {
|
pub fn get_key_id() -> Option<String> {
|
||||||
env::var(TINY_ENCRYPT_ENV_KEY_ID).ok()
|
rust_util_env::env_var(TINY_ENCRYPT_ENV_KEY_ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_gpg_cmd() -> Option<String> {
|
pub fn get_gpg_cmd() -> Option<String> {
|
||||||
env::var(TINY_ENCRYPT_ENV_GPG_COMMAND).ok()
|
rust_util_env::env_var(TINY_ENCRYPT_ENV_GPG_COMMAND)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_default_pin_entry() -> Option<String> {
|
pub fn get_default_pin_entry() -> Option<String> {
|
||||||
@@ -54,7 +54,7 @@ pub fn get_default_pin_entry() -> Option<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_pin_entry() -> Option<String> {
|
pub fn get_pin_entry() -> Option<String> {
|
||||||
env::var(TINY_ENCRYPT_ENV_PIN_ENTRY).ok()
|
rust_util_env::env_var(TINY_ENCRYPT_ENV_PIN_ENTRY)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_auto_select_key_ids() -> Option<Vec<String>> {
|
pub fn get_auto_select_key_ids() -> Option<Vec<String>> {
|
||||||
@@ -66,7 +66,7 @@ pub fn get_auto_compress_file_exts() -> Option<Vec<String>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_default_compress() -> Option<bool> {
|
pub fn get_default_compress() -> Option<bool> {
|
||||||
env::var(TINY_ENCRYPT_ENV_DEFAULT_COMPRESS).ok().map(|val| util_env::is_on(&val))
|
rust_util_env::env_var(TINY_ENCRYPT_ENV_DEFAULT_COMPRESS).map(|val| util_env::is_on(&val))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_no_progress() -> bool {
|
pub fn get_no_progress() -> bool {
|
||||||
@@ -82,7 +82,7 @@ pub fn get_use_dialoguer() -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_env_with_split(env_name: &str) -> Option<Vec<String>> {
|
fn get_env_with_split(env_name: &str) -> Option<Vec<String>> {
|
||||||
let val = env::var(env_name).ok();
|
let val = rust_util_env::env_var(env_name);
|
||||||
debugging!("Environment variable {} = {:?}", env_name, &val);
|
debugging!("Environment variable {} = {:?}", env_name, &val);
|
||||||
val.map(|env_values| {
|
val.map(|env_values| {
|
||||||
env_values.split(',').map(ToString::to_string).collect::<Vec<_>>()
|
env_values.split(',').map(ToString::to_string).collect::<Vec<_>>()
|
||||||
|
|||||||
Reference in New Issue
Block a user