Commit 30eb7ced authored by Tails developers's avatar Tails developers

Import new htpdate (at commit e473d0b).

This adds the -T option we need.
parent 8a18ca8d
......@@ -53,8 +53,9 @@ 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 $res_file;
our ($opt_d, $opt_h, $opt_q, $opt_x, $opt_u, $opt_a, $opt_f, $opt_l, $opt_p, $opt_t);
our ($opt_d, $opt_h, $opt_q, $opt_x, $opt_u, $opt_a, $opt_f, $opt_l, $opt_p, $opt_t, $opt_T);
sub message {
my @msg = @_;
......@@ -82,7 +83,7 @@ sub error (@_) {
sub parseCommandLine () {
# specify valid switches
getopts('dhqxfpu:a:l:t:') || usage();
getopts('dhqxfpu:a:l:t:T:') || usage();
usage() if $opt_h;
usage() unless $ARGV[0];
......@@ -96,6 +97,7 @@ sub parseCommandLine () {
$quiet = 1 if $opt_q;
$set_date = 0 if $opt_x;
$dns_timeout = $opt_t if $opt_t;
$res_file = $opt_T if $opt_T;
my @urls;
foreach my $url (@ARGV) {
......@@ -113,7 +115,7 @@ sub usage () {
print STDERR <<USAGE;
htpdate version $VERSION
Usage: $0 [-dhqxf] [-u userid] [-a useragent] [-t dns_timeout] <URL> [<URL> ...]
Usage: $0 [-dhqxf] [-u userid] [-a useragent] [-t dns_timeout] [-T success_file] <URL> [<URL> ...]
-d debug
-h show this help
......@@ -125,6 +127,7 @@ Usage: $0 [-dhqxf] [-u userid] [-a useragent] [-t dns_timeout] <URL> [<URL> ...]
-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
-T create this file after setting time successfully
e.g. $0 -x http://www.microsoft.com/ https://check.torproject.org/
......@@ -238,6 +241,9 @@ sub adjustDate {
error "An error occured setting the time\n@output";
}
close($fd);
open my $res_h, '>>', $res_file or die "Cannot open res file $res_file: $!";
print $res_h "$diff\n";
close $res_h;
$> = getpwnam($opt_u) if $opt_u;
}
}
......
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