F #165: Safety checks for TZ data file location

pull/188/head
Vlastimil Holer 5 years ago
parent 4e6abbb589
commit d5419bd2aa
No known key found for this signature in database
GPG Key ID: EB549BADEFD07C53

@ -21,8 +21,16 @@ if [ -z "${TIMEZONE}" ]; then
fi
if ! timedatectl set-timezone "${TIMEZONE}" 2>/dev/null; then
if [ -f "/usr/share/zoneinfo/${TIMEZONE}" ]; then
ln -sf "/usr/share/zoneinfo/${TIMEZONE}" /etc/localtime
_tz_base='/usr/share/zoneinfo/'
_tz_dest=$(realpath "${_tz_base}${TIMEZONE}" 2>/dev/null)
# if timezone file path is resolvable file and
# real path is inside the timezone directory
if [ -n "${_tz_dest}" ] &&
[ -f "${_tz_dest}" ] &&
[[ "${_tz_dest}" =~ ^${_tz_base} ]];
then
ln -sf "${_tz_dest}" /etc/localtime
else
echo "ERROR: Invalid timezone '${TIMEZONE}'" >&2
exit 1

Loading…
Cancel
Save