Commit cfb7bb43 authored by T(A)ILS developers's avatar T(A)ILS developers
Browse files

Htpdate: display the logs when the clock synchronization fails.

parent 11b1b94d
......@@ -7,8 +7,8 @@
# However, since all DNS lookups are normally made through the Tor
# network, which we are not connected to at this point, we use the
# local DNS servers obtained through DHCP if possible, or the OpenDNS
# ones, else.
# local DNS servers obtained through DHCP, if possible, or the OpenDNS
# ones otherwise.
# To limit fingerprinting possibilities, we do not want to send HTTP
# requests aimed at an IP-based virtualhost such as https://IP/, but
......@@ -116,7 +116,7 @@ echo "${END_MAGIC}" >> /etc/hosts
touch "${HTPDATE_LOG}"
chown htp:nogroup "${HTPDATE_LOG}"
chmod 600 "${HTPDATE_LOG}"
chmod 644 "${HTPDATE_LOG}"
/usr/local/sbin/htpdate \
-d \
......@@ -132,6 +132,7 @@ echo "htpdate exited with return code ${HTPDATE_RET}" >>$LOG
cleanup_etc_hosts
echo "${HTPDATE_RET}" > "${DONE_FILE}"
touch "${DONE_FILE}"
exit ${HTPDATE_RET}
......@@ -47,4 +47,30 @@ $notification->show();
until (-e $htp_done_file) {
sleep 1;
}
$notification->close();
# read the return code from /var/lib/live/htp-done
open(my $htp_done, "< $htp_done_file") or die "Can not read file: $!";
(my $htp_done_code) = (<$htp_done> =~ /^(\d+)/);
# in case htpdate went fine, close the 'Please wait...' notification
if ($htp_done_code == 0) {
$notification->close();
}
# in case htpdate failed, notify the user with the corresponding logs
else {
open(my $htp_log, "< /var/log/htpdate.log") or die "Can not read file: $!";
my $last_log;
while (<$htp_log>) {
if ($_ =~ /Running htpdate./) {
$last_log = '';
next;
}
$last_log .= $_;
}
my $failure_summary = gettext("Failed to synchronize the clock!");
my $failure_body = $last_log;
my $failure_notification = $notify->create(summary => $failure_summary,
body => $failure_body,
timeout => 0);
$failure_notification->show();
}
......@@ -240,6 +240,7 @@ sub adjustDate {
}
my @urls = parseCommandLine();
message("Running htpdate.");
my @diffs = grep {
defined $_
} map {
......
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