~ubuntu-branches/ubuntu/precise/jockey/precise-security

« back to all changes in this revision

Viewing changes to data/handlers/cdv.py

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2013-09-13 10:16:23 UTC
  • mfrom: (147.1.10 precise-proposed)
  • Revision ID: package-import@ubuntu.com-20130913101623-kiyngi3qyhh0jzaq
Tags: 0.9.7-0ubuntu7.11
* SECURITY UPDATE: possible privilege escalation via policykit UID lookup
  race.
  - jockey/backend.py: pass system-bus-name as a subject instead of pid
    so policykit can get the information from the system bus.
  - CVE-2013-1065

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
# (c) 2008 Canonical Ltd.
 
3
# Authors: Martin Pitt <martin.pitt@ubuntu.com>
 
4
#          Alberto Milone <alberto.milone@canonical.com>
 
5
# License: GPL v2 or later
 
6
 
 
7
import logging, os, os.path
 
8
 
 
9
import XKit.xorgparser
 
10
from jockey.xorg_driver import XorgDriverHandler
 
11
from NvidiaDetector.alternatives import Alternatives
 
12
from NvidiaDetector.alternatives import MultiArchUtils
 
13
import subprocess
 
14
 
 
15
# dummy stub for xgettext
 
16
def _(x): return x
 
17
 
 
18
class CdvDriver(XorgDriverHandler):
 
19
    def __init__(self, backend, package=None):
 
20
        self._free = False
 
21
 
 
22
        name=_('Intel Cedarview graphics driver')
 
23
 
 
24
        XorgDriverHandler.__init__(self, backend, 'cedarview_gfx',
 
25
            'cedarview-graphics-drivers', None, None, add_modules=['glx'],
 
26
            disable_modules=[], name=name,
 
27
            description=_('3D-accelerated proprietary graphics driver for '
 
28
                'Intel Cedarview cards.'),
 
29
            rationale=_('This driver is required to fully utilise the 3D '
 
30
                'potential of some Intel Cedarview cards, as well as provide '
 
31
                '2D acceleration of newer cards.'))
 
32
 
 
33
        self._alternatives = self._get_alternatives()
 
34
        self.needs_kernel_headers = True
 
35
        self.alternative_name = 'intel-cdv'
 
36
 
 
37
    def _get_alternatives(self):
 
38
        '''Get multi-arch alternatives names'''
 
39
        main_name = 'i386-linux-gnu_egl_conf'
 
40
        return Alternatives(main_name)
 
41
 
 
42
    def available(self):
 
43
        # we don't offer cdv in a life CD environment, as we will run out of
 
44
        # RAM trying to download and install all the packages in the RAM disk.
 
45
        if os.path.isdir('/rofs'):
 
46
            logging.debug('Disabling cdv driver on live system')
 
47
            return False
 
48
 
 
49
        logging.debug('cdv.available: falling back to default')
 
50
        return XorgDriverHandler.available(self)
 
51
 
 
52
    def enable(self):
 
53
        XorgDriverHandler.enable(self)
 
54
        
 
55
        # Set the alternative to cdv
 
56
        cdv_alternative = self._alternatives.get_alternative_by_name(
 
57
            self.alternative_name, ignore_pattern='-updates')
 
58
        if not cdv_alternative:
 
59
            logging.error('%s: get_alternative_by_name(%s) returned nothing' % (
 
60
                self.id(), self.package))
 
61
            return
 
62
        self._alternatives.set_alternative(cdv_alternative)
 
63
        subprocess.call(['update-initramfs', '-u'])
 
64
        subprocess.call(['update-initramfs', '-u', '-k', os.uname()[2]])
 
65
 
 
66
    def enabled(self):
 
67
        # See if cdv is the current alternative
 
68
        target_alternative = \
 
69
            self._alternatives.get_alternative_by_name(self.alternative_name)
 
70
        current_alternative = self._alternatives.get_current_alternative()
 
71
 
 
72
        logging.debug('cdv.enabled(%s): target_alt %s current_alt %s',
 
73
                self.module, target_alternative, current_alternative)
 
74
 
 
75
        if current_alternative is None:
 
76
            logging.debug('current alternative of %s is None, not enabled',
 
77
                self.module)
 
78
            return False
 
79
        if current_alternative != target_alternative:
 
80
            logging.debug('%s is not the alternative in use', self.module)
 
81
            return False
 
82
 
 
83
        return XorgDriverHandler.enabled(self)
 
84
 
 
85
    def disable(self):
 
86
        XorgDriverHandler.disable(self)
 
87
        # make sure that 'cedarview-drm' is removed too
 
88
        self.backend.remove_package('cedarview-drm')
 
89
 
 
90
        # Set the alternative back to open drivers
 
91
        open_drivers = self._alternatives.get_open_drivers_alternative()
 
92
        logging.debug('cdv.disable(%s): open_drivers: %s',
 
93
            self.module, open_drivers)
 
94
        if open_drivers:
 
95
            self._alternatives.set_alternative(open_drivers)
 
96
 
 
97
        subprocess.call(['update-initramfs', '-u'])
 
98
        subprocess.call(['update-initramfs', '-u', '-k', os.uname()[2]])
 
99
 
 
100
        return False