Bad workaround for local appimage daemon
This commit is contained in:
parent
9a262a1243
commit
37fb4f4974
1 changed files with 16 additions and 11 deletions
|
|
@ -30,8 +30,8 @@ impl AsyncComponent for DaemonGroup {
|
||||||
#[name(group)]
|
#[name(group)]
|
||||||
adw::PreferencesGroup {
|
adw::PreferencesGroup {
|
||||||
#[watch]
|
#[watch]
|
||||||
set_sensitive:
|
set_sensitive:
|
||||||
(model.system_setup == SystemSetup::AppImage || model.system_setup == SystemSetup::Other) &&
|
(model.system_setup == SystemSetup::AppImage || model.system_setup == SystemSetup::Other) &&
|
||||||
!model.already_running,
|
!model.already_running,
|
||||||
set_title: "Local Daemon",
|
set_title: "Local Daemon",
|
||||||
set_description: Some("Run Local Daemon"),
|
set_description: Some("Run Local Daemon"),
|
||||||
|
|
@ -68,27 +68,32 @@ impl AsyncComponent for DaemonGroup {
|
||||||
) {
|
) {
|
||||||
match msg {
|
match msg {
|
||||||
DaemonGroupMsg::LaunchLocal => {
|
DaemonGroupMsg::LaunchLocal => {
|
||||||
|
// TODO: Handle error condition
|
||||||
|
|
||||||
|
const BURROW_LOCAL_DAEMON_PATH: &str = "/tmp/burrow-detached-daemon";
|
||||||
|
|
||||||
let burrow_original_bin = std::env::vars()
|
let burrow_original_bin = std::env::vars()
|
||||||
.find(|(k, _)| k == "APPDIR")
|
.find(|(k, _)| k == "APPDIR")
|
||||||
.map(|(_, v)| v + "/usr/bin/burrow")
|
.map(|(_, v)| v + "/usr/bin/burrow")
|
||||||
.unwrap_or("/usr/bin/burrow".to_owned());
|
.unwrap_or("/usr/bin/burrow".to_owned());
|
||||||
|
|
||||||
|
Command::new("cp")
|
||||||
|
.arg(&burrow_original_bin)
|
||||||
|
.arg(BURROW_LOCAL_DAEMON_PATH)
|
||||||
|
.output()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let mut burrow_bin =
|
let mut burrow_bin =
|
||||||
String::from_utf8(Command::new("mktemp").output().unwrap().stdout).unwrap();
|
String::from_utf8(Command::new("mktemp").output().unwrap().stdout).unwrap();
|
||||||
burrow_bin.pop();
|
burrow_bin.pop();
|
||||||
|
|
||||||
let privileged_spawn_script = format!(
|
let privileged_spawn_script = format!(
|
||||||
r#"TEMP=$(mktemp -p /root)
|
r#"chmod +x {}
|
||||||
cp {} $TEMP
|
setcap CAP_NET_BIND_SERVICE,CAP_NET_ADMIN+eip {}"#,
|
||||||
chmod +x $TEMP
|
BURROW_LOCAL_DAEMON_PATH, BURROW_LOCAL_DAEMON_PATH
|
||||||
setcap CAP_NET_BIND_SERVICE,CAP_NET_ADMIN+eip $TEMP
|
|
||||||
mv $TEMP /tmp/burrow-detached-daemon"#,
|
|
||||||
burrow_original_bin
|
|
||||||
)
|
)
|
||||||
.replace('\n', "&&");
|
.replace('\n', "&&");
|
||||||
|
|
||||||
// TODO: Handle error condition
|
|
||||||
|
|
||||||
Command::new("pkexec")
|
Command::new("pkexec")
|
||||||
.arg("sh")
|
.arg("sh")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
|
|
@ -97,7 +102,7 @@ mv $TEMP /tmp/burrow-detached-daemon"#,
|
||||||
.output()
|
.output()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
Command::new("/tmp/burrow-detached-daemon")
|
Command::new(BURROW_LOCAL_DAEMON_PATH)
|
||||||
.env("RUST_LOG", "debug")
|
.env("RUST_LOG", "debug")
|
||||||
.arg("daemon")
|
.arg("daemon")
|
||||||
.spawn()
|
.spawn()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue