aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra Umiker <cat@ophivana.moe>2024-10-13 12:09:38 +0900
committerOphestra Umiker <cat@ophivana.moe>2024-10-13 12:09:38 +0900
commitb47094191145277319b81feb6d1a7f0e3e20b906 (patch)
tree55770baea2b1166e1d8c0ad9a730318c6fee3d8a
parente4536b87ad5bc23096eab00f17ac55b7aad23996 (diff)
shim: get rid of insane launch condition
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
-rw-r--r--internal/app/launch.machinectl.go4
-rw-r--r--internal/app/launch.sudo.go2
-rw-r--r--internal/shim/main.go11
-rw-r--r--internal/shim/parent.go8
-rw-r--r--main.go6
5 files changed, 16 insertions, 15 deletions
diff --git a/internal/app/launch.machinectl.go b/internal/app/launch.machinectl.go
index 59efd553..9fb9ea0b 100644
--- a/internal/app/launch.machinectl.go
+++ b/internal/app/launch.machinectl.go
@@ -57,8 +57,8 @@ func (a *app) commandBuilderMachineCtl(shimEnv string) (args []string) {
}
}
- // both license and version flags need to be set to activate shim path
- innerCommand.WriteString("exec " + a.seal.sys.executable + " -V -license")
+ // launch fortify as shim
+ innerCommand.WriteString("exec " + a.seal.sys.executable + " shim")
// append inner command
args = append(args, innerCommand.String())
diff --git a/internal/app/launch.sudo.go b/internal/app/launch.sudo.go
index 777cb2a7..3e364ace 100644
--- a/internal/app/launch.sudo.go
+++ b/internal/app/launch.sudo.go
@@ -26,7 +26,7 @@ func (a *app) commandBuilderSudo(shimEnv string) (args []string) {
args = append(args, shimEnv)
// -- $@
- args = append(args, "--", a.seal.sys.executable, "-V", "--license") // magic for shim.Try()
+ args = append(args, "--", a.seal.sys.executable, "shim")
return
}
diff --git a/internal/shim/main.go b/internal/shim/main.go
index f9cf0386..e5bca6fd 100644
--- a/internal/shim/main.go
+++ b/internal/shim/main.go
@@ -3,6 +3,7 @@ package shim
import (
"encoding/gob"
"errors"
+ "flag"
"fmt"
"net"
"os"
@@ -148,3 +149,13 @@ func receiveWLfd(conn *net.UnixConn) (int, error) {
return fds[0], nil
}
}
+
+// Try runs shim and stops execution if FORTIFY_SHIM is set.
+func Try() {
+ if args := flag.Args(); len(args) == 1 && args[0] == "shim" {
+ if s, ok := os.LookupEnv(EnvShim); ok {
+ shim(s)
+ panic("unreachable")
+ }
+ }
+}
diff --git a/internal/shim/parent.go b/internal/shim/parent.go
index 7ffc1c41..98856555 100644
--- a/internal/shim/parent.go
+++ b/internal/shim/parent.go
@@ -80,11 +80,3 @@ func ServeConfig(socket string, payload *Payload, wl string, done chan struct{})
return ws, nil
}
}
-
-// Try runs shim and stops execution if FORTIFY_SHIM is set.
-func Try() {
- if s, ok := os.LookupEnv(EnvShim); ok {
- shim(s)
- }
- panic("unreachable")
-}
diff --git a/main.go b/main.go
index 896f7aa4..b0558c15 100644
--- a/main.go
+++ b/main.go
@@ -35,10 +35,8 @@ func main() {
verbose.Println("system booted with systemd as init system")
}
- // launcher payload early exit
- if printVersion && printLicense {
- shim.Try()
- }
+ // shim early exit
+ shim.Try()
// version/license/template command early exit
tryVersion()