No read from fifo device in snap packaged app

I use FIFO device file where data is written using some process, data write gives no denials but when i try to read from fifo file apparmor block it, is there a interface already to get the permission to do this ?

reproduction : snap install olivia-test
snap run olivia-test.olivia
add two tracks , play first track and wait for EOF of track (here mpv will give EOF signal as tracks ends i catch that signal by reading fifo file and send playnext command). here the eof signal is blocked from reading by apparmor (see debug of scanlog for denials)
debug : sudo scanlog
(in the source code of olivia radio.cpp is file where one might be interested to look)

What does the denial look like?

1 Like
= AppArmor =
    Time: Jul  3 04:01:32
    Log: apparmor="DENIED" operation="file_perm" profile="snap.olivia-test.olivia" name="/home/bulld/snap/olivia-test/114/.local/share/org.keshavnrj.ubuntu/Olivia/fifos/1562106609366.fifo" pid=21796 comm="socat" requested_mask="r" denied_mask="r" fsuid=1000 ouid=0
File: /home/bulld/snap/olivia-test/114/.local/share/org.keshavnrj.ubuntu/Olivia/fifos/1562106609366.fifo (read)

this is how the Denial look like

app runs perfectly fine in --devmode
i use socat to write data to fifo file and in non confined state the write gives me data i want, but if confined inside snap it refuses to read. I can confirm that i can write data to fifo (tested in other cases) but cannot read from it.

Are you trying to read from a user’s fifo as root?

Solved the issue by creating fifo file in /tmp directory instead of /home/user/snap/app/.local/share/

I’m glad you got this working, but for future reference, the reason why it didn’t is because the object uid (ouid) if the fifo did not match the fsuid (typically the same as the euid) of the process accessing the fifo. The home interface requires ‘owner’ match, so because fsuid!=ouid, the access was denied. /tmp doesn’t require owner match, so it worked.

As an aside, you may want to look into why your fifo was created by a root-owned process and if you want non-root processes to access it without some sort additional safeguards since while with what you have other snaps won’t be to access the fifo, other non-snap processes will.


thanks for describing it @jdstrand :slight_smile: but i didn’t wrote file with root . it was just mkfifo command. am still using the same command but the thing that i changed is the location of file. it was in home dir first and not its in /tmp .

Something did since its ouid was 0. Perhaps you used sudo at some point or an errant chmod?