This file is indexed.

/usr/lib/2013.com.canonical.certification:plainbox-resources/bin/cdimage_resource is in plainbox-provider-resource-generic 0.3-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
#!/usr/bin/python3
#
# This file is part of Checkbox.
#
# Copyright 2009 Canonical Ltd.
#
# Checkbox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3,
# as published by the Free Software Foundation.

#
# Checkbox is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Checkbox.  If not, see <http://www.gnu.org/licenses/>.
#
import re
import sys


# Filename containing casper logs
CASPER_FILENAME = "/var/log/installer/casper.log"

# Filename containing media info
MEDIA_FILENAME = "/var/log/installer/media-info"


def get_disk_from_string(string):
    # Ubuntu 8.04.1 "Hardy Heron" - Release amd64 (20080702.1)
    # Ubuntu 10.04.2 LTS "Lucid Lynx" - Release amd64 (20110227.2)
    distributor_regex = r"(?P<distributor>[\w\-]+)"
    release_regex = r"(?P<release>[\d\.]+( LTS)?)"
    codename_regex = r"(?P<codename>[^_\"]+)"
    official_regex = r"(?P<official>[\w ]+)"
    architecture_regex = r"(?P<architecture>[\w\+]+)"
    type_regex = r"(?P<type>Binary-\d+)"
    date_regex = r"(?P<date>[^\)]+)"

    string_regex = (r"%s %s [_\"]%s[_\"] - %s %s (%s )?\(%s\)"
                    % (distributor_regex, release_regex, codename_regex,
                       official_regex, architecture_regex, type_regex,
                       date_regex))

    disk = {}
    match = re.match(string_regex, string)
    if match:
        disk = match.groupdict()
        del disk["type"]

    return disk


def get_disk_from_casper(filename):
    disk = {}

    # Try to open the disk info file logged by the installer
    try:
        file = open(filename)
    except IOError:
        return disk

    line_regex = r"Found label '(?P<string>[^']+)'"
    line_pattern = re.compile(line_regex)

    for line in file.readlines():
        match = line_pattern.match(line)
        if match:
            string = match.group("string")
            disk = get_disk_from_string(string)
            break

    return disk


def get_disk_from_media(filename):
    try:
        file = open(filename)
    except IOError:
        return {}

    string = file.readline()
    return get_disk_from_string(string)


def main():
    disk = get_disk_from_media(MEDIA_FILENAME)
    if not disk:
        disk = get_disk_from_casper(CASPER_FILENAME)

    for key, value in disk.items():
        print("%s: %s" % (key, value))

    return 0


if __name__ == "__main__":
    sys.exit(main())