__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
#!/bin/bash
set -e
set +x
STATIC_SNAP_MOUNT_DIR="/snap"
show_help() {
exec cat <<'EOF'
Usage: snap-mgmt-selinux.sh [OPTIONS]
A helper script to manage SELinux contexts used by snapd
Arguments:
--snap-mount-dir=<path> Provide a path to be used as $STATIC_SNAP_MOUNT_DIR
--patch-selinux-mount-context=<context> Add SELinux context to mount units
--remove-selinux-mount-context=<context> Remove SELinux context from mount units
EOF
}
SNAP_UNIT_PREFIX="$(systemd-escape -p ${STATIC_SNAP_MOUNT_DIR})"
patch_selinux_mount_context() {
if ! command -v selinuxenabled > /dev/null; then
return
fi
if ! selinuxenabled; then
# The tools are there, but SELinux is not enabled
return
fi
selinux_mount_context="$1"
remove="$2"
if ! echo "$selinux_mount_context" | grep -qE '[a-zA-Z0-9_]+(:[a-zA-Z0-9_]+){2,3}'; then
echo "invalid mount context '$selinux_mount_context'"
exit 1
fi
context_opt="context=$selinux_mount_context"
mounts=$(systemctl list-unit-files --no-legend --full "$SNAP_UNIT_PREFIX-*.mount" | cut -f1 -d ' ' || true)
changed_mounts=
for unit in $mounts; do
# Ensure its really a snap mount unit or systemd unit
if ! grep -q 'What=/var/lib/snapd/snaps/' "/etc/systemd/system/$unit" && ! grep -q 'X-Snappy=yes' "/etc/systemd/system/$unit"; then
echo "Skipping non-snapd systemd unit $unit"
continue
fi
if [ "$remove" == "" ]; then
if grep -q "Options=.*,$context_opt" < "/etc/systemd/system/$unit"; then
# already patched
continue
fi
if ! sed -i -e "s#^\\(Options=nodev.*\\)#\\1,$context_opt#" "/etc/systemd/system/$unit"; then
echo "Cannot patch $unit"
fi
changed_mounts="$changed_mounts $unit"
elif [ "$remove" == "remove" ]; then
if ! grep -q "Options=.*,$context_opt" < "/etc/systemd/system/$unit"; then
# Not patched
continue
fi
if ! sed -i -e "s#^\\(Options=nodev.*\\),$context_opt\\(,.*\\)\\?#\\1\\2#" "/etc/systemd/system/$unit"; then
echo "Cannot patch $unit"
fi
changed_mounts="$changed_mounts $unit"
fi
done
if [ -z "$changed_mounts" ]; then
# Nothing changed, no need to reload
return
fi
systemctl daemon-reload
for unit in $changed_mounts; do
if ! systemctl try-restart "$unit" ; then
echo "Cannot restart $unit"
fi
done
}
while [ -n "$1" ]; do
case "$1" in
--help)
show_help
exit
;;
--snap-mount-dir=*)
STATIC_SNAP_MOUNT_DIR=${1#*=}
SNAP_UNIT_PREFIX=$(systemd-escape -p "$STATIC_SNAP_MOUNT_DIR")
shift
;;
--patch-selinux-mount-context=*)
patch_selinux_mount_context "${1#*=}"
shift
;;
--remove-selinux-mount-context=*)
patch_selinux_mount_context "${1#*=}" remove
shift
;;
*)
echo "Unknown command: $1"
exit 1
;;
esac
done
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| apparmor | Folder | 0755 |
|
|
| apparmor.d | Folder | 0755 |
|
|
| apparmor_parser | File | 1.59 MB | 0755 |
|
| complete.sh | File | 5.27 KB | 0644 |
|
| etelpmoc.sh | File | 6.87 KB | 0644 |
|
| info | File | 116 B | 0644 |
|
| preseed.json | File | 841 B | 0644 |
|
| snap-bootstrap | File | 12.52 MB | 0755 |
|
| snap-confine | File | 205.13 KB | 0755 |
|
| snap-confine.caps | File | 126 B | 0644 |
|
| snap-confine.v2-only.caps | File | 104 B | 0644 |
|
| snap-debug-info.sh | File | 2.28 KB | 0755 |
|
| snap-device-helper | File | 61.94 KB | 0755 |
|
| snap-discard-ns | File | 45.92 KB | 0755 |
|
| snap-exec | File | 5.16 MB | 0755 |
|
| snap-failure | File | 3.04 MB | 0755 |
|
| snap-fde-keymgr | File | 4.87 MB | 0755 |
|
| snap-gdbserver-shim | File | 1.01 MB | 0755 |
|
| snap-gpio-helper | File | 2.9 MB | 0755 |
|
| snap-mgmt | File | 9.86 KB | 0755 |
|
| snap-mgmt-selinux | File | 3.19 KB | 0755 |
|
| snap-preseed | File | 10.87 MB | 0755 |
|
| snap-recovery-chooser | File | 8.73 MB | 0755 |
|
| snap-repair | File | 8.11 MB | 0755 |
|
| snap-seccomp | File | 2.8 MB | 0755 |
|
| snap-strace-shim | File | 33.47 KB | 0755 |
|
| snap-update-ns | File | 6.18 MB | 0755 |
|
| snapctl | File | 7.8 MB | 0755 |
|
| snapd | File | 28.8 MB | 0755 |
|
| snapd-apparmor | File | 2.54 MB | 0755 |
|
| snapd.core-fixup.sh | File | 3.74 KB | 0755 |
|
| snapd.run-from-snap | File | 73 B | 0755 |
|
| system-shutdown | File | 37.68 KB | 0755 |
|