Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tails
tails
Commits
43cb3dcf
Commit
43cb3dcf
authored
Aug 08, 2010
by
amnesia
Browse files
New htpdate script.
Copied from commit 184d9ba in
git://gaffer.ptitcanardnoir.org/htp.git
parent
f8f60b78
Changes
1
Hide whitespace changes
Inline
Side-by-side
config/chroot_local-includes/usr/local/sbin/htpdate
View file @
43cb3dcf
...
...
@@ -36,6 +36,7 @@ use File::Temp qw/tempdir/;
use
Getopt::
Std
;
use
open
qw{:utf8 :std}
;
use
POSIX
qw( WIFEXITED )
;
use
threads
;
my
$datecommand
=
'
/bin/date
';
# "date" command to set time
my
$dateparam
=
'
-s
';
# "date" parameter to set time
...
...
@@ -184,6 +185,7 @@ sub getRemoteDateDiff {
# fetch (the page and) referenced resources:
# images, stylesheets, scripts, etc.
my
$beforedt
=
DateTime
->
now
;
WIFEXITED
(
system
(
@cmdline
))
or
error
"
Failed to fetch content from
$url
: $!
";
my
$localdt
=
DateTime
->
now
;
my
$newestdt
;
...
...
@@ -196,7 +198,9 @@ sub getRemoteDateDiff {
my
$diffdt
=
$newestdt
-
$localdt
;
my
$diff
=
$diffdt
->
in_units
('
seconds
');
debug
("
$url
=>
$diff
second(s)
");
my
$tookdt
=
$localdt
-
$beforedt
;
my
$took
=
$tookdt
->
in_units
('
seconds
');
debug
("
$url
(took
${took}
s) => diff =
$diff
second(s)
");
chdir
$origdir
;
return
$diffdt
;
...
...
@@ -243,18 +247,11 @@ sub adjustDate {
}
my
@urls
=
parseCommandLine
();
my
@diffdts
;
foreach
my
$url
(
@urls
)
{
my
$diffdt
;
eval
{
$diffdt
=
getRemoteDateDiff
(
$url
,
$fullrequest
)
};
if
(
$EVAL_ERROR
)
{
print
STDERR
"
$EVAL_ERROR
\n
";
}
else
{
push
@diffdts
,
$diffdt
;
}
}
@diffdts
or
error
"
No Date header could be received.
";
my
@diffdts
=
grep
{
defined
$_
}
map
{
$_
->
join
()
}
map
{
threads
->
create
(
\
&getRemoteDateDiff
,
$_
,
$fullrequest
)
}
@urls
or
error
"
No Date header could be received.
";
my
@sorted_diffdts
=
sort
{
$a
->
in_units
('
seconds
')
<=>
$b
->
in_units
('
seconds
')
}
@diffdts
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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