Commit 0d8ad1b4 authored by Franco Fichtner's avatar Franco Fichtner

share: remove and rework timezone info

Now use the base system's tzdata, which we update regularly...
parent 2d257557
......@@ -1270,7 +1270,8 @@ EOD;
}
function system_timezone_configure() {
function system_timezone_configure()
{
global $config, $g;
if(isset($config['system']['developerspew'])) {
$mt = microtime();
......@@ -1284,23 +1285,19 @@ function system_timezone_configure() {
/* extract appropriate timezone file */
$timezone = $syscfg['timezone'];
if ($timezone) {
exec('/usr/bin/tar -tvzf /usr/share/zoneinfo.tgz', $tzs);
foreach ($tzs as $tz) {
if (preg_match(",{$timezone}$,", $tz))
break;
if (preg_match(",{$timezone} link to *(.*)$,", $tz, $matches)) {
$timezone = $matches[1];
break;
}
}
} else
$timezone = "Etc/UTC";
$timezones = array_map(
function ($path) { return str_replace('/usr/share/zoneinfo/', '', $path); },
glob('/usr/share/zoneinfo/*/*')
);
conf_mount_rw();
// Reset to default if empty or not existend
if (empty($timezone) || !in_array($timezone, $timezones)) {
$timezone = 'Etc/UTC';
}
exec("LANG=C /usr/bin/tar xzfO /usr/share/zoneinfo.tgz " .
escapeshellarg($timezone) . " > /etc/localtime");
// Apply timezone
conf_mount_rw();
copy(sprintf('/usr/share/zoneinfo/%s', $timezone), '/etc/localtime');
mwexec("sync");
conf_mount_ro();
......
......@@ -75,17 +75,14 @@ if (!$pconfig['timeservers'])
$changedesc = gettext("System") . ": ";
$changecount = 0;
function is_timezone($elt) {
return !preg_match("/\/$/", $elt);
}
if($pconfig['timezone'] <> $_POST['timezone']) {
filter_pflog_start(true);
}
exec('/usr/bin/tar -tzf /usr/share/zoneinfo.tgz', $timezonelist);
$timezonelist = array_filter($timezonelist, 'is_timezone');
sort($timezonelist);
$timezonelist = array_map(
function ($path) { return str_replace('/usr/share/zoneinfo/', '', $path); },
glob('/usr/share/zoneinfo/*/*')
);
$multiwan = false;
$interfaces = get_configured_interface_list();
......
......@@ -701,13 +701,12 @@ function showchange() {
break;
case "timezone_select":
exec('/usr/bin/tar -tzf /usr/share/zoneinfo.tgz', $timezonelist);
$timezonelist = array_filter($timezonelist, 'is_timezone');
sort($timezonelist);
/* kill carriage returns */
for($x=0; $x<count($timezonelist); $x++)
$timezonelist[$x] = str_replace("\n", "", $timezonelist[$x]);
$timezonelist = array_map(
function ($path) {
return str_replace('/usr/share/zoneinfo/', '', $path);
},
glob('/usr/share/zoneinfo/*/*')
);
if ($field['displayname']) {
echo "<td width=\"22%\" align=\"right\" class=\"vncellreq\">\n";
......@@ -987,4 +986,4 @@ function is_timezone($elt) {
?>
<? include('foot.inc'); ?>
\ No newline at end of file
<? include('foot.inc'); ?>
This diff is collapsed.
This diff is collapsed.
Copyright (c) 2006-2009, Intel Corporation.
All rights reserved.
Redistribution. Redistribution and use in binary form, without
modification, are permitted provided that the following conditions are
met:
* Redistributions must reproduce the above copyright notice and the
following disclaimer in the documentation and/or other materials
provided with the distribution.
* Neither the name of Intel Corporation nor the names of its suppliers
may be used to endorse or promote products derived from this software
without specific prior written permission.
* No reverse engineering, decompilation, or disassembly of this software
is permitted.
Limited patent license. Intel Corporation grants a world-wide,
royalty-free, non-exclusive license under patents it now or hereafter
owns or controls to make, have made, use, import, offer to sell and
sell ("Utilize") this software, but solely to the extent that any
such patent is necessary to Utilize the software alone, or in
combination with an operating system licensed under an approved Open
Source license as listed by the Open Source Initiative at
http://opensource.org/licenses. The patent license shall not apply to
any other combinations which include this software. No hardware per
se is licensed hereunder.
DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment