difftreelog
refactor drop lach.PolkitHelper
Polkit127 has introduced /run/polkit/agent-helper.socket instead, which implements the same thing I want.
18 files changed
Cargo.lockdiffbeforeafterboth558 "tracing",558 "tracing",559]559]560561[[package]]562name = "bindgen"563version = "0.69.5"564source = "registry+https://github.com/rust-lang/crates.io-index"565checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088"566dependencies = [567 "bitflags 2.13.0",568 "cexpr",569 "clang-sys",570 "itertools 0.12.1",571 "lazy_static",572 "lazycell",573 "proc-macro2",574 "quote",575 "regex",576 "rustc-hash 1.1.0",577 "shlex 1.3.0",578 "syn 2.0.118",579]580560581[[package]]561[[package]]582name = "bindgen"562name = "bindgen"583version = "0.72.1"563version = "0.72.1"584source = "registry+https://github.com/rust-lang/crates.io-index"564source = "registry+https://github.com/rust-lang/crates.io-index"585checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895"565checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895"586dependencies = [566dependencies = [587 "bitflags 2.13.0",567 "bitflags",588 "cexpr",568 "cexpr",589 "clang-sys",569 "clang-sys",590 "itertools 0.13.0",570 "itertools 0.13.0",598 "syn 2.0.118",578 "syn 2.0.118",599]579]600601[[package]]602name = "bitflags"603version = "1.3.2"604source = "registry+https://github.com/rust-lang/crates.io-index"605checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"606580607[[package]]581[[package]]608name = "bitflags"582name = "bitflags"1415checksum = "ccc2776f0c61eca1ca32528f85548abd1a4be8fb53d1b21c013e4f18da1e7090"1389checksum = "ccc2776f0c61eca1ca32528f85548abd1a4be8fb53d1b21c013e4f18da1e7090"1416dependencies = [1390dependencies = [1417 "data-encoding",1391 "data-encoding",1418 "syn 1.0.109",1392 "syn 2.0.118",1419]1393]142013941421[[package]]1395[[package]]1566source = "registry+https://github.com/rust-lang/crates.io-index"1540source = "registry+https://github.com/rust-lang/crates.io-index"1567checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38"1541checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38"1568dependencies = [1542dependencies = [1569 "bitflags 2.13.0",1543 "bitflags",1570 "block2",1544 "block2",1571 "libc",1545 "libc",1572 "objc2",1546 "objc2",1706 "syn 2.0.118",1680 "syn 2.0.118",1707]1681]17081709[[package]]1710name = "enum-repr"1711version = "0.2.6"1712source = "registry+https://github.com/rust-lang/crates.io-index"1713checksum = "bad30c9c0fa1aaf1ae5010dab11f1117b15d35faf62cda4bbbc53b9987950f18"1714dependencies = [1715 "proc-macro2",1716 "quote",1717 "syn 1.0.109",1718]171916821720[[package]]1683[[package]]1721name = "enum_dispatch"1684name = "enum_dispatch"3123source = "registry+https://github.com/rust-lang/crates.io-index"3086source = "registry+https://github.com/rust-lang/crates.io-index"3124checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"3087checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"31253126[[package]]3127name = "itertools"3128version = "0.12.1"3129source = "registry+https://github.com/rust-lang/crates.io-index"3130checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"3131dependencies = [3132 "either",3133]313430883135[[package]]3089[[package]]3136name = "itertools"3090name = "itertools"3289 "spin 0.9.8",3243 "spin 0.9.8",3290]3244]32913292[[package]]3293name = "lazycell"3294version = "1.3.0"3295source = "registry+https://github.com/rust-lang/crates.io-index"3296checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"329732453298[[package]]3246[[package]]3299name = "libc"3247name = "libc"3323source = "registry+https://github.com/rust-lang/crates.io-index"3271source = "registry+https://github.com/rust-lang/crates.io-index"3324checksum = "f02ab6bace2054fb888a3c16f990117b579d14a3088e472d63c6011fa185c9d3"3272checksum = "f02ab6bace2054fb888a3c16f990117b579d14a3088e472d63c6011fa185c9d3"3325dependencies = [3273dependencies = [3326 "bitflags 2.13.0",3274 "bitflags",3327 "libc",3275 "libc",3328 "plain",3276 "plain",3329 "redox_syscall 0.8.1",3277 "redox_syscall 0.8.1",3611source = "registry+https://github.com/rust-lang/crates.io-index"3559source = "registry+https://github.com/rust-lang/crates.io-index"3612checksum = "df9854ea6ad14e3f4698a7f03b65bce0833dd2d81d594a0e4a984170537146b6"3560checksum = "df9854ea6ad14e3f4698a7f03b65bce0833dd2d81d594a0e4a984170537146b6"3613dependencies = [3561dependencies = [3614 "bitflags 2.13.0",3562 "bitflags",3615 "libc",3563 "libc",3616 "log",3564 "log",3617 "netlink-packet-core",3565 "netlink-packet-core",3623source = "registry+https://github.com/rust-lang/crates.io-index"3571source = "registry+https://github.com/rust-lang/crates.io-index"3624checksum = "e2288fcb784eb3defd5fb16f4c4160d5f477de192eac730f43e1d11c24d9a007"3572checksum = "e2288fcb784eb3defd5fb16f4c4160d5f477de192eac730f43e1d11c24d9a007"3625dependencies = [3573dependencies = [3626 "bitflags 2.13.0",3574 "bitflags",3627 "libc",3575 "libc",3628 "log",3576 "log",3629 "netlink-packet-core",3577 "netlink-packet-core",3699source = "registry+https://github.com/rust-lang/crates.io-index"3647source = "registry+https://github.com/rust-lang/crates.io-index"3700checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d"3648checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d"3701dependencies = [3649dependencies = [3702 "bitflags 2.13.0",3650 "bitflags",3703 "cfg-if",3651 "cfg-if",3704 "cfg_aliases",3652 "cfg_aliases",3705 "libc",3653 "libc",3710version = "0.1.9"3658version = "0.1.9"3711dependencies = [3659dependencies = [3712 "anyhow",3660 "anyhow",3713 "bindgen 0.72.1",3661 "bindgen",3714 "camino",3662 "camino",3715 "cxx",3663 "cxx",3716 "cxx-build",3664 "cxx-build",3943source = "registry+https://github.com/rust-lang/crates.io-index"3891source = "registry+https://github.com/rust-lang/crates.io-index"3944checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"3892checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"3945dependencies = [3893dependencies = [3946 "bitflags 2.13.0",3894 "bitflags",3947 "block2",3895 "block2",3948 "dispatch2",3896 "dispatch2",3949 "libc",3897 "libc",3956source = "registry+https://github.com/rust-lang/crates.io-index"3904source = "registry+https://github.com/rust-lang/crates.io-index"3957checksum = "c71e34919aba0d701380d911702455038a8a3587467fe0141d6a71501e7ffe48"3905checksum = "c71e34919aba0d701380d911702455038a8a3587467fe0141d6a71501e7ffe48"3958dependencies = [3906dependencies = [3959 "bitflags 2.13.0",3907 "bitflags",3960 "objc2",3908 "objc2",3961 "objc2-core-foundation",3909 "objc2-core-foundation",3962 "objc2-foundation",3910 "objc2-foundation",3976source = "registry+https://github.com/rust-lang/crates.io-index"3924source = "registry+https://github.com/rust-lang/crates.io-index"3977checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272"3925checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272"3978dependencies = [3926dependencies = [3979 "bitflags 2.13.0",3927 "bitflags",3980 "block2",3928 "block2",3981 "libc",3929 "libc",3982 "objc2",3930 "objc2",3989source = "registry+https://github.com/rust-lang/crates.io-index"3937source = "registry+https://github.com/rust-lang/crates.io-index"3990checksum = "709fe137109bd1e8b5a99390f77a7d8b2961dafc1a1c5db8f2e60329ad6d895a"3938checksum = "709fe137109bd1e8b5a99390f77a7d8b2961dafc1a1c5db8f2e60329ad6d895a"3991dependencies = [3939dependencies = [3992 "bitflags 2.13.0",3940 "bitflags",3993 "objc2",3941 "objc2",3994 "objc2-core-foundation",3942 "objc2-core-foundation",3995]3943]4010source = "registry+https://github.com/rust-lang/crates.io-index"3958source = "registry+https://github.com/rust-lang/crates.io-index"4011checksum = "7216bd11cbda54ccabcab84d523dc93b858ec75ecfb3a7d89513fa22464da396"3959checksum = "7216bd11cbda54ccabcab84d523dc93b858ec75ecfb3a7d89513fa22464da396"4012dependencies = [3960dependencies = [4013 "bitflags 2.13.0",3961 "bitflags",4014 "dispatch2",3962 "dispatch2",4015 "libc",3963 "libc",4016 "objc2",3964 "objc2",4217 "windows-strings",4165 "windows-strings",4218]4166]42194220[[package]]4221name = "pam-client"4222version = "0.5.0"4223source = "registry+https://github.com/rust-lang/crates.io-index"4224checksum = "51bd776116a7ada5ebbe31f54cdc5b1030ed7265686cf7c8a21c057a2f8dab9a"4225dependencies = [4226 "bitflags 1.3.2",4227 "enum-repr",4228 "libc",4229 "pam-sys",4230 "rpassword",4231 "rustversion",4232]42334234[[package]]4235name = "pam-sys"4236version = "1.0.0-alpha5"4237source = "registry+https://github.com/rust-lang/crates.io-index"4238checksum = "ce9484729b3e52c0bacdc5191cb6a6a5f31ef4c09c5e4ab1209d3340ad9e997b"4239dependencies = [4240 "bindgen 0.69.5",4241 "libc",4242]424341674244[[package]]4168[[package]]4245name = "papaya"4169name = "papaya"4509 "time",4433 "time",4510]4434]45114512[[package]]4513name = "polkit-backend"4514version = "0.1.9"4515dependencies = [4516 "anyhow",4517 "clap",4518 "nix",4519 "pam-client",4520 "remowt-polkit-shared",4521 "remowt-ui-prompt",4522 "tokio",4523 "tracing",4524 "tracing-subscriber",4525 "zbus",4526 "zbus_polkit",4527]452844354529[[package]]4436[[package]]4530name = "polling"4437name = "polling"4761source = "registry+https://github.com/rust-lang/crates.io-index"4668source = "registry+https://github.com/rust-lang/crates.io-index"4762checksum = "4b45fcc2344c680f5025fe57779faef368840d0bd1f42f216291f0dc4ace4744"4669checksum = "4b45fcc2344c680f5025fe57779faef368840d0bd1f42f216291f0dc4ace4744"4763dependencies = [4670dependencies = [4764 "bitflags 2.13.0",4671 "bitflags",4765 "num-traits",4672 "num-traits",4766 "rand 0.9.4",4673 "rand 0.9.4",4767 "rand_chacha 0.9.0",4674 "rand_chacha 0.9.0",4988source = "registry+https://github.com/rust-lang/crates.io-index"4895source = "registry+https://github.com/rust-lang/crates.io-index"4989checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"4896checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"4990dependencies = [4897dependencies = [4991 "bitflags 2.13.0",4898 "bitflags",4992]4899]499349004994[[package]]4901[[package]]4997source = "registry+https://github.com/rust-lang/crates.io-index"4904source = "registry+https://github.com/rust-lang/crates.io-index"4998checksum = "5b44b894f2a6e36457d665d1e08c3866add6ed5e70050c1b4ba8a8ddedb02ce7"4905checksum = "5b44b894f2a6e36457d665d1e08c3866add6ed5e70050c1b4ba8a8ddedb02ce7"4999dependencies = [4906dependencies = [5000 "bitflags 2.13.0",4907 "bitflags",5001]4908]500249095003[[package]]4910[[package]]5262 "windows-sys 0.52.0",5169 "windows-sys 0.52.0",5263]5170]52645265[[package]]5266name = "rpassword"5267version = "6.0.1"5268source = "registry+https://github.com/rust-lang/crates.io-index"5269checksum = "2bf099a1888612545b683d2661a1940089f6c2e5a8e38979b2159da876bfd956"5270dependencies = [5271 "libc",5272 "serde",5273 "serde_json",5274 "winapi",5275]527651715277[[package]]5172[[package]]5278name = "rsa"5173name = "rsa"5320checksum = "bbf893f64684e58da8a68d56a5e84d1cf0440226274c515770fe267707a7d0b0"5215checksum = "bbf893f64684e58da8a68d56a5e84d1cf0440226274c515770fe267707a7d0b0"5321dependencies = [5216dependencies = [5322 "aes 0.9.1",5217 "aes 0.9.1",5323 "bitflags 2.13.0",5218 "bitflags",5324 "block-padding 0.4.2",5219 "block-padding 0.4.2",5325 "byteorder",5220 "byteorder",5326 "bytes",5221 "bytes",5484source = "registry+https://github.com/rust-lang/crates.io-index"5379source = "registry+https://github.com/rust-lang/crates.io-index"5485checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"5380checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"5486dependencies = [5381dependencies = [5487 "bitflags 2.13.0",5382 "bitflags",5488 "errno",5383 "errno",5489 "libc",5384 "libc",5490 "linux-raw-sys 0.4.15",5385 "linux-raw-sys 0.4.15",5497source = "registry+https://github.com/rust-lang/crates.io-index"5392source = "registry+https://github.com/rust-lang/crates.io-index"5498checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"5393checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190"5499dependencies = [5394dependencies = [5500 "bitflags 2.13.0",5395 "bitflags",5501 "errno",5396 "errno",5502 "libc",5397 "libc",5503 "linux-raw-sys 0.12.1",5398 "linux-raw-sys 0.12.1",5700source = "registry+https://github.com/rust-lang/crates.io-index"5595source = "registry+https://github.com/rust-lang/crates.io-index"5701checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d"5596checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d"5702dependencies = [5597dependencies = [5703 "bitflags 2.13.0",5598 "bitflags",5704 "core-foundation 0.10.1",5599 "core-foundation 0.10.1",5705 "core-foundation-sys",5600 "core-foundation-sys",5706 "libc",5601 "libc",5956source = "registry+https://github.com/rust-lang/crates.io-index"5851source = "registry+https://github.com/rust-lang/crates.io-index"5957checksum = "7a75cbde1bf934313596a004973e462f9a82caa814dcf1a5f507bdf51597eeb4"5852checksum = "7a75cbde1bf934313596a004973e462f9a82caa814dcf1a5f507bdf51597eeb4"5958dependencies = [5853dependencies = [5959 "bitflags 2.13.0",5854 "bitflags",5960]5855]596158565962[[package]]5857[[package]]6184source = "registry+https://github.com/rust-lang/crates.io-index"6079source = "registry+https://github.com/rust-lang/crates.io-index"6185checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b"6080checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b"6186dependencies = [6081dependencies = [6187 "bitflags 2.13.0",6082 "bitflags",6188 "core-foundation 0.9.4",6083 "core-foundation 0.9.4",6189 "system-configuration-sys",6084 "system-configuration-sys",6190]6085]6610source = "registry+https://github.com/rust-lang/crates.io-index"6505source = "registry+https://github.com/rust-lang/crates.io-index"6611checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840"6506checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840"6612dependencies = [6507dependencies = [6613 "bitflags 2.13.0",6508 "bitflags",6614 "bytes",6509 "bytes",6615 "futures-util",6510 "futures-util",6616 "http",6511 "http",6953checksum = "a5924018406ce0063cd67f8e008104968b74b563ee1b85dde3ed1f7cb87d3dbd"6848checksum = "a5924018406ce0063cd67f8e008104968b74b563ee1b85dde3ed1f7cb87d3dbd"6954dependencies = [6849dependencies = [6955 "arrayvec",6850 "arrayvec",6956 "bitflags 2.13.0",6851 "bitflags",6957 "cursor-icon",6852 "cursor-icon",6958 "log",6853 "log",6959 "memchr",6854 "memchr",Cargo.tomldiffbeforeafterboth89zbus = "5.16.0"89zbus = "5.16.0"90zbus_polkit = "5.0.0"90zbus_polkit = "5.0.0"91tokio-util = "0.7.11"91tokio-util = "0.7.11"92pam-client = "0.5.0"939294[profile.dev]93[profile.dev]95panic = "abort"94panic = "abort"remowt/cmds/polkit-dbus-helper/Cargo.tomldiffbeforeafterbothno changes
remowt/cmds/polkit-dbus-helper/README.adocdiffbeforeafterbothno changes
remowt/cmds/polkit-dbus-helper/etc/systemd/system/remowt-polkit-helper.servicediffbeforeafterbothno changes
remowt/cmds/polkit-dbus-helper/share/dbus-1/system-services/lach.polkit.helper1.confdiffbeforeafterbothno changes
remowt/cmds/polkit-dbus-helper/share/dbus-1/system.d/lach.polkit.helper1.confdiffbeforeafterbothno changes
remowt/cmds/polkit-dbus-helper/src/main.rsdiffbeforeafterbothno changes
remowt/cmds/remowt-agent/src/helper/dbus.rsdiffbeforeafterbothno changes
remowt/cmds/remowt-agent/src/helper/mod.rsdiffbeforeafterboth2use remowt_polkit_shared::Identity;2use remowt_polkit_shared::Identity;3use remowt_ui_prompt::Prompter;3use remowt_ui_prompt::Prompter;445mod dbus;6mod protocol;5mod protocol;7mod socket;6mod socket;8mod suid;7mod suid;9810pub use dbus::DbusHelper;11pub use socket::SocketHelper;9pub use socket::SocketHelper;12pub use suid::SuidHelper;10pub use suid::SuidHelper;1311remowt/cmds/remowt-agent/src/main.rsdiffbeforeafterboth18};18};19use remowt_link_shared::iroh_tunnel::TunnelDialer;19use remowt_link_shared::iroh_tunnel::TunnelDialer;20use remowt_link_shared::{editor::EditorEndpointsClient, Address, BifConfig};20use remowt_link_shared::{editor::EditorEndpointsClient, Address, BifConfig};21use remowt_polkit_shared::{emphasize, BackendRequest, Identity, PidDisplay};21use remowt_polkit_shared::{emphasize, Identity, PidDisplay};22use remowt_ui_prompt::bifrost::PromptEndpointsClient;22use remowt_ui_prompt::bifrost::PromptEndpointsClient;23use remowt_ui_prompt::rofi::RofiPrompter;23use remowt_ui_prompt::rofi::RofiPrompter;24use remowt_ui_prompt::{PrependSourcePrompter, Prompter, Source};24use remowt_ui_prompt::{PrependSourcePrompter, Prompter, Source};29use tracing::{debug, trace};29use tracing::{debug, trace};30use zbus::fdo;30use zbus::fdo;31use zbus::zvariant::{OwnedValue, Str};31use zbus::zvariant::{OwnedValue, Str};32use zbus::{interface, proxy, Connection};32use zbus::{interface, Connection};33use zbus_polkit::policykit1::Subject;33use zbus_polkit::policykit1::Subject;343435use self::helper::{Helper, SocketHelper, SuidHelper};35use self::helper::{Helper, SocketHelper, SuidHelper};200200201const OBJ_PATH: &str = "/org/freedesktop/PolicyKit1/AuthenticationAgent";201const OBJ_PATH: &str = "/org/freedesktop/PolicyKit1/AuthenticationAgent";202203#[proxy(204 interface = "lach.PolkitHelper",205 default_service = "lach.polkit.helper1",206 default_path = "/lach/PolkitHelper"207)]208trait PolkitHelper {209 fn init_conversation(&self, request: BackendRequest) -> zbus::Result<()>;210}211202212#[derive(Parser)]203#[derive(Parser)]213enum Opts {204enum Opts {remowt/crates/polkit-shared/src/lib.rsdiffbeforeafterboth104 }104 }105}105}106107#[derive(Serialize, Deserialize, Type, PartialEq, Debug)]108pub struct BackendRequest {109 pub cookie: String,110 pub environment: HashMap<String, String>,111 pub prompter_path: String,112 pub identity: Identity,113}114106remowt/crates/remowt-link-shared/Cargo.tomldiffbeforeafterboth9anyhow.workspace = true9anyhow.workspace = true10bifrostlink.workspace = true10bifrostlink.workspace = true11bytes.workspace = true11bytes.workspace = true12camino = { workspace = true }12camino = { workspace = true, features = ["serde1"] }13serde = { workspace = true, features = ["derive"] }13serde = { workspace = true, features = ["derive"] }14serde_json.workspace = true14serde_json.workspace = true15thiserror.workspace = true15thiserror.workspace = trueremowt/crates/remowt-link-shared/src/gateway.rsdiffbeforeafterbothno changes
remowt/crates/remowt-ui-prompt/Cargo.tomldiffbeforeafterboth2name = "remowt-ui-prompt"2name = "remowt-ui-prompt"3description = "Interactive UI prompt endpoint for remowt (D-Bus)"3description = "Interactive UI prompt endpoint for remowt (D-Bus)"4version.workspace = true4version.workspace = true5edition = "2021"5edition.workspace = true6license.workspace = true6license.workspace = true778[dependencies]8[dependencies]9anyhow.workspace = true9anyhow.workspace = true10bifrostlink.workspace = true10bifrostlink.workspace = true11bifrostlink-macros.workspace = true11bifrostlink-macros.workspace = true12remowt-link-shared.workspace = true12serde.workspace = true13serde.workspace = true13thiserror.workspace = true14thiserror.workspace = true14tokio = { workspace = true, features = ["io-util", "macros", "process", "rt"] }15tokio = { workspace = true, features = ["io-util", "macros", "process", "rt"] }15tracing.workspace = true16tracing.workspace = true16zbus = { workspace = true, optional = true }1718[features]19default = ["dbus"]20dbus = ["dep:zbus"]2117remowt/crates/remowt-ui-prompt/src/auto.rsdiffbeforeafterboth1use anyhow::bail;1use std::path::Path;22use tracing::debug;3use bifrostlink::declarative::RemoteEndpoints as _;3use zbus::fdo::DBusProxy;4use remowt_link_shared::{Address, BifConfig, gateway};4use zbus::names::BusName;5use tracing::debug;566use crate::dbus::{DbusPrompterProxy, BUS_NAME, PROMPTER_PATH};7use crate::bifrost::PromptEndpointsClient;7use crate::rofi::RofiPrompter;8use crate::rofi::RofiPrompter;8use crate::{Prompter, Result, Source};9use crate::{Prompter, Result, Source};91010pub struct AutoPrompter {11pub struct AutoPrompter {11 dbus: Option<DbusPrompterProxy<'static>>,12 remote: Option<PromptEndpointsClient<BifConfig>>,12 fallback: RofiPrompter,13 fallback: RofiPrompter,13}14}141515impl AutoPrompter {16impl AutoPrompter {16 pub async fn new() -> Self {17 pub async fn new() -> Self {17 let dbus = match Self::try_dbus().await {18 let remote = match gateway::local_socket() {18 Ok(p) => Some(p),19 Ok(path) => Self::try_connect(&path).await,19 Err(e) => {20 Err(e) => {20 debug!("dbus prompter unavailable, falling back to rofi: {e}");21 debug!("no local gateway socket, falling back to rofi: {e}");21 None22 None22 }23 }23 };24 };24 Self {25 Self {25 dbus,26 remote,26 fallback: RofiPrompter,27 fallback: RofiPrompter,27 }28 }28 }29 }293030 async fn try_dbus() -> anyhow::Result<DbusPrompterProxy<'static>> {31 async fn try_connect(path: &Path) -> Option<PromptEndpointsClient<BifConfig>> {31 let conn = zbus::Connection::session().await?;32 match gateway::connect(path).await {32 let dbus = DBusProxy::new(&conn).await?;33 let name = BusName::try_from(BUS_NAME)?;34 if !dbus.name_has_owner(name).await? {33 Ok(rpc) => Some(PromptEndpointsClient::wrap(rpc.remote(Address::User))),34 Err(e) => {35 bail!("{BUS_NAME} not registered on session bus");35 debug!("local prompt agent unavailable, falling back to rofi: {e}");36 None36 }37 }37 let proxy = DbusPrompterProxy::builder(&conn)38 }38 .destination(BUS_NAME)?39 .path(PROMPTER_PATH)?40 .build()41 .await?;42 Ok(proxy)43 }39 }44}40}454151 variants: &[&str],47 variants: &[&str],52 source: &[Source],48 source: &[Source],53 ) -> Result<u32> {49 ) -> Result<u32> {54 if let Some(dbus) = &self.dbus {50 if let Some(remote) = &self.remote {55 return Prompter::prompt_enum(dbus, prompt, description, variants, source).await;51 return Prompter::prompt_enum(remote, prompt, description, variants, source).await;56 }52 }57 self.fallback53 self.fallback58 .prompt_enum(prompt, description, variants, source)54 .prompt_enum(prompt, description, variants, source)66 description: &str,62 description: &str,67 source: &[Source],63 source: &[Source],68 ) -> Result<String> {64 ) -> Result<String> {69 if let Some(dbus) = &self.dbus {65 if let Some(remote) = &self.remote {70 return Prompter::prompt_text(dbus, echo, prompt, description, source).await;66 return Prompter::prompt_text(remote, echo, prompt, description, source).await;71 }67 }72 self.fallback68 self.fallback73 .prompt_text(echo, prompt, description, source)69 .prompt_text(echo, prompt, description, source)74 .await70 .await75 }71 }767277 async fn display_text(&self, error: bool, description: &str, source: &[Source]) -> Result<()> {73 async fn display_text(&self, error: bool, description: &str, source: &[Source]) -> Result<()> {78 if let Some(dbus) = &self.dbus {74 if let Some(remote) = &self.remote {79 return Prompter::display_text(dbus, error, description, source).await;75 return Prompter::display_text(remote, error, description, source).await;80 }76 }81 self.fallback.display_text(error, description, source).await77 self.fallback.display_text(error, description, source).await82 }78 }remowt/crates/remowt-ui-prompt/src/dbus.rsdiffbeforeafterbothno changes
remowt/crates/remowt-ui-prompt/src/lib.rsdiffbeforeafterboth556pub mod auto;6pub mod auto;7pub mod bifrost;7pub mod bifrost;8pub mod dbus;9pub mod rofi;8pub mod rofi;10911#[derive(thiserror::Error, Debug, serde::Serialize, serde::Deserialize)]10#[derive(thiserror::Error, Debug, serde::Serialize, serde::Deserialize)]201921pub type Result<T, E = Error> = result::Result<T, E>;20pub type Result<T, E = Error> = result::Result<T, E>;222123#[cfg_attr(feature = "dbus", derive(zbus::zvariant::Type))]24#[derive(serde::Serialize, serde::Deserialize, Clone)]22#[derive(serde::Serialize, serde::Deserialize, Clone)]25pub struct Source(pub Cow<'static, str>);23pub struct Source(pub Cow<'static, str>);26impl fmt::Display for Source {24impl fmt::Display for Source {