From 28e6cfbff8f195bc3bfbf726eea88f463cfe2805 Mon Sep 17 00:00:00 2001 From: Itxaka Date: Wed, 15 Feb 2023 10:53:48 +0100 Subject: [PATCH] Do not do anything if rd.cos.disable its on the cmdline That means we dont want to run any immutable stuff, for netboot and cdrom Signed-off-by: Itxaka --- internal/cmd/commands.go | 12 +++++++++--- internal/utils/common.go | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/internal/cmd/commands.go b/internal/cmd/commands.go index d66060e..3c1eca2 100644 --- a/internal/cmd/commands.go +++ b/internal/cmd/commands.go @@ -39,7 +39,13 @@ Sends a generic event payload with the configuration found in the scanned direct zerolog.SetGlobalLevel(zerolog.DebugLevel) } - // First set the sentinel file + // You can pass rd.cos.disable in the cmdline to disable the whole immutable stuff + if len(utils.ReadCMDLineArg("rd.cos.disable")) > 0 { + log.Logger.Info().Msg("Stanza rd.cos.disable on the cmdline. Doing nothing.") + return nil + } + + // First set the sentinel file. if !c.Bool("dry-run") { err = utils.SetSentinelFile() if err != nil { @@ -48,8 +54,7 @@ Sends a generic event payload with the configuration found in the scanned direct } } - // If we boot from CD, we do nothing - cdBoot, err := utils.BootedFromCD() + cdBoot, err := utils.BootedFromLiveMedia() if err != nil { log.Logger.Err(err).Send() return err @@ -57,6 +62,7 @@ Sends a generic event payload with the configuration found in the scanned direct img := utils.ReadCMDLineArg("cos-img/filename=") if len(img) == 0 { + // If we boot from LIVE media or are using dry-run, we use a fake img as we still want to do things if c.Bool("dry-run") || cdBoot { img = []string{"fake"} } else { diff --git a/internal/utils/common.go b/internal/utils/common.go index 6986e76..b3e2885 100644 --- a/internal/utils/common.go +++ b/internal/utils/common.go @@ -8,8 +8,8 @@ import ( "strings" ) -// BootedFromCD tells us if we are currently runnig of the LiveCD -func BootedFromCD() (bool, error) { +// BootedFromLiveMedia tells us if we are currently running off LIVE media like cd/usb or netboot +func BootedFromLiveMedia() (bool, error) { runtime, err := state.NewRuntime() if err != nil { return false, err @@ -151,4 +151,4 @@ func SetSentinelFile() error { return err } return nil -} \ No newline at end of file +}