[Pkg-wmaker-commits] [wmbiff] 24/92: wmbiff: Fix security.debian.rb script.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Thu Aug 20 02:59:21 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch master
in repository wmbiff.
commit 6b5849e26a55e09113f48f9d793996fa1d3d17e1
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date: Fri Nov 7 21:31:16 2014 -0600
wmbiff: Fix security.debian.rb script.
Patch by Lothar Ketterer <lketterer at users.sourceforge.net>
For more information, see:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=525749
---
scripts/security.debian.rb | 58 ++++++++++++----------------------------------
1 file changed, 15 insertions(+), 43 deletions(-)
diff --git a/scripts/security.debian.rb b/scripts/security.debian.rb
index 11d2362..bf403cb 100755
--- a/scripts/security.debian.rb
+++ b/scripts/security.debian.rb
@@ -7,7 +7,7 @@
# Based on security-update-check.py by Rob Bradford
-require 'net/http'
+require 'net/ftp'
#require 'profile'
@@ -67,16 +67,13 @@ end
# file, the url, the system's cache of the file, and a
# per-user cache of the file.
packagelists = Dir.glob("/var/lib/apt/lists/#{Server}*Packages").map { |pkgfile|
- [ pkgfile.gsub(/.*#{Server}/, '').tr('_','/'), # the url path
+ [ '/debian-security' + pkgfile.gsub(/.*#{Server}/, '').tr('_','/').gsub(/Packages/, ''), # the url path
pkgfile, # the system cache of the packages file. probably up-to-date.
# and finally, a user's cache of the page, if needed.
"%s/%s" % [ Cachedir, pkgfile.gsub(/.*#{Server}_/,'') ]
]
}
-# we'll open a persistent session, but only if we need it.
-session = nil
-
# update the user's cache if necessary.
packagelists.each { |urlpath, sc, uc|
sctime = File.stat(sc).mtime
@@ -91,31 +88,23 @@ packagelists.each { |urlpath, sc, uc|
uctime
end
else
- # the user cache doesn't exist, but we might have
- # talked to the server recently.
- if(test(?e, uc + '.stamp')) then
- File.stat(uc + '.stamp').mtime
- else
- sctime
- end
+ sctime
end
if(Time.now > cached_time + Refetch_Interval_Sec) then
debugmsg "fetching #{urlpath} %s > %s + %d" % [Time.now, cached_time, Refetch_Interval_Sec]
begin
- if(session == nil) then
- session = Net::HTTP.new(Server)
- # session.set_pipe($stderr);
- end
- begin
- # the warning with ruby1.8 on the following line
- # has to do with the resp, data bit, which should
- # eventually be replaced with (copied from the
- # docs with the 1.8 net/http.rb)
- # response = http.get('/index.html')
- # puts response.body
- resp, data = session.get(urlpath,
- { 'If-Modified-Since' =>
- cached_time.strftime( "%a, %d %b %Y %H:%M:%S GMT" ) })
+ test(?e, Cachedir) or Dir.mkdir(Cachedir)
+
+ ftp = Net::FTP.new(Server)
+ ftp.login
+ ftp.chdir(urlpath)
+ ftp.getbinaryfile('Packages.gz', uc + '.gz', 1024)
+ ftp.close
+
+ # need to unzip Packages.gz
+ cmd_gunzip = "gzip -df %s" % [ uc + '.gz' ]
+ Kernel.system(cmd_gunzip)
+
rescue SocketError => e
# if the net is down, we'll get this error; avoid printing a stack trace.
puts "XX old"
@@ -127,24 +116,7 @@ packagelists.each { |urlpath, sc, uc|
puts "XX old"
exit 1;
end
- test(?e, Cachedir) or Dir.mkdir(Cachedir)
- File.open(uc, 'w') { |o| o.puts data }
- test(?e, uc + '.stamp') and File.unlink(uc + '.stamp') # we have a copy, don't need the stamp.
debugmsg "urlpath updated"
- rescue Net::ProtoRetriableError => detail
- head = detail.data
- if head.code != "304"
- raise "unexpected error occurred: " + detail
- end
- test(?e, Cachedir) or Dir.mkdir(Cachedir)
- if(test(?e, uc)) then
- touch(uc)
- else
- # we didn't get an update, but we don't have a cached
- # copy in the user directory.
- touch(uc + '.stamp')
- end
- end
else
debugmsg "skipping #{urlpath}"
end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbiff.git
More information about the Pkg-wmaker-commits
mailing list