/lib/udev/snappy-app-dev is in ubuntu-core-launcher 1.0.27.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #!/bin/sh
# udev callout (should live in /lib/udev) to allow a snap to access a device node
set -e
# debugging
#exec >>/tmp/snappy-app-dev.log
#exec 2>&1
#set -x
# end debugging
ACTION="$1"
APPNAME="$2"
DEVPATH="$3"
MAJMIN="$4"
[ -n "$APPNAME" ] || { echo "no app name given" >&2; exit 1; }
[ -n "$DEVPATH" ] || { echo "no devpath given" >&2; exit 1; }
[ -n "$MAJMIN" ] || { echo "no major/minor given" >&2; exit 0; }
APPNAME=`echo $APPNAME | tr '_' '.'`
app_dev_cgroup="/sys/fs/cgroup/devices/$APPNAME"
# check if it's a block or char dev
if [ "${DEVPATH#*/block/}" != "$DEVPATH" ]; then
type="b"
else
type="c"
fi
acl="$type $MAJMIN rwm"
case "$ACTION" in
add|change)
echo "$acl" > "$app_dev_cgroup/devices.allow"
;;
remove)
echo "$acl" > "$app_dev_cgroup/devices.deny"
;;
*)
echo "ERROR: unknown action $ACTION" >&2
exit 1 ;;
esac
|