Great! I’m not alone here!
libcomposite-support would be the simplest solution here.
Still as I understand you propose to divide one
libcomposite interface into more specific use cases and add to the existing ones. It’s interesting but I’m not sure how to achieve that.
Apparmor should catch the difference between:
Where “gadget” is arbitrary name for gadget (g1, g2 … etc) and the last “name” also (0, 1, usb0, usb1).
That said you will end up with:
Apparmor should decide whether to allow particular $FUNCTION_NAME for a particular snap.
Still allowing to access for every snap with libcomposite to:
And of course it should be possible to mkdir $GADGET_NAME and write to UDC, idVendor, idProduct in it.
Nowadays I’m interested in uac1, uac2 which could go into alsa interface (as it creates a new alsa sound card).
And HID. It can go to hidraw interface as you mentioned.
Serial port “gser” could go to serial-port maybe? It could be a separate simple snap maintained by @ogra that simply configures one serial port /dev/ttyGS0 with libcomposite and nothing more. Some snap configuration may allow to add several additional ports if user wants. This snap can be installed by those users who needs this functionality or added by --extra-snaps in ubuntu-image to make it available from the very beginning.