Skip to content

Commit 555650b

Browse files
committed
Bad workaround for local appimage daemon
1 parent f7236bd commit 555650b

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

burrow-gtk/src/components/settings/daemon_group.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ impl AsyncComponent for DaemonGroup {
3030
#[name(group)]
3131
adw::PreferencesGroup {
3232
#[watch]
33-
set_sensitive:
34-
(model.system_setup == SystemSetup::AppImage || model.system_setup == SystemSetup::Other) &&
33+
set_sensitive:
34+
(model.system_setup == SystemSetup::AppImage || model.system_setup == SystemSetup::Other) &&
3535
!model.already_running,
3636
set_title: "Local Daemon",
3737
set_description: Some("Run Local Daemon"),
@@ -68,27 +68,32 @@ impl AsyncComponent for DaemonGroup {
6868
) {
6969
match msg {
7070
DaemonGroupMsg::LaunchLocal => {
71+
// TODO: Handle error condition
72+
73+
const BURROW_LOCAL_DAEMON_PATH: &str = "/tmp/burrow-detached-daemon";
74+
7175
let burrow_original_bin = std::env::vars()
7276
.find(|(k, _)| k == "APPDIR")
7377
.map(|(_, v)| v + "/usr/bin/burrow")
7478
.unwrap_or("/usr/bin/burrow".to_owned());
7579

80+
Command::new("cp")
81+
.arg(&burrow_original_bin)
82+
.arg(BURROW_LOCAL_DAEMON_PATH)
83+
.output()
84+
.unwrap();
85+
7686
let mut burrow_bin =
7787
String::from_utf8(Command::new("mktemp").output().unwrap().stdout).unwrap();
7888
burrow_bin.pop();
7989

8090
let privileged_spawn_script = format!(
81-
r#"TEMP=$(mktemp -p /root)
82-
cp {} $TEMP
83-
chmod +x $TEMP
84-
setcap CAP_NET_BIND_SERVICE,CAP_NET_ADMIN+eip $TEMP
85-
mv $TEMP /tmp/burrow-detached-daemon"#,
86-
burrow_original_bin
91+
r#"chmod +x {}
92+
setcap CAP_NET_BIND_SERVICE,CAP_NET_ADMIN+eip {}"#,
93+
BURROW_LOCAL_DAEMON_PATH, BURROW_LOCAL_DAEMON_PATH
8794
)
8895
.replace('\n', "&&");
8996

90-
// TODO: Handle error condition
91-
9297
Command::new("pkexec")
9398
.arg("sh")
9499
.arg("-c")
@@ -97,7 +102,7 @@ mv $TEMP /tmp/burrow-detached-daemon"#,
97102
.output()
98103
.unwrap();
99104

100-
Command::new("/tmp/burrow-detached-daemon")
105+
Command::new(BURROW_LOCAL_DAEMON_PATH)
101106
.env("RUST_LOG", "debug")
102107
.arg("daemon")
103108
.spawn()

0 commit comments

Comments
 (0)