Codebase list debian-goodies / 85d9cac
Add patch provided by Tollef Fog Heen which includes a new -b (blacklist) option (Closes: #649168) Javier Fernandez-Sanguino 12 years ago
3 changed file(s) with 31 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
6767
6868 lc_all_c_env = os.environ
6969 lc_all_c_env['LC_ALL'] = 'C'
70
70 blacklistFiles = []
71 blacklist = []
7172
7273 # Process options
7374 try:
74 opts, args = getopt.getopt(sys.argv[1:], "hvpa", ["help", "verbose", "packages", "all"])
75 opts, args = getopt.getopt(sys.argv[1:], "hvpab:", ["help", "verbose", "packages", "all", "blacklist"])
7576 except getopt.GetoptError, err:
7677 # print help information and exit:
7778 print str(err) # will print something like "option -x not recognized"
9798 elif o in ("-a", "--all"):
9899 allFiles = True
99100 onlyPackageFiles = False
101 elif o in ("-b", "--blacklist"):
102 blacklistFiles.append(a)
103 onlyPackageFiles = False
100104 else:
101105 assert False, "unhandled option"
106
107 for f in blacklistFiles:
108 for line in file(f, "r"):
109 if line.startswith("#"):
110 continue
111 blacklist.append(re.compile(line.strip()))
102112
103113 # Start checking
104114
113123 # TODO - This does not work yet:
114124 # toRestart = psdelcheck()
115125
116 toRestart = lsofcheck()
126 toRestart = lsofcheck(blacklist = blacklist)
117127
118128 print "Found %d processes using old versions of upgraded files" % len(toRestart)
119129
225235 for process in package.processes:
226236 print "\t%s\t%s" % (process.pid,process.program)
227237
228 def lsofcheck():
238 def lsofcheck(blacklist = None):
229239 processes = {}
230240
231241 for line in os.popen('lsof +XL -F nf').readlines():
253263 # Save the descriptor for later comparison
254264 process.descriptors.append(data)
255265
256 toRestart = filter(lambda process: process.needsRestart(),
266 toRestart = filter(lambda process: process.needsRestart(blacklist),
257267 processes.values())
258268 return toRestart
259269
261271 # Returns:
262272 # - 0 (NO) for known locations of files which might be deleted
263273 # - 1 (YES) for valid deleted files we are interested in
264 def isdeletedFile (f):
274 def isdeletedFile (f, blacklist = None):
265275
266276 global lc_all_c_env
267277
268278 if allFiles:
269279 return 1
280 if blacklist:
281 for p in blacklist:
282 if p.search(f):
283 return 0
270284 # We don't care about log files
271285 if f.startswith('/var/log/'):
272286 return 0
468482 # Returns:
469483 # - 0 if there is no need to restart the process
470484 # - 1 if the process needs to be restarted
471 def needsRestart(self):
485 def needsRestart(self, blacklist = None):
472486 for f in self.files:
473 if isdeletedFile(f):
487 if isdeletedFile(f, blacklist):
474488 return 1
475489 for f in self.links:
476490 if f == 0:
5656 .I -p
5757 option.
5858
59 .TP
60 .BI -b file, --blacklist=file
61 Read a blacklist of regular expressions from
62 .I file.
63 Any files matching the patterns will be ignored.
64
5965 .SH EXIT STATUS
6066
6167 The program will exit with error (1) if a non-root user tries to run it. Otherwise,
00 debian-goodies (0.61) unstable; urgency=low
11
22 * [checkrestart]
3 - Prover fix to avoid false positives due to /drm (Closes: 548380)
3 - Prover fix to avoid false positives due to /drm (Closes: #548380)
4 - Add patch provided by Tollef Fog Heen which includes a new -b
5 (blacklist) option (Closes: #649168)
46
57 -- Javier Fernandez-Sanguino Pen~a <jfs@debian.org> Wed, 28 Mar 2012 23:37:20 +0200
68