-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime-sdk/modules/rofl: Run post-registration script
- Loading branch information
Showing
4 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//! Additional init functionalities performed by ROFL apps when running in a virtual machine | ||
//! environment (e.g. Intel TDX). | ||
#[cfg(feature = "tdx")] | ||
mod tdx; | ||
|
||
/// Perform post-registration initialization. This will set up things like external networking | ||
/// support inside the virtual machine. | ||
pub(crate) fn post_registration_init() { | ||
#[cfg(feature = "tdx")] | ||
tdx::post_registration_init(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//! Initialization specifix to Intel TDX. | ||
use std::{os::unix::fs::PermissionsExt, path::Path, process::Command}; | ||
|
||
use anyhow::Result; | ||
|
||
/// Path to the post-registration init script. | ||
const POST_REGISTRATION_INIT_SCRIPT: &str = "/etc/oasis/init.post-registration"; | ||
|
||
/// Perform post-registration initialization. This will set up things like external networking | ||
/// support inside the virtual machine. | ||
pub(crate) fn post_registration_init() { | ||
let _ = run_post_registration_init_script(); // Ignore errors. | ||
} | ||
|
||
fn run_post_registration_init_script() -> Result<()> { | ||
let meta = Path::new(POST_REGISTRATION_INIT_SCRIPT).metadata()?; | ||
|
||
// Only execute when it is an executable file. | ||
if !meta.is_file() || meta.permissions().mode() & 0o111 == 0 { | ||
return Ok(()); | ||
} | ||
|
||
let mut cmd = Command::new(POST_REGISTRATION_INIT_SCRIPT).spawn()?; | ||
cmd.wait()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ use crate::{ | |
|
||
mod client; | ||
mod env; | ||
mod init; | ||
mod notifier; | ||
pub mod prelude; | ||
mod processor; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters