From 4d2e876a68c3bc59aca85add5800755046a4dd71 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sun, 29 Dec 2013 20:48:28 -0800 Subject: [PATCH] Never just crash if hardware time cannot be read http://virtualmin.com/node/31933 --- time/index.cgi | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/time/index.cgi b/time/index.cgi index 6fd97d733..333b6420b 100755 --- a/time/index.cgi +++ b/time/index.cgi @@ -69,16 +69,22 @@ else # Get the hardware time if (&support_hwtime()) { local @tm = &get_hardware_time(); - @tm || &error($get_hardware_time_error || $text{'index_eformat'}); - $hw_date{ 'second' } = $tm[0]; - $hw_date{ 'minute' } = $tm[1]; - $hw_date{ 'hour' } = $tm[2]; - $hw_date{ 'date' } = $tm[3]; - $hw_date{ 'month' } = &number_to_month($tm[4]); - $hw_date{ 'year'} = $tm[5]+1900; - $hw_date{ 'day' } = &number_to_weekday($tm[6]); + if (@tm) { + $hw_date{'second'} = $tm[0]; + $hw_date{'minute'} = $tm[1]; + $hw_date{'hour'} = $tm[2]; + $hw_date{'date'} = $tm[3]; + $hw_date{'month'} = &number_to_month($tm[4]); + $hw_date{'year'} = $tm[5]+1900; + $hw_date{'day'} = &number_to_weekday($tm[6]); + } - if(!$access{'hwdate'}) { + if (!@tm) { + # Didn't actually work! + print $get_hardware_time_error || $text{'index_eformat'}; + print "

\n"; + } + elsif (!$access{'hwdate'}) { # Allow editing of hardware time if( !$access{ 'sysdate' } ) { $hw_date{ 'second' } = $system_date{ 'second' } if( $hw_date{ 'second' } - $system_date{ 'second' } <= $config{ 'lease' } );