Commit aae2d65b authored by Tails developers's avatar Tails developers

Import new htpdate (at commit 45dbc4c).

This adds the -D option we need.
parent 058ae840
......@@ -53,9 +53,25 @@ my $ssl_protocol = 'TLSv1'; # will be passed to wget's --secure-protocol
my $useragent = "htpdate/$VERSION";
my $userid = ''; # userid for proxy servers
my $dns_timeout;
my $done_file;
my $res_file;
our ($opt_d, $opt_h, $opt_q, $opt_x, $opt_u, $opt_a, $opt_f, $opt_l, $opt_p, $opt_t, $opt_T);
our ($opt_d, $opt_h, $opt_q, $opt_x, $opt_u, $opt_a, $opt_f, $opt_l, $opt_p, $opt_t, $opt_D, $opt_T);
sub done {
if (defined $done_file) {
$> = 0 if $opt_u;
open my $f, '>', $done_file or
print STDERR "Couldn't write done file: $done_file\n";
close $f;
$> = getpwnam($opt_u) if $opt_u;
}
}
$SIG{__DIE__} = sub {
done;
die(@_);
};
sub message {
my @msg = @_;
......@@ -83,7 +99,7 @@ sub error (@_) {
sub parseCommandLine () {
# specify valid switches
getopts('dhqxfpu:a:l:t:T:') || usage();
getopts('dhqxfpu:a:l:t:D:T:') || usage();
usage() if $opt_h;
usage() unless $ARGV[0];
......@@ -97,6 +113,7 @@ sub parseCommandLine () {
$quiet = 1 if $opt_q;
$set_date = 0 if $opt_x;
$dns_timeout = $opt_t if $opt_t;
$done_file = $opt_D if $opt_D;
$res_file = $opt_T if $opt_T;
my @urls;
......@@ -127,6 +144,7 @@ Usage: $0 [-dhqxf] [-u userid] [-a useragent] [-t dns_timeout] [-T success_file]
-l log to this file rather than to STDOUT
-p paranoid mode: don't set time unless all servers could be reached
-t DNS timeout for wget
-D create this file after quitting in any way
-T create this file after setting time successfully
e.g. $0 -x http://www.microsoft.com/ https://check.torproject.org/
......@@ -272,3 +290,4 @@ my @diffs = grep {
or error "No Date header could be received.";
my @sorted_diffs = sort @diffs;
adjustDate($sorted_diffs[int(@sorted_diffs / 2)]);
done;
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