feat(profile): add lslocks

This commit is contained in:
Alexandre Pujol 2025-07-20 14:55:36 +02:00
parent 601e5ab35c
commit d5044ff328
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
2 changed files with 55 additions and 0 deletions

View file

@ -0,0 +1,33 @@
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2025 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
abi <abi/4.0>,
include <tunables/global>
@{exec_path} = @{bin}/lslocks
profile lslocks @{exec_path} flags=(attach_disconnected) {
include <abstractions/base>
capability dac_read_search,
capability sys_ptrace,
ptrace read,
@{exec_path} mr,
@{PROC}/ r,
@{PROC}/@{pid}/ r,
@{PROC}/@{pid}/comm r,
@{PROC}/@{pid}/fd/ r,
@{PROC}/@{pid}/fdinfo/ r,
@{PROC}/@{pid}/fdinfo/@{int} r,
@{PROC}/locks r,
owner @{PROC}/@{pid}/ r,
owner @{PROC}/@{pid}/mountinfo r,
include if exists <local/lslocks>
}
# vim:syntax=apparmor

View file

@ -0,0 +1,22 @@
#!/usr/bin/env bats
# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only
load ../common
@test "lslocks: List all local system locks" {
sudo lslocks
}
@test "lslocks: List locks producing a raw output (no columns), and without column headers" {
sudo lslocks --raw --noheadings
}
@test "lslocks: List locks by PID input" {
sudo lslocks --pid "$(sudo lslocks --raw --noheadings --output PID | head -1)"
}
@test "lslocks: List locks with JSON output to stdout" {
lslocks --json
}