File opera.sh.in of Package opera.17654
#!/bin/bash
# Authors:
# Sorokin Alexei <sor.alexei@meowr.ru>
# Fabien Tassin <fta@sofaraway.org>
# Licence: GPLv2+
PROGNAME="opera"
LIBDIR="__LIBDIR__/$PROGNAME"
SANDBOX_FILE="$LIBDIR/${PROGNAME}_sandbox"
# Allow users to override command-line options.
# Based on Gentoo's chromium package (and by extension, Debian's).
if [ -r "__SYSCONFDIR__/default/$PROGNAME" ]; then
. "__SYSCONFDIR__/default/$PROGNAME"
fi
# Prefer user defined OPERA_USER_FLAGS (from env) over system
# default OPERA_FLAGS (from /etc/default/opera).
OPERA_FLAGS="${OPERA_USER_FLAGS:-$OPERA_FLAGS}"
# Check if CLONE_NEWUSER exists (setuid sandboxing is required).
if [ ! -f "/proc/$$/ns/user" ]; then
REQUIRE_SETUID_SANDBOX=1
else
REQUIRE_SETUID_SANDBOX=
fi
# Check if sandbox binary has a setuid flag.
if [[ "$(stat -c '%a %u:%g' "$SANDBOX_FILE")" == '4755 0:0' ]]; then
HAS_SETUID_SANDBOX=1
else
HAS_SETUID_SANDBOX=
fi
# SUID sandboxing is required but does not exist. Let's try and fix it.
if [ -n "$REQUIRE_SETUID_SANDBOX" ] && [ -z "$HAS_SETUID_SANDBOX" ]; then
if [[ "$OPERA_FLAGS" =~ '--sandbox' ]]; then
if ( ! which xdg-su &> /dev/null ) || \
( ! xdg-su -c "chmod 4755 "$SANDBOX_FILE"; chown 0:0 "$SANDBOX_FILE"" &> /dev/null ); then
echo "Permission granting failed, falling back to disabled sandboxing." >&2
OPERA_FLAGS="$OPERA_FLAGS --no-sandbox"
fi
else
OPERA_FLAGS="$OPERA_FLAGS --no-sandbox"
fi
fi
exec "$LIBDIR/$PROGNAME" $SANDBOX $CHROMIUM_FLAGS $OPERA_FLAGS "$@"