Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
tails
tails
Commits
dbc2502e
Commit
dbc2502e
authored
Aug 06, 2010
by
amnesia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New htpdate script.
Copied from 89ed34b.
parent
db0ad2e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
wiki/src/todo/authenticate_time_servers/htpdate
wiki/src/todo/authenticate_time_servers/htpdate
+16
-5
No files found.
wiki/src/todo/authenticate_time_servers/htpdate
View file @
dbc2502e
...
...
@@ -30,6 +30,7 @@ use Carp;
use
Cwd
;
use
DateTime
;
use
DateTime::Format::
DateParse
;
use
English
qw( -no_match_vars )
;
use
Fatal
qw( open close )
;
use
File::
Temp
qw/tempdir/
;
use
Getopt::
Std
;
...
...
@@ -104,7 +105,7 @@ sub newestDateHeader {
my
$origdir
=
getcwd
;
chdir
$dir
;
my
@files
=
glob
('
.* *
');
my
@files
=
grep
{
!
(
$_
=~
m/^\.{1,2}$/
)
}
glob
('
.* *
');
@files
or
croak
"
No downloaded files can be found
";
my
$newestdt
;
...
...
@@ -158,7 +159,11 @@ sub getRemoteDateDiff {
# images, stylesheets, scripts, etc.
WIFEXITED
(
system
(
@cmdline
))
or
croak
"
Failed to fetch content from
$url
: $!
";
my
$localdt
=
DateTime
->
now
;
my
$newestdt
=
newestDateHeader
(
$tmpdir
);
my
$newestdt
;
eval
{
$newestdt
=
newestDateHeader
(
$tmpdir
)
};
if
(
$EVAL_ERROR
=~
m/No downloaded files can be found/
)
{
croak
"
No file could be downloaded from
$url
.
";
}
defined
$newestdt
or
croak
"
Could not get any Date header
";
...
...
@@ -215,10 +220,16 @@ sub adjustDate {
my
@urls
=
parseCommandLine
();
my
@diffdts
;
foreach
my
$url
(
@urls
)
{
# TODO: use try/catch, return a zero diff on failure
my
$diffdt
=
getRemoteDateDiff
(
$url
,
$fullrequest
);
push
@diffdts
,
$diffdt
;
my
$diffdt
;
eval
{
$diffdt
=
getRemoteDateDiff
(
$url
,
$fullrequest
)
};
if
(
$EVAL_ERROR
)
{
print
STDERR
"
$EVAL_ERROR
\n
";
}
else
{
push
@diffdts
,
$diffdt
;
}
}
@diffdts
or
croak
"
No Date header could be received.
";
my
@sorted_diffdts
=
sort
{
$a
->
in_units
('
seconds
')
<=>
$b
->
in_units
('
seconds
')
}
@diffdts
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment