Skip to content

Commit

Permalink
Fix nsjail error, surface non-AybErrors more effectively
Browse files Browse the repository at this point in the history
  • Loading branch information
marcua committed Jan 20, 2025
1 parent eb54b4b commit 1d755bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/hosted_db/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,19 @@ pub async fn potentially_isolated_sqlite_query(
run_in_sandbox(Path::new(&isolation.nsjail_path), path, query, query_mode).await?;
println!("potentially2");
if !result.stderr.is_empty() {
println!("potentially3");
// Before shipping, consider whether to still try to parse and then catch the parsing error.
return Err(AybError::QueryError {
message: format!(
"Error message from sandboxed query runner: {}",
result.stderr
),
});
let error: AybError = serde_json::from_str(&result.stderr);
// If the error could be deserialized into an AybError,
// return that. Otherwise, create a more generic AybError
// to at least surface an issue.
return match error {
Ok(error) => Err(error),
Err(error) => Err(AybError::QueryError {
message: format!(
"Error message from sandboxed query runner: {}",
result.stderr
),
}),
};
} else if result.status != 0 {
println!("potentially5");
return Err(AybError::QueryError {
Expand Down
5 changes: 5 additions & 0 deletions tests/set_up_e2e_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ DOCKER_FLAGS="-v ${SCRIPT_PATH}:/etc/localstack/init/ready.d/init-aws.sh" locals
# On Ubuntu, assumes these requirements: sudo apt-get install -y libprotobuf-dev protobuf-compiler libnl-route-3-dev
scripts/build_nsjail.sh
mv nsjail tests/

# Starting with Ubuntu 24.x, nsjail won't run with default permissions
# (https://github.com/google/nsjail/issues/236).
sudo sysctl -w kernel.apparmor_restrict_unprivileged_unconfined=0
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0

0 comments on commit 1d755bd

Please sign in to comment.