Skip to content

Commit

Permalink
report reboot for new kernels
Browse files Browse the repository at this point in the history
This compares `uname -r` to the directories in /lib/modules/, if a directory name in /lib/modules/ is bigger than `uname -r` a fake AffectedApplication is added for it.
  • Loading branch information
sean797 committed May 8, 2017
1 parent 121647f commit 30c740b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tracer/resources/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

from __future__ import absolute_import

import os
from distutils.version import LooseVersion
from psutil import NoSuchProcess
from tracer.resources.system import System
from tracer.resources.FilenameCleaner import FilenameCleaner
Expand Down Expand Up @@ -119,9 +121,19 @@ def trace_affected(self, user=None):
affected[a.name].affected_instances.append(p)
except NoSuchProcess:
pass
if self._has_updated_kernel() and not self._applications.find('kernel').ignore:
# Add fake AffectedApplication
affected['kernel'] = AffectedApplication({"name": "kernel", "type": Applications.TYPES["STATIC"],
"helper": u"You will have to reboot your computer"})

return ApplicationsCollection(affected.values())

def _has_updated_kernel(self):
for k_version in next(os.walk('/lib/modules/'))[1]:
if LooseVersion(os.uname()[2]) < LooseVersion(k_version):
return True
return False

def _apply_rules(self, process):
parent = process.parent()
if not parent:
Expand Down

0 comments on commit 30c740b

Please sign in to comment.