Currently looking for an interface which would give me access to read/write to
/dev/tty[0-9]+ to either just present information or even run a “Console UI” in one of the tty consoles.
Below just demonstrate an attempt to write to “/dev/tty2” within a snap.
Test Script
#!/bin/bash
echo -ne "TEST CONTENT\n" > /dev/tty2
Looking in the source of snapd i noticed that “ppp”
seems like the best option to be able to access the /dev/tty[0-9]+
but also tried ofono,waylan,x11 and modem-manager since they have apparmor profiles related to /dev/tty[0-9].
$ snap interfaces testapp
Slot Plug
:modem-manager testapp
:ofono testapp
:ppp testapp
:wayland testapp
:x11 testapp
- testapp:mir
Above test script works in classic/devmode but not in strict mode.
I tested this both on a Ubuntu Server 18 and Ubuntu Core 18 Gadget.
Tested this on “Ubuntu Server 18” only to be able to get the feedback from "snappy-debug.secuirty scanlog ".
snappy-debug output during execution
= AppArmor =
...
Log: apparmor="ALLOWED" operation="open" profile="snap.testapp.testapp" name="/dev/tty2" pid=9941 comm="testapp" requested_mask="wc" denied_mask="wc" fsuid=0 ouid=0
File: /dev/tty2 (write)
Suggestion:
* add 'serial-port (with gadget or core support)' to 'plugs'
Added serial-port interface in my Gadget Snap + Testapp in the same way as I do when I need access to
serial interfaces /dev/ttyS[0-9]+.
Gadget Snap
############
gadget.yaml
...
connections:
- plug: <snap id>:serial-port
slot: <gadget snap id>:serialtty-0
- plug: <snap id>:serial-port
slot: <gadget snap id>:tty-2
snapcraft.yaml
...
slots:
serialtty-0:
interface: serial-port
path: /dev/ttyS0
tty-2:
interface: serial-port
path: /dev/tty2
...
But I’m still unable give the snap access to one of the tty console, in this case /dev/tty2 (tty-2).
$ snap interfaces testgadget
Slot Plug
testgadget:serialtty-0 testapp:testgadget
$sudo journalctl -u snap.testapp.testapp -f
testapp.testapp[3768]: /snap/testapp/x1/usr/bin/testapp: line 2: /dev/tty2: Operation not permitted
Does snapd provide any interface to similar to serial-port but for “dev/tty[0-9]”?