fix: route forge_admin through hive-priv; auto-recover matrix passwords
forge_admin() spawned nixos-container run hive-forge directly from the
hive-core process. nixos-container run uses nsenter to enter the container
namespaces, which requires root. hive-core is unprivileged, so every call
failed with: nsenter: stat of /proc/<pid>/ns/user failed: Permission denied
Fix: add RunForgeAdmin { args } to PrivRequest. hive-priv (root) handles
it by spawning nixos-container run hive-forge -- runuser -u forgejo --
forgejo --work-path /var/lib/forgejo admin <args>. forge_admin() now calls
priv_client::run_forge_admin().
matrix: ensure_user_for hit M_USER_IN_USE then failed when the stored
password file was missing (state dirs wiped but homeserver kept accounts).
Previously required manual hivectl matrix reset-password <name>.
Fix: add auto_reset_password() — calls the admin API (PUT
/_synapse/admin/v2/users/@<name>:<server> with the hive admin token) to
set a new random password, then proceeds with login. Falls back to the
existing manual-recovery error if the admin token is unavailable.
Closes #1234
This commit is contained in:
parent
3830b13b03
commit
34bc4c0b06
5 changed files with 147 additions and 47 deletions
|
|
@ -198,6 +198,25 @@ pub enum PrivRequest {
|
|||
/// Set mode of `/run/hive-agent/<agent_name>/`.
|
||||
/// Fallback when uid lookup returns `None` on first spawn.
|
||||
ChmodSocketDir { agent_name: String, mode: u32 },
|
||||
|
||||
// --- Forge admin CLI ---
|
||||
/// Run `forgejo admin <args>` inside the `hive-forge` container as the
|
||||
/// `forgejo` unix user. hive-priv executes:
|
||||
///
|
||||
/// nixos-container run hive-forge -- runuser -u forgejo --
|
||||
/// forgejo --work-path /var/lib/forgejo admin <args>
|
||||
///
|
||||
/// `args` must not contain null bytes, newlines, or shell metacharacters;
|
||||
/// hive-priv validates this before spawning the subprocess.
|
||||
///
|
||||
/// This operation requires root (to nsenter into the forge container's
|
||||
/// namespaces); hive-c0re (which runs as `hive-core`) calls it through
|
||||
/// this route instead of spawning `nixos-container run` directly.
|
||||
RunForgeAdmin {
|
||||
/// Argument list appended after `forgejo --work-path /var/lib/forgejo admin`.
|
||||
/// Each element is a separate argv word — no shell expansion occurs.
|
||||
args: Vec<String>,
|
||||
},
|
||||
}
|
||||
|
||||
/// Response from the privileged helper.
|
||||
|
|
|
|||
Loading…
Reference in a new issue