feat(profile): add lslocks
This commit is contained in:
parent
f516e1140a
commit
926a6fdcb9
2 changed files with 55 additions and 0 deletions
33
apparmor.d/groups/utils/lslocks
Normal file
33
apparmor.d/groups/utils/lslocks
Normal 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
|
||||||
22
tests/integration/utils/lslocks.bats
Normal file
22
tests/integration/utils/lslocks.bats
Normal 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
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue