This file is indexed.

/usr/share/pyshared/bootconfig/utils.py is in startupmanager 1.9.13-5.

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

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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# -*- coding: utf-8 -*-
# Copyright (c) 2007 Jimmy Rönnholm
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import os
import re
from subprocess import call

def fix_filename_spaces(filename):
    """Prepend spaces in filename with '\' if it is not already there"""
    filename = filename.strip()
    parts = filename.split(' ')
    filename = ''
    for part in parts:
        if part == '':
            part = '\ '
        elif part[-1] != '\\':
            part += '\ '
        filename += part
    filename = filename.strip()
    if filename[-1] == '\\':
        filename = filename[:-1]
    filename = filename.strip()
    return filename

def get_line_number(filename, identifier):
    """Return the number of the line in filename that begin with identifier.

    Return -1 if there is no match.

    """
    lines = read_lines_from_file(filename)
    length = len(identifier)
    for i, line in enumerate(lines):
        line = line.strip()[:length].strip()
        if line == identifier:
            return i
    return -1

def extract_number(line):
    """Extract a number from line.
    
    Return -1 if failed.
    
    """
    number_filter = re.compile('[0-9]+')
    match = number_filter.search(line)
    if match:
        return int(match.group())
    return -1

def get_and_trim_line(filename, identifier):
    """
    Read file, find line that begin with identifier, remove that from line.

    Return -1 if line cannot be found.

    """
    line_number = get_line_number(filename, identifier)
    if line_number == -1:
        return -1
    lines = read_lines_from_file(filename)
    line = lines[line_number]
    length = len(identifier)
    line = line[length:]
    return line.strip()

def read_lines_from_file(filename):
    """Read file filename, return list of lines in the file."""
    try:
        input_file = open(filename, 'r')
        lines = input_file.readlines()
        input_file.close()
        return lines
    except IOError:
        raise SystemExit('File %s does not exist.' % filename)

def write_lines_to_file(filename, lines):
    """Write the list lines to file filename."""
    output_file = open(filename, 'w')
    for out_line in lines:
        output_file.write(out_line)
    output_file.close()

def format_floppy():
    """Format a floppy.

    Return 0 if it was successful.
    Return 1 if a floppy was not found.
    Return 3 if there was an OSError.
    Return a code < 0 or > 3 for other errors.

    """
    try:
        retcode = call('/sbin/mke2fs /dev/fd0', shell=True)
        if retcode < 0:
            print 'Child was terminated by signal', -retcode
        return retcode
    except OSError, e:
        print 'Execution failed:', e
        return 3

def make_floppy(grub_install_command, config_file):
    """Write a Grub boot floppy.

    Return 0 if it was successful.
    Return 1 if there was an OSError.
    Return a code < 0 or > 1 for other errors.

    """
    dir_preexisting = True

    if not os.path.isdir('/mnt/floppysum'):
        os.mkdir('/mnt/floppysum')
        dir_preexisting = False

    commands = [
        'mount -t ext2 /dev/fd0 /mnt/floppysum',
        grub_install_command + ' --root-directory=/mnt/floppysum fd0',
        'cp ' + config_file + ' /mnt/floppysum/' + config_file,
        'umount /mnt/floppysum']
    try:
        for command in commands:
            retcode = call(command, shell=True)
            if not retcode == 0:
                print 'Child was terminated by signal', -retcode
                return retcode

    except OSError, e:
        print 'Execution failed:', e
        return 1

    if not dir_preexisting:
        os.rmdir('/mnt/floppysum')
    return 0
    
def get_resolution():
    pipe = os.popen('xrandr')
    data = pipe.read()
    pipe.close()
    matches = re.search('current (\d+) x (\d+)', data)
    return matches.group(1) + 'x' + matches.group(2)

def set_resolution(resolution):
    os.system('xrandr --size ' + resolution)