MCPcopy Create free account
hub / github.com/evilsocket/shellz / runEnable

Function runEnable

cmd/shellz/enable.go:7–30  ·  view source on GitHub ↗
(filter string, enable bool)

Source from the content-addressed store, hash-verified

5)
6
7func runEnable(filter string, enable bool) {
8 if err, onShells = doShellSelection(filter, true); err != nil {
9 log.Fatal("%s", err)
10 } else if nShells = len(onShells); nShells == 0 {
11 log.Fatal("no shell selected by the filter %s", filter)
12 }
13
14 word := "enabled"
15 if !enable {
16 word = "disabled"
17 }
18 for _, shell := range onShells {
19 if shell.Enabled == enable {
20 log.Debug("shell %s already %s", shell.Name, word)
21 } else {
22 shell.Enabled = enable
23 if err := shell.Save(); err != nil {
24 log.Error("error while setting shell %s to %s: %s", shell.Name, word, err)
25 } else {
26 log.Info("shell %s successfully %s", shell.Name, word)
27 }
28 }
29 }
30}

Callers 1

mainFunction · 0.85

Calls 5

doShellSelectionFunction · 0.85
DebugMethod · 0.80
SaveMethod · 0.80
ErrorMethod · 0.80
InfoMethod · 0.80

Tested by

no test coverage detected