Trying to get through the apparmor documentation and try some sample
profile.

I have in file `/etc/apparmor.d/_testing` this trivial testing profile:

    #include <tunables/global>

    profile mc-test /usr/bin/cat flags=(enforce){
      #include <abstractions/base>
      #include <abstractions/nameservice>
      #include <abstractions/kde>

      audit deny /home/mmucha/test-file rwkl,
      audit deny /home/mmucha/test-file am,
    }

I realoded the file using:

    sudo apparmor_parser -r _testing

Create sample file:

    echo "sdfsdfs" > /home/mmucha/test-file

If I invoke it as:

    sudo aa-exec -p mc-test -- /usr/bin/cat /home/mmucha/test-file
    [sudo: authenticate] Password:
    cat: /home/mmucha/test-file: Permission denied

with log:

    lis 09 10:02:14 vbDesktop2 kernel: audit: type=1400
audit(1794214934.727:336): apparmor="DENIED" operation="capable"
class="cap" profile="mc-test" pid=1181401 comm="cat" capability=2
 capname="dac_read_search"
    lis 09 10:02:14 vbDesktop2 kernel: audit: type=1400
audit(1794214934.727:337): apparmor="DENIED" operation="capable"
class="cap" profile="mc-test" pid=1181401 comm="cat" capability=1
 capname="dac_override"


now lets try invoke it normally:

    cat test-file
    sdfsdfs
    /usr/bin/cat /home/mmucha/test-file
    sdfsdfs

2x success, no audit logs, not too cool.

Lets try this:

    /usr/bin/cat /home/mmucha/test-file & PID=$!;cat
/proc/$PID/attr/apparmor/current;wait $PID
    [1] 1181581
    unconfined
    sdfsdfs

**What is going on? We're literally have to match /usr/bin/cat to
/usr/bin/cat which should not be a problem.**

Can someone explain what is wrong? Maybe I missed something?

kernel:

    uname -r
    7.1.13-tkg-eevdf

same with

    7.0.0-42-generic

distro:

    DISTRIB_ID=Ubuntu
    DISTRIB_RELEASE=26.04
    DISTRIB_CODENAME=resolute
    DISTRIB_DESCRIPTION="Ubuntu 26.04.1 LTS"

Reply via email to