git.delta.rocks / remowt / refs/commits / 2499daa8100a

difftreelog

feat enum prompt variant

wnlysuptYaroslav Bolyukin2024-08-05parent: #7c2fb57.patch.diff
in: trunk

11 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -351,9 +351,9 @@
 
 [[package]]
 name = "clap"
-version = "4.5.11"
+version = "4.5.13"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3"
+checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc"
 dependencies = [
  "clap_builder",
  "clap_derive",
@@ -361,9 +361,9 @@
 
 [[package]]
 name = "clap_builder"
-version = "4.5.11"
+version = "4.5.13"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa"
+checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99"
 dependencies = [
  "anstream",
  "anstyle",
@@ -373,9 +373,9 @@
 
 [[package]]
 name = "clap_derive"
-version = "4.5.11"
+version = "4.5.13"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5d029b67f89d30bbb547c89fd5161293c0aec155fc691d7924b64550662db93e"
+checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0"
 dependencies = [
  "heck",
  "proc-macro2",
@@ -863,24 +863,6 @@
 ]
 
 [[package]]
-name = "polkit-agent"
-version = "0.1.0"
-dependencies = [
- "anyhow",
- "pam-client",
- "polkit-shared",
- "rand",
- "serde",
- "tokio",
- "tracing",
- "tracing-subscriber",
- "ui-prompt",
- "uuid",
- "zbus",
- "zbus_polkit",
-]
-
-[[package]]
 name = "polkit-backend"
 version = "0.1.0"
 dependencies = [
@@ -1013,6 +995,29 @@
 checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
 
 [[package]]
+name = "remowt-agent"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "clap",
+ "pam-client",
+ "polkit-shared",
+ "rand",
+ "serde",
+ "tokio",
+ "tracing",
+ "tracing-subscriber",
+ "ui-prompt",
+ "uuid",
+ "zbus",
+ "zbus_polkit",
+]
+
+[[package]]
+name = "remowt-ssh"
+version = "0.1.0"
+
+[[package]]
 name = "rpassword"
 version = "6.0.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,3 +1,7 @@
 [workspace]
 members = ["cmds/*", "crates/*"]
 resolver = "2"
+
+[workspace.packages]
+bifrostlink = { path = "../bifrostlink/crates/bifrostlink" }
+bifrostlink-ports = { path = "../bifrostlink/crates/bifrostlink-ports" }
deletedcmds/polkit-agent/Cargo.tomldiffbeforeafterboth
--- a/cmds/polkit-agent/Cargo.toml
+++ /dev/null
@@ -1,18 +0,0 @@
-[package]
-name = "polkit-agent"
-version = "0.1.0"
-edition = "2021"
-
-[dependencies]
-anyhow = "1.0.86"
-pam-client = "0.5.0"
-polkit-shared = { version = "0.1.0", path = "../../crates/polkit-shared" }
-rand = "0.8.5"
-serde = { version = "1.0.204", features = ["derive"] }
-tokio = { version = "1.39.2", features = ["rt-multi-thread", "fs", "macros"] }
-tracing = "0.1.40"
-tracing-subscriber = "0.3.18"
-ui-prompt = { version = "0.1.0", path = "../../crates/ui-prompt" }
-uuid = { version = "1.10.0", features = ["v4"] }
-zbus = { version = "4.4.0", features = ["tokio"] }
-zbus_polkit = { version = "4.0.0", features = ["tokio"] }
deletedcmds/polkit-agent/src/main.rsdiffbeforeafterboth
before · cmds/polkit-agent/src/main.rs
1use std::collections::HashMap;2use std::future;3use std::marker::PhantomData;4use std::sync::{Mutex, RwLock};56use polkit_shared::{BackendRequest, Identity};7use tokio::runtime::Handle;8use tokio::task::{AbortHandle, JoinHandle, LocalSet};9use tracing::trace;10use ui_prompt::dbus::DbusPrompterInterface;11use ui_prompt::rofi::RofiPrompter;12use ui_prompt::Prompter;13use zbus::zvariant::{OwnedValue, Str};14use zbus::ObjectServer;15use zbus::{interface, proxy, Connection};16use zbus_polkit::policykit1::Subject;1718struct TemporaryPrompterInterface<P: Prompter + Send + Sync + 'static> {19    connection: Connection,20    path: String,21    _marker: PhantomData<P>,22}23impl<P: Prompter + Send + Sync + 'static> TemporaryPrompterInterface<P> {24    async fn new(connection: Connection, prompter: P) -> Self {25        let path = format!(26            "/remowt/prompters/{}",27            uuid::Uuid::new_v4().to_string().replace("-", "_")28        );29        let _ = connection30            .object_server()31            .at(path.clone(), DbusPrompterInterface(prompter))32            .await;33        Self {34            connection,35            path,36            _marker: PhantomData,37        }38    }39}40impl<P: Prompter + Send + Sync + 'static> Drop for TemporaryPrompterInterface<P> {41    fn drop(&mut self) {42        // FIXME: block_in_place prevents to moving to current_thread runtime43        // There should be a blocking way to remove ObjectServer listener.44        // As far as I can see, it is only async because of async RwLock, shouldn't it be45        // just a sync lock?46        tokio::task::block_in_place(move || {47            Handle::current().block_on(async {48                let _ = self49                    .connection50                    .object_server()51                    .remove::<DbusPrompterInterface<P>, String>(self.path.clone())52                    .await;53            });54        });55    }56}5758struct Agent {59    helper: PolkitHelperProxy<'static>,60    tasks: Mutex<HashMap<String, AbortHandle>>,61    connection: Connection,62}63impl Agent {64    async fn new(connection: Connection) -> anyhow::Result<Self> {65        Ok(Self {66            helper: PolkitHelperProxy::new(&connection).await?,67            tasks: Mutex::new(HashMap::new()),68            connection,69        })70    }71}7273#[interface(name = "org.freedesktop.PolicyKit1.AuthenticationAgent")]74impl Agent {75    /// BeginAuthentication method76    #[allow(clippy::too_many_arguments)]77    async fn begin_authentication(78        &mut self,79        action_id: String,80        message: String,81        icon_name: String,82        details: HashMap<String, String>,83        cookie: String,84        identities: Vec<Identity>,85    ) -> zbus::fdo::Result<()> {86        trace!("begin auth");87        let task = {88            let connection = self.connection.clone();89            let helper = self.helper.clone();90            let cookie = cookie.clone();91            tokio::task::spawn(async move {92                trace!("conversation task");93                let prompter = TemporaryPrompterInterface::new(connection, RofiPrompter).await;94                helper95                    .init_conversation(96                        BackendRequest {97                            cookie: cookie.to_owned(),98                            environment: HashMap::new(),99                            prompter_path: prompter.path.clone(),100                            // TODO: Let user choose101                            identity: identities.get(0).expect("first always exists").clone(),102                        }, // cookie.to_owned(), HashMap::new(), prompter.path.clone()103                    )104                    .await?;105                println!("ASKED");106                dbg!(action_id, message, icon_name, details, cookie, identities);107108                Ok(())109            })110        };111112        self.tasks113            .lock()114            .unwrap()115            .insert(cookie.clone(), task.abort_handle());116        let result = task.await.expect("join error");117        // The only way to no reach this line, is to either panic in previous line, or if authorization cancelled,118        // while cancellation will remove task by itself.119        // TODO: But still it would be better to have abort guard, which will remove it from HashMap120        self.tasks.lock().unwrap().remove(&cookie);121122        result123    }124125    /// CancelAuthentication method126    async fn cancel_authentication(&self, cookie: &str) -> zbus::fdo::Result<()> {127        trace!("cancel auth");128        if let Some(abort) = self.tasks.lock().unwrap().remove(cookie) {129            abort.abort();130        }131        // debug!("Authentication cancled ! {cookie}");132        Ok(())133    }134}135136const OBJ_PATH: &str = "/0lach/polkitAgent";137#[tokio::main]138async fn main() -> anyhow::Result<()> {139    tracing_subscriber::fmt::init();140141    trace!("started");142    let conn = Connection::system().await?;143144    let proxy = zbus_polkit::policykit1::AuthorityProxy::new(&conn).await?;145    conn.object_server()146        .at(OBJ_PATH, Agent::new(conn.clone()).await?)147        .await?;148149    let session_id = std::env::var("XDG_SESSION_ID")?;150    let mut details = HashMap::new();151    let val: OwnedValue = {152        let wrapped: Str<'_> = session_id.into();153        wrapped.into()154    };155    details.insert("session-id".to_string(), val);156    proxy157        .register_authentication_agent(158            &Subject {159                subject_kind: "unix-session".to_string(),160                subject_details: details,161            },162            "C",163            OBJ_PATH,164        )165        .await?;166167    future::pending().await168}169170#[proxy(171    interface = "lach.PolkitHelper",172    default_service = "lach.polkit.helper1",173    default_path = "/lach/PolkitHelper"174)]175trait PolkitHelper {176    fn init_conversation(&self, request: BackendRequest) -> zbus::Result<()>;177}
addedcmds/remowt-agent/Cargo.tomldiffbeforeafterboth
--- /dev/null
+++ b/cmds/remowt-agent/Cargo.toml
@@ -0,0 +1,19 @@
+[package]
+name = "remowt-agent"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+anyhow = "1.0.86"
+clap = { version = "4.5.13", features = ["derive"] }
+pam-client = "0.5.0"
+polkit-shared = { version = "0.1.0", path = "../../crates/polkit-shared" }
+rand = "0.8.5"
+serde = { version = "1.0.204", features = ["derive"] }
+tokio = { version = "1.39.2", features = ["rt-multi-thread", "fs", "macros"] }
+tracing = "0.1.40"
+tracing-subscriber = "0.3.18"
+ui-prompt = { version = "0.1.0", path = "../../crates/ui-prompt" }
+uuid = { version = "1.10.0", features = ["v4"] }
+zbus = { version = "4.4.0", features = ["tokio"] }
+zbus_polkit = { version = "4.0.0", features = ["tokio"] }
addedcmds/remowt-agent/src/main.rsdiffbeforeafterboth
--- /dev/null
+++ b/cmds/remowt-agent/src/main.rs
@@ -0,0 +1,197 @@
+use std::collections::HashMap;
+use std::io::{stdout, Write};
+use std::marker::PhantomData;
+use std::sync::{Mutex, RwLock};
+use std::{future, process};
+
+use clap::Parser;
+use polkit_shared::{BackendRequest, Identity};
+use tokio::runtime::Handle;
+use tokio::task::{AbortHandle, JoinHandle, LocalSet};
+use tracing::trace;
+use ui_prompt::dbus::DbusPrompterInterface;
+use ui_prompt::rofi::RofiPrompter;
+use ui_prompt::Prompter;
+use zbus::zvariant::{OwnedValue, Str};
+use zbus::ObjectServer;
+use zbus::{interface, proxy, Connection};
+use zbus_polkit::policykit1::Subject;
+
+struct TemporaryPrompterInterface<P: Prompter + Send + Sync + 'static> {
+    connection: Connection,
+    path: String,
+    _marker: PhantomData<P>,
+}
+impl<P: Prompter + Send + Sync + 'static> TemporaryPrompterInterface<P> {
+    async fn new(connection: Connection, prompter: P) -> Self {
+        let path = format!(
+            "/remowt/prompters/{}",
+            uuid::Uuid::new_v4().to_string().replace("-", "_")
+        );
+        let _ = connection
+            .object_server()
+            .at(path.clone(), DbusPrompterInterface(prompter))
+            .await;
+        Self {
+            connection,
+            path,
+            _marker: PhantomData,
+        }
+    }
+}
+impl<P: Prompter + Send + Sync + 'static> Drop for TemporaryPrompterInterface<P> {
+    fn drop(&mut self) {
+        // FIXME: block_in_place prevents to moving to current_thread runtime
+        // There should be a blocking way to remove ObjectServer listener.
+        // As far as I can see, it is only async because of async RwLock, shouldn't it be
+        // just a sync lock?
+        tokio::task::block_in_place(move || {
+            Handle::current().block_on(async {
+                let _ = self
+                    .connection
+                    .object_server()
+                    .remove::<DbusPrompterInterface<P>, String>(self.path.clone())
+                    .await;
+            });
+        });
+    }
+}
+
+struct Agent {
+    helper: PolkitHelperProxy<'static>,
+    tasks: Mutex<HashMap<String, AbortHandle>>,
+    connection: Connection,
+}
+impl Agent {
+    async fn new(connection: Connection) -> anyhow::Result<Self> {
+        Ok(Self {
+            helper: PolkitHelperProxy::new(&connection).await?,
+            tasks: Mutex::new(HashMap::new()),
+            connection,
+        })
+    }
+}
+
+#[interface(name = "org.freedesktop.PolicyKit1.AuthenticationAgent")]
+impl Agent {
+    /// BeginAuthentication method
+    #[allow(clippy::too_many_arguments)]
+    async fn begin_authentication(
+        &mut self,
+        action_id: String,
+        message: String,
+        icon_name: String,
+        details: HashMap<String, String>,
+        cookie: String,
+        identities: Vec<Identity>,
+    ) -> zbus::fdo::Result<()> {
+        trace!("begin auth");
+        let task = {
+            let connection = self.connection.clone();
+            let helper = self.helper.clone();
+            let cookie = cookie.clone();
+            tokio::task::spawn(async move {
+                trace!("conversation task");
+                let prompter = TemporaryPrompterInterface::new(connection, RofiPrompter).await;
+                helper
+                    .init_conversation(
+                        BackendRequest {
+                            cookie: cookie.to_owned(),
+                            environment: HashMap::new(),
+                            prompter_path: prompter.path.clone(),
+                            // TODO: Let user choose
+                            identity: identities.get(0).expect("first always exists").clone(),
+                        }, // cookie.to_owned(), HashMap::new(), prompter.path.clone()
+                    )
+                    .await?;
+                println!("ASKED");
+                dbg!(action_id, message, icon_name, details, cookie, identities);
+
+                Ok(())
+            })
+        };
+
+        self.tasks
+            .lock()
+            .unwrap()
+            .insert(cookie.clone(), task.abort_handle());
+        let result = task.await.expect("join error");
+        // The only way to no reach this line, is to either panic in previous line, or if authorization cancelled,
+        // while cancellation will remove task by itself.
+        // TODO: But still it would be better to have abort guard, which will remove it from HashMap
+        self.tasks.lock().unwrap().remove(&cookie);
+
+        result
+    }
+
+    /// CancelAuthentication method
+    async fn cancel_authentication(&self, cookie: &str) -> zbus::fdo::Result<()> {
+        trace!("cancel auth");
+        if let Some(abort) = self.tasks.lock().unwrap().remove(cookie) {
+            abort.abort();
+        }
+        // debug!("Authentication cancled ! {cookie}");
+        Ok(())
+    }
+}
+
+const OBJ_PATH: &str = "/0lach/polkitAgent";
+
+#[proxy(
+    interface = "lach.PolkitHelper",
+    default_service = "lach.polkit.helper1",
+    default_path = "/lach/PolkitHelper"
+)]
+trait PolkitHelper {
+    fn init_conversation(&self, request: BackendRequest) -> zbus::Result<()>;
+}
+
+#[derive(Parser)]
+enum Opts {
+    Agent,
+    AskPass { description: String },
+}
+
+#[tokio::main]
+async fn main() -> anyhow::Result<()> {
+    tracing_subscriber::fmt::init();
+    let opts = Opts::parse();
+
+    match opts {
+        Opts::Agent => {
+            trace!("started");
+            let conn = Connection::system().await?;
+
+            let proxy = zbus_polkit::policykit1::AuthorityProxy::new(&conn).await?;
+            conn.object_server()
+                .at(OBJ_PATH, Agent::new(conn.clone()).await?)
+                .await?;
+
+            let session_id = std::env::var("XDG_SESSION_ID")?;
+            let mut details = HashMap::new();
+            let val: OwnedValue = {
+                let wrapped: Str<'_> = session_id.into();
+                wrapped.into()
+            };
+            details.insert("session-id".to_string(), val);
+            proxy
+                .register_authentication_agent(
+                    &Subject {
+                        subject_kind: "unix-session".to_string(),
+                        subject_details: details,
+                    },
+                    "C",
+                    OBJ_PATH,
+                )
+                .await?;
+        }
+        Opts::AskPass { description } => {
+            let password = RofiPrompter
+                .prompt_text(false, &description, "SSH password request", &[])
+                .await?;
+            stdout().lock().write_all(password.as_bytes())?;
+        }
+    }
+
+    future::pending().await
+}
addedcmds/remowt-ssh/Cargo.tomldiffbeforeafterboth
--- /dev/null
+++ b/cmds/remowt-ssh/Cargo.toml
@@ -0,0 +1,6 @@
+[package]
+name = "remowt-ssh"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
addedcmds/remowt-ssh/src/main.rsdiffbeforeafterboth
--- /dev/null
+++ b/cmds/remowt-ssh/src/main.rs
@@ -0,0 +1,3 @@
+fn main() {
+    println!("Hello, world!");
+}
modifiedcrates/ui-prompt/src/dbus.rsdiffbeforeafterboth
--- a/crates/ui-prompt/src/dbus.rs
+++ b/crates/ui-prompt/src/dbus.rs
@@ -40,12 +40,13 @@
 
 #[proxy(interface = "lach.PolkitInputHandler")]
 trait DbusPrompter {
-    async fn prompt_radio(
+    async fn prompt_enum(
         &self,
         prompt: &str,
         description: &str,
+        variants: &[&str],
         source: &[Source],
-    ) -> fdo::Result<bool>;
+    ) -> fdo::Result<u32>;
     async fn prompt_text(
         &self,
         echo: bool,
@@ -62,13 +63,16 @@
 }
 
 impl Prompter for DbusPrompterProxy<'_> {
-    async fn prompt_radio(
+    async fn prompt_enum(
         &self,
         prompt: &str,
         description: &str,
+        variants: &[&str],
         source: &[Source],
-    ) -> Result<bool> {
-        Ok(self.prompt_radio(prompt, description, source).await?)
+    ) -> Result<u32> {
+        Ok(self
+            .prompt_enum(prompt, description, variants, source)
+            .await?)
     }
 
     async fn prompt_text(
@@ -86,8 +90,14 @@
     }
 }
 impl BlockingPrompter for DbusPrompterProxyBlocking<'_> {
-    fn prompt_radio(&self, prompt: &str, description: &str, source: &[Source]) -> Result<bool> {
-        Ok(self.prompt_radio(prompt, description, source)?)
+    fn prompt_enum(
+        &self,
+        prompt: &str,
+        description: &str,
+        variants: &[&str],
+        source: &[Source],
+    ) -> Result<u32> {
+        Ok(self.prompt_enum(prompt, description, variants, source)?)
     }
 
     fn prompt_text(
modifiedcrates/ui-prompt/src/lib.rsdiffbeforeafterboth
--- a/crates/ui-prompt/src/lib.rs
+++ b/crates/ui-prompt/src/lib.rs
@@ -31,7 +31,17 @@
         prompt: &str,
         description: &str,
         source: &[Source],
-    ) -> impl Future<Output = Result<bool>> + Send;
+    ) -> impl Future<Output = Result<bool>> + Send {
+        let fut = self.prompt_enum(prompt, description, &["No", "Yes"], source);
+        async { fut.await.map(|v| v == 1) }
+    }
+    fn prompt_enum(
+        &self,
+        prompt: &str,
+        description: &str,
+        variants: &[&str],
+        source: &[Source],
+    ) -> impl Future<Output = Result<u32>> + Send;
     fn prompt_text(
         &self,
         echo: bool,
@@ -47,7 +57,17 @@
     ) -> impl Future<Output = Result<()>> + Send;
 }
 pub trait BlockingPrompter {
-    fn prompt_radio(&self, prompt: &str, description: &str, source: &[Source]) -> Result<bool>;
+    fn prompt_radio(&self, prompt: &str, description: &str, source: &[Source]) -> Result<bool> {
+        self.prompt_enum(prompt, description, &["No", "Yes"], source)
+            .map(|v| v == 1)
+    }
+    fn prompt_enum(
+        &self,
+        prompt: &str,
+        description: &str,
+        variants: &[&str],
+        source: &[Source],
+    ) -> Result<u32>;
     fn prompt_text(
         &self,
         echo: bool,
@@ -73,14 +93,15 @@
 where
     P: Prompter + Sync,
 {
-    async fn prompt_radio(
+    async fn prompt_enum(
         &self,
         prompt: &str,
         description: &str,
+        variants: &[&str],
         source: &[Source],
-    ) -> Result<bool> {
+    ) -> Result<u32> {
         self.prompter
-            .prompt_radio(prompt, description, &self.source(source))
+            .prompt_enum(prompt, description, variants, &self.source(source))
             .await
     }
 
modifiedcrates/ui-prompt/src/rofi.rsdiffbeforeafterboth
--- a/crates/ui-prompt/src/rofi.rs
+++ b/crates/ui-prompt/src/rofi.rs
@@ -8,13 +8,19 @@
 
 pub struct RofiPrompter;
 
+fn fixup_prompt(prompt: &str) -> &str {
+    // Rofi always appends such suffix
+    prompt.strip_suffix(": ").unwrap_or(prompt)
+}
+
 impl Prompter for RofiPrompter {
-    async fn prompt_radio(
+    async fn prompt_enum(
         &self,
         prompt: &str,
         description: &str,
+        variants: &[&str],
         source: &[Source],
-    ) -> Result<bool> {
+    ) -> Result<u32> {
         trace!("rofi radio");
         let mut cmd = Command::new("rofi");
         let mesg = if source.is_empty() {
@@ -34,7 +40,9 @@
             "-sync",
             "-only-match",
             "-p",
-            prompt,
+            fixup_prompt(prompt),
+            "-format",
+            "i",
         ]);
         cmd.stdin(Stdio::piped());
         cmd.stdout(Stdio::piped());
@@ -43,13 +51,20 @@
             .spawn()
             .map_err(|e| Error::InputError(format!("failed to spawn rofi: {e}")))?;
 
-        child
-            .stdin
-            .take()
-            .expect("stdin is piped")
-            .write_all(b"Yes\nNo\n")
-            .await
-            .map_err(|e| Error::InputError(format!("failed to write rofi variants: {e}")))?;
+        let mut stdin = child.stdin.take().expect("stdin is piped");
+        for var in variants {
+            stdin
+                .write_all(var.replace('\n', " ").as_bytes())
+                .await
+                .map_err(|e| Error::InputError(format!("failed to write rofi variants: {e}")))?;
+            stdin
+                .write_all(b"\n")
+                .await
+                .map_err(|e| Error::InputError(format!("failed to write rofi variants: {e}")))?;
+        }
+        // write_all already flushes, just to be sure.
+        let _ = stdin.flush().await;
+        drop(stdin);
 
         let out = child
             .wait_with_output()
@@ -61,13 +76,15 @@
             .unwrap_or(&out.stdout)
             .to_owned();
 
-        if &stdout == b"Yes" {
-            Ok(true)
-        } else if &stdout == b"No" {
-            Ok(false)
-        } else {
-            Err(Error::InputError("bad rofi response".to_owned()))
+        let id: u32 = String::from_utf8(stdout)
+            .map_err(|e| Error::InputError(format!("rofi produced invalid output: {e}")))?
+            .parse()
+            .map_err(|e| Error::InputError(format!("rofi produced invalid output: {e}")))?;
+        if id as usize >= variants.len() {
+            return Err(Error::InputError("invalid rofi response".to_owned()));
         }
+
+        Ok(id)
     }
 
     async fn prompt_text(
@@ -89,7 +106,7 @@
             out.push_str("</b>");
             out
         };
-        cmd.args(["-dmenu", "-mesg", &mesg, "-p", prompt]);
+        cmd.args(["-dmenu", "-mesg", &mesg, "-p", fixup_prompt(prompt)]);
         if !echo {
             cmd.arg("-password");
         }