This file is indexed.

/usr/lib/python3/dist-packages/checkbox_support/heuristics/udisks2.py is in python3-checkbox-support 0.2-2.

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
# This file is part of Checkbox.
#
# Copyright 2012 Canonical Ltd.
# Written by:
#   Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
#
# 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/>.

"""
checkbox_support.heuristics.udisks2
===========================

Heuristics for udisks2.

    Documentation: http://udisks.freedesktop.org/docs/latest/
    Source code: http://cgit.freedesktop.org/systemd/systemd/ (src/udev)
    Bug tracker: http://bugs.freedesktop.org/ (using systemd product)
"""

from checkbox_support.parsers.udevadm import CARD_READER_RE, GENERIC_RE, FLASH_RE


def is_memory_card(vendor, model, udisks2_media):
    """
    Check if the device seems to be a memory card

    The vendor and model arguments are _strings_, not integers.
    The udisks2_media argument is the value of org.freedesktop.UDisks2.Drive/


    This is rather fuzzy, sadly udev and udisks2 don't do a very good job and
    mostly don't specify the "media" property (it has a few useful values, such
    as flash_cf, flash_ms, flash_sm, flash_sd, flash_sdhc, flash_sdxc and
    flash_mmc but I have yet to see a device that reports such values)
    """
    # Treat any udisks2_media that contains 'flash' as a memory card
    if udisks2_media is not None and FLASH_RE.search(udisks2_media):
        return True
    # Treat any device that match model name to the following regular
    # expression as a memory card reader.
    if CARD_READER_RE.search(model):
        return True
    # Treat any device that contains the word 'Generic' in the vendor string as
    # a memory card reader.
    #
    # XXX: This seems odd but strangely enough seems to gets the job done. I
    # guess if I should start filing tons of bugs/patches on udev/udisks2 to
    # just have a few more rules and make this rule obsolete.
    if GENERIC_RE.search(vendor):
        return True
    return False