Skip to content

Commit

Permalink
Pass query mode to sandbox
Browse files Browse the repository at this point in the history
  • Loading branch information
marcua committed Oct 30, 2024
1 parent 8c47df4 commit bab43ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/hosted_db/sandbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ SOFTWARE.

use crate::error::AybError;
use crate::hosted_db::paths::{pathbuf_to_file_name, pathbuf_to_parent};
use crate::hosted_db::QueryMode;
use serde::{Deserialize, Serialize};
use std::env::current_exe;
use std::fs::canonicalize;
Expand All @@ -51,6 +52,7 @@ pub async fn run_in_sandbox(
nsjail: &Path,
db_path: &PathBuf,
query: &str,
query_mode: QueryMode,
) -> Result<RunResult, AybError> {
let mut cmd = tokio::process::Command::new(nsjail);

Expand Down Expand Up @@ -97,6 +99,7 @@ pub async fn run_in_sandbox(
.arg("--")
.arg("/tmp/ayb_isolated_runner")
.arg(tmp_db_path)
.arg((query_mode as i16).to_string())
.arg(query)
.stdout(Stdio::piped())
.stderr(Stdio::piped())
Expand Down
3 changes: 2 additions & 1 deletion src/hosted_db/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ pub async fn potentially_isolated_sqlite_query(
query_mode: QueryMode,
) -> Result<QueryResult, AybError> {
if let Some(isolation) = isolation {
let result = run_in_sandbox(Path::new(&isolation.nsjail_path), path, query).await?;
let result =
run_in_sandbox(Path::new(&isolation.nsjail_path), path, query, query_mode).await?;

if !result.stderr.is_empty() {
let error: AybError = serde_json::from_str(&result.stderr)?;
Expand Down

0 comments on commit bab43ab

Please sign in to comment.