Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(local): relabel FusionAuth kickstart mount for SELinux (#7302)

Will Hutchinson4a305f063065
diff --git a/docs/RUNNING_LOCALLY.md b/docs/RUNNING_LOCALLY.md
index 99d1b0b988..3c5960b98a 100644
--- a/docs/RUNNING_LOCALLY.md
+++ b/docs/RUNNING_LOCALLY.md
@@ -159,6 +159,25 @@ on demand. Register with any email address. FusionAuth sends you a one-time code
by email. That email lands in **Mailpit** at http://localhost:8025, not in a real
inbox.
+### Recover an existing instance without resetting data
+
+`run_local` and `stack up` initialize clean state, including snapshot restoration.
+Do not use them to recover an instance whose application or auth data must
+survive. Keep its generated env/Compose files and existing named volumes; start
+stopped containers with `docker start`, or recreate only the affected services
+with the same Compose project/files and `up -d --no-deps --no-build <service>`.
+Never use `down -v`, `reset_local`, or `destroy_local` for this recovery.
+
+On SELinux hosts, FusionAuth can become healthy while silently skipping an
+unreadable kickstart. The generated per-instance kickstart directory uses
+`:ro,Z`: read-only with a private container label. Regenerate the override with
+`cargo x gen-compose --instance <name>`, then recreate only FusionAuth against
+its existing volumes. Verify the kickstart is readable in the container and the
+configured application API returns 200 with the local API key; a healthy process
+alone does not prove kickstart ran. Do not disable SELinux, change host permissions,
+or delete the FusionAuth database. Diagnose other bind-mount denials separately;
+private labels must not be applied to directories shared by several containers.
+
### Seeding sample data (recommended)
A bare stack has no content to click through. The seed CLI creates a realistic
diff --git a/tooling/xtask/crates/xtask_local/src/local/gen_compose.rs b/tooling/xtask/crates/xtask_local/src/local/gen_compose.rs
index 775ac9bfed..4f24b3f4ea 100644
--- a/tooling/xtask/crates/xtask_local/src/local/gen_compose.rs
+++ b/tooling/xtask/crates/xtask_local/src/local/gen_compose.rs
@@ -26,6 +26,9 @@ use super::instance::{Instance, Port};
use super::inventory::services_for_mode;
use super::{Mode, repo_root};
+#[cfg(test)]
+mod test;
+
/// The one Rust service with a second listener: the agent egress proxy inside
/// `agent_harness_service`, on the container port `EGRESS_PORT` defaults to.
const EGRESS_SERVICE: &str = "agent_harness_service";
@@ -342,7 +345,8 @@ fn add_local_infra(
instance: &Instance,
static_frontend: bool,
) {
- // FusionAuth: repoint at the generated kickstart (volumes replaced via tag).
+ // This per-instance directory belongs only to FusionAuth. Private SELinux
+ // relabeling keeps the kickstart readable without sharing its container label.
let mut fusionauth = dct::Service {
environment: kv(&[(
"FUSIONAUTH_APP_KICKSTART_FILE",
@@ -351,7 +355,7 @@ fn add_local_infra(
volumes: vec![
dct::Volumes::Simple("fusionauth_config:/usr/local/fusionauth/config".to_string()),
dct::Volumes::Simple(format!(
- "{}:/usr/local/fusionauth/kickstart:ro",
+ "{}:/usr/local/fusionauth/kickstart:ro,Z",
kickstart_dir(instance).display()
)),
],
diff --git a/tooling/xtask/crates/xtask_local/src/local/gen_compose/test.rs b/tooling/xtask/crates/xtask_local/src/local/gen_compose/test.rs
new file mode 100644
index 0000000000..25f17dcdb7
--- /dev/null
+++ b/tooling/xtask/crates/xtask_local/src/local/gen_compose/test.rs
@@ -0,0 +1,32 @@
+use super::*;
+
+#[test]
+fn fusionauth_kickstart_is_privately_relabelled_and_replaces_inherited_mounts() {
+ for name in [None, Some("selinux-test")] {
+ let instance = Instance::derive(name, None).unwrap();
+ let mut services = IndexMap::new();
+ add_local_infra(&mut services, &instance, false);
+ let compose = dct::Compose {
+ services: dct::Services(services),
+ ..Default::default()
+ };
+ let mut value = serde_yaml::to_value(compose).unwrap();
+ apply_tags(&mut value, Mode::Local, &instance);
+
+ let Value::Tagged(volumes) = &value["services"]["fusionauth"]["volumes"] else {
+ panic!("FusionAuth mounts must replace the inherited mount list");
+ };
+ assert_eq!(volumes.tag, Tag::new("!override"));
+ assert_eq!(
+ volumes.value,
+ serde_yaml::to_value(vec![
+ "fusionauth_config:/usr/local/fusionauth/config".to_string(),
+ format!(
+ "{}:/usr/local/fusionauth/kickstart:ro,Z",
+ kickstart_dir(&instance).display()
+ ),
+ ])
+ .unwrap()
+ );
+ }
+}