aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-03-31 04:41:08 +0900
committerOphestra <cat@gensokyo.uk>2025-03-31 04:41:08 +0900
commitecdd4d820296162c273c3344f844cf78af0e4426 (patch)
tree41df1eab24f67816ad07be9ddd3a687ee264fe32
parentbdee0c3921c05a9f1286e09ffb7f602f6b316694 (diff)
fortify: clean ps output
This format never changed ever since it was added. It used to show everything there is in a process state but that is no longer true for a long time. This change cleans it up in favour of `fortify show` displaying extra information. Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--print.go18
-rw-r--r--print_test.go14
2 files changed, 12 insertions, 20 deletions
diff --git a/print.go b/print.go
index 7c6663bd..891c576b 100644
--- a/print.go
+++ b/print.go
@@ -247,22 +247,18 @@ func printPs(output io.Writer, now time.Time, s state.Store, short, flagJSON boo
t := newPrinter(output)
defer t.MustFlush()
- t.Println("\tInstance\tPID\tApp\tUptime\tEnablements\tCommand")
+ t.Println("\tInstance\tPID\tApplication\tUptime")
for _, e := range exp {
- var (
- es = "(No confinement information)"
- cs = "(No command information)"
- as = "(No configuration information)"
- )
+ as := "(No configuration information)"
if e.Config != nil {
- es = e.Config.Confinement.Enablements.String()
- cs = fmt.Sprintf("%q", e.Config.Args)
as = strconv.Itoa(e.Config.Confinement.AppID)
+ if e.Config.ID != "" {
+ as += " (" + e.Config.ID + ")"
+ }
}
- t.Printf("\t%s\t%d\t%s\t%s\t%s\t%s\n",
- e.s[:8], e.PID, as, now.Sub(e.Time).Round(time.Second).String(), strings.TrimPrefix(es, ", "), cs)
+ t.Printf("\t%s\t%d\t%s\t%s\n",
+ e.s[:8], e.PID, as, now.Sub(e.Time).Round(time.Second).String())
}
- t.Println()
}
type expandedStateEntry struct {
diff --git a/print_test.go b/print_test.go
index addeb604..d892e55f 100644
--- a/print_test.go
+++ b/print_test.go
@@ -458,20 +458,16 @@ func Test_printPs(t *testing.T) {
short, json bool
want string
}{
- {"no entries", make(state.Entries), false, false, ` Instance PID App Uptime Enablements Command
-
+ {"no entries", make(state.Entries), false, false, ` Instance PID Application Uptime
`},
{"no entries short", make(state.Entries), true, false, ``},
- {"nil instance", state.Entries{testID: nil}, false, false, ` Instance PID App Uptime Enablements Command
-
+ {"nil instance", state.Entries{testID: nil}, false, false, ` Instance PID Application Uptime
`},
- {"state corruption", state.Entries{fst.ID{}: testState}, false, false, ` Instance PID App Uptime Enablements Command
-
+ {"state corruption", state.Entries{fst.ID{}: testState}, false, false, ` Instance PID Application Uptime
`},
- {"valid", state.Entries{testID: testState}, false, false, ` Instance PID App Uptime Enablements Command
- 8e2c76b0 3735928559 9 1h2m32s wayland, dbus, pulseaudio ["chromium" "--ignore-gpu-blocklist" "--disable-smooth-scrolling" "--enable-features=UseOzonePlatform" "--ozone-platform=wayland"]
-
+ {"valid", state.Entries{testID: testState}, false, false, ` Instance PID Application Uptime
+ 8e2c76b0 3735928559 9 (org.chromium.Chromium) 1h2m32s
`},
{"valid short", state.Entries{testID: testState}, true, false, `8e2c76b0
`},