-
Notifications
You must be signed in to change notification settings - Fork 13
[executor_manager] Move process stdout/stderr logs to top_dir #361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -227,11 +227,9 @@ impl HostShim { | |
| // Spawn child process | ||
| let mut cmd = tokio::process::Command::new(&command); | ||
|
|
||
| // Use app_dir for logs and temp files (per-instance isolation) | ||
| // Use app_dir for temp files (per-instance isolation) | ||
| let app_work_dir = work_dir.app_dir(); | ||
| // Use process_dir for the actual process working directory | ||
| // - User-specified: runs in top_dir (to find pyproject.toml, etc.) | ||
| // - Auto-generated: runs in app_dir | ||
| // Use process_dir for actual process working directory and stdout/stderr logs | ||
| let process_work_dir = work_dir.process_dir(); | ||
|
|
||
| // Setup working directory and tmp (per-instance) | ||
|
|
@@ -254,15 +252,15 @@ impl HostShim { | |
| .read(true) | ||
| .write(true) | ||
| .truncate(true) | ||
| .open(app_work_dir.join(format!("{}.out", executor.id))) | ||
| .open(process_work_dir.join(format!("{}.out", executor.id))) | ||
| .map_err(|e| FlameError::Internal(format!("failed to open stdout log file: {e}")))?; | ||
|
|
||
| let log_err = OpenOptions::new() | ||
| .create(true) | ||
| .read(true) | ||
| .write(true) | ||
| .truncate(true) | ||
| .open(app_work_dir.join(format!("{}.err", executor.id))) | ||
| .open(process_work_dir.join(format!("{}.err", executor.id))) | ||
|
Comment on lines
+255
to
+263
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The stdout and stderr log file paths are constructed by joining |
||
| .map_err(|e| FlameError::Internal(format!("failed to open stderr log file: {e}")))?; | ||
|
|
||
| let child = cmd | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,8 +36,8 @@ pub type ShimPtr = Arc<Mutex<dyn Shim>>; | |
|
|
||
| /// Represents the executor's working directory with cleanup management. | ||
| /// Directory structure: | ||
| /// top_dir/ - Process working directory (user-specified or auto-generated) | ||
| /// top_dir/work/<app_name>/ - App-specific directory for logs, tmp, cache | ||
| /// top_dir/ - Process working directory, stdout/stderr logs | ||
| /// top_dir/work/<app_name>/ - App-specific directory for tmp, cache | ||
| /// top_dir/work/<executor_id>.sock - Socket for gRPC communication | ||
| /// Cleanup: | ||
| /// - top_dir: cleaned up only if auto-generated | ||
|
|
@@ -106,7 +106,7 @@ impl ExecutorWorkDir { | |
| }) | ||
| } | ||
|
|
||
| /// Returns the application working directory path (for logs, tmp, cache). | ||
| /// Returns the application working directory path (for tmp, cache). | ||
| pub fn app_dir(&self) -> &Path { | ||
| &self.app_dir | ||
|
Comment on lines
+109
to
111
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
app_work_diris obtained viawork_dir.app_dir(), which returns a path constructed from the unsanitizedapp.name. Ifapp.namecontains path traversal sequences (e.g.,../../../../etc), this path can point to arbitrary locations outside the intended working directory. This is a critical security risk because theExecutorWorkDirimplementation (inmod.rs) recursively deletes this directory when it is dropped (fs::remove_dir_all(&self.app_dir)), which could lead to the destruction of sensitive system directories if a malicious application name is provided.