···3232 defer cancel()
33333434 // Build systemd-run command with security properties
3535- // Note: PrivateNetwork, PrivateTmp, ProtectHome, ProtectSystem, NoNewPrivileges
3636- // are only available for service units, not scope units.
3737- // Scope units only support resource limits (Memory, CPU, Tasks)
3535+ // Using service unit (not scope) to get access to network/filesystem isolation
3836 systemdArgs := []string{
3939- "--scope", // Create transient scope unit
3737+ "--unit=" + name, // Give it a descriptive name
4038 "--quiet", // Suppress systemd output
4139 "--collect", // Automatically clean up after exit
4040+ "--service-type=exec", // Run until process exits
4241 "--property=MemoryMax=512M", // Max 512MB RAM
4342 "--property=CPUQuota=200%", // Max 2 CPU cores worth
4443 "--property=TasksMax=50", // Max 50 processes/threads
4444+ "--property=PrivateNetwork=true", // Isolate network (no internet)
4545+ "--property=PrivateTmp=true", // Private /tmp
4646+ "--property=NoNewPrivileges=true", // Prevent privilege escalation
4547 "--",
4648 }
4749 systemdArgs = append(systemdArgs, args...)