mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-09-12 08:22:16 +00:00
fix: sandbox SQL local filesystem access (#8708)
* fix: sandbox SQL local filesystem access Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: address local file sandbox review findings Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: support Windows local copy paths Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: improve sandbox path errors Signed-off-by: jeremyhi <fengjiachun@gmail.com> * refactor: simplify local path error context Signed-off-by: jeremyhi <fengjiachun@gmail.com> * perf: stream secure filesystem listings Signed-off-by: jeremyhi <fengjiachun@gmail.com> * style: derive local file access default Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: improve local file access errors Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: address local file access review findings Signed-off-by: jeremyhi <fengjiachun@gmail.com> * test: simplify local file access coverage Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: harden sandboxed local file backends Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: reject directory copy targets before creation Signed-off-by: jeremyhi <fengjiachun@gmail.com> * fix: avoid implicit string clone in file table listing Signed-off-by: jeremyhi <fengjiachun@gmail.com> --------- Signed-off-by: jeremyhi <fengjiachun@gmail.com>
This commit is contained in:
@@ -20,6 +20,7 @@ client.workspace = true
|
||||
common-base.workspace = true
|
||||
common-catalog.workspace = true
|
||||
common-config.workspace = true
|
||||
common-datasource.workspace = true
|
||||
common-error.workspace = true
|
||||
common-function.workspace = true
|
||||
common-greptimedb-telemetry.workspace = true
|
||||
|
||||
@@ -39,6 +39,11 @@ use servers::http::HttpOptions;
|
||||
pub struct StorageConfig {
|
||||
/// The working directory of database
|
||||
pub data_home: String,
|
||||
/// Root directory for standalone SQL access to local files.
|
||||
///
|
||||
/// Defaults to `<data_home>/copy` when `data_home` is a local path.
|
||||
/// Distributed deployments always disable SQL access to local files.
|
||||
pub copy_root: Option<String>,
|
||||
#[serde(flatten)]
|
||||
pub store: ObjectStoreConfig,
|
||||
/// Object storage providers
|
||||
@@ -56,6 +61,7 @@ impl Default for StorageConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
data_home: DEFAULT_DATA_HOME.to_string(),
|
||||
copy_root: None,
|
||||
store: ObjectStoreConfig::default(),
|
||||
providers: vec![],
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ use std::sync::Arc;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use common_base::Plugins;
|
||||
use common_datasource::object_store::LocalFileAccess;
|
||||
use common_error::ext::BoxedError;
|
||||
use common_greptimedb_telemetry::GreptimeDBTelemetryTask;
|
||||
use common_meta::cache::{LayeredCacheRegistry, SchemaCacheRef, TableSchemaCacheRef};
|
||||
@@ -164,6 +165,7 @@ pub struct DatanodeBuilder {
|
||||
cache_registry: Option<Arc<LayeredCacheRegistry>>,
|
||||
topic_stats_reporter: Option<Box<dyn TopicStatsReporter>>,
|
||||
open_regions_writable_override: Option<bool>,
|
||||
local_file_access: LocalFileAccess,
|
||||
#[cfg(feature = "enterprise")]
|
||||
extension_range_provider_factory: Option<mito2::extension::BoxedExtensionRangeProviderFactory>,
|
||||
}
|
||||
@@ -178,6 +180,7 @@ impl DatanodeBuilder {
|
||||
kv_backend,
|
||||
cache_registry: None,
|
||||
open_regions_writable_override: None,
|
||||
local_file_access: LocalFileAccess::Disabled,
|
||||
#[cfg(feature = "enterprise")]
|
||||
extension_range_provider_factory: None,
|
||||
topic_stats_reporter: None,
|
||||
@@ -198,6 +201,11 @@ impl DatanodeBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_local_file_access(&mut self, local_file_access: LocalFileAccess) -> &mut Self {
|
||||
self.local_file_access = local_file_access;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn kv_backend(&self) -> &KvBackendRef {
|
||||
&self.kv_backend
|
||||
}
|
||||
@@ -528,6 +536,7 @@ impl DatanodeBuilder {
|
||||
let file_engine = FileRegionEngine::new(
|
||||
file_engine_config,
|
||||
object_store_manager.default_object_store().clone(), // TODO: implement custom storage for file engine
|
||||
self.local_file_access.clone(),
|
||||
);
|
||||
|
||||
Ok(vec![
|
||||
|
||||
Reference in New Issue
Block a user