/usr/lib/firehol/functions.common is in firehol-common 3.1.5+ds-1ubuntu1.
This file is owned by root:root, with mode 0o644.
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | #
# Copyright
#
# Copyright (C) 2016-2017 Costa Tsaousis <costa@tsaousis.gr>
# Copyright (C) 2016-2017 Phil Whineray <phil@sanewall.org>
#
# See sbin/firehol.in for details
#
# This file contains functions used by the firehol suite.
# To keep the namespace clean, functions defined in functions.x.sh
# should be of the form x_whatever() if they are intended for general
# use or int_x_whatever() if they are intended as helpers to the other
# functions in the file.
#
common_require_cmd() {
local progname="$1" var="$2" val=
eval val=\$\{${var}\}
if [ "${val}" ]
then
return 0
fi
$CAT_CMD >&2 <<-__EOF__
ERROR: $progname feature requires $var
You have invoked the program requesting a feature which uses
a program which was not available when $progname was installed.
Please re-install $progname with a suitable command available.
__EOF__
exit 1
}
common_require_root() {
if [ "${UID}" != 0 ]
then
echo >&2
echo >&2 "ERROR:"
echo >&2 "Only user root can run ${1}"
echo >&2
return 1
fi
return 0
}
common_disable_localization() {
export LC_ALL=C
}
common_private_umask() {
# Make sure our generated files cannot be accessed by anyone else.
umask 077
}
common_public_umask() {
# let everyone read our status info
umask 022
}
common_setup_terminal() {
# Are stdout/stderr on the terminal? If not, then fail
test -t 2 || return 1
test -t 1 || return 1
if [ ! -z "$TPUT_CMD" ]
then
if [ $[$($TPUT_CMD colors 2>/dev/null)] -ge 8 ]
then
# Enable colors
COLOR_RESET="\e[0m"
COLOR_BLACK="\e[30m"
COLOR_RED="\e[31m"
COLOR_GREEN="\e[32m"
COLOR_YELLOW="\e[33m"
COLOR_BLUE="\e[34m"
COLOR_PURPLE="\e[35m"
COLOR_CYAN="\e[36m"
COLOR_WHITE="\e[37m"
COLOR_BGBLACK="\e[40m"
COLOR_BGRED="\e[41m"
COLOR_BGGREEN="\e[42m"
COLOR_BGYELLOW="\e[43m"
COLOR_BGBLUE="\e[44m"
COLOR_BGPURPLE="\e[45m"
COLOR_BGCYAN="\e[46m"
COLOR_BGWHITE="\e[47m"
COLOR_BOLD="\e[1m"
COLOR_DIM="\e[2m"
COLOR_UNDERLINED="\e[4m"
COLOR_BLINK="\e[5m"
COLOR_INVERTED="\e[7m"
fi
fi
return 0
}
|