Skip to content

Commit 6fbd126

Browse files
committed
feat: report process MAC labels
This will be useful for debugging process access rights once we start implementing SELinux Signed-off-by: Dmitry Sharshakov <dmitry.sharshakov@siderolabs.com>
1 parent d460328 commit 6fbd126

File tree

6 files changed

+1134
-1073
lines changed

6 files changed

+1134
-1073
lines changed

api/machine/machine.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ message ProcessInfo {
650650
string command = 8;
651651
string executable = 9;
652652
string args = 10;
653+
string label = 11;
653654
}
654655

655656
// rpc restart

cmd/talosctl/cmd/talos/processes.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func processesOutput(ctx context.Context, c *client.Client) (output string, err
190190

191191
s := []string{}
192192

193-
s = append(s, "NODE | PID | STATE | THREADS | CPU-TIME | VIRTMEM | RESMEM | COMMAND")
193+
s = append(s, "NODE | PID | STATE | THREADS | CPU-TIME | VIRTMEM | RESMEM | LABEL | COMMAND")
194194

195195
for _, msg := range resp.Messages {
196196
procs := msg.Processes
@@ -221,8 +221,8 @@ func processesOutput(ctx context.Context, c *client.Client) (output string, err
221221
}
222222

223223
s = append(s,
224-
fmt.Sprintf("%12s | %6d | %1s | %4d | %8.2f | %7s | %7s | %s",
225-
node, p.Pid, p.State, p.Threads, p.CpuTime, humanize.Bytes(p.VirtualMemory), humanize.Bytes(p.ResidentMemory), args))
224+
fmt.Sprintf("%12s | %6d | %1s | %4d | %8.2f | %7s | %7s | %64s | %s",
225+
node, p.Pid, p.State, p.Threads, p.CpuTime, humanize.Bytes(p.VirtualMemory), humanize.Bytes(p.ResidentMemory), p.Label, args))
226226
}
227227
}
228228

internal/pkg/miniprocfs/processes.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ func (procs *Processes) readProc(pidString string) (*machine.ProcessInfo, error)
161161
return nil, err
162162
}
163163

164+
var label string
165+
166+
if err = procs.readFileIntoBuf(path + "attr/current"); err == nil {
167+
label = string(bytes.TrimSpace(procs.buf))
168+
}
169+
164170
return &machine.ProcessInfo{
165171
Pid: int32(pid),
166172
Ppid: int32(ppid),
@@ -172,6 +178,7 @@ func (procs *Processes) readProc(pidString string) (*machine.ProcessInfo, error)
172178
Command: command,
173179
Executable: executable,
174180
Args: args,
181+
Label: label,
175182
}, nil
176183
}
177184

0 commit comments

Comments
 (0)