This file is indexed.

/usr/share/pyshared/allmydata/windows/registry.py is in tahoe-lafs 1.9.2-1.

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
import sys
import _winreg

_AMD_KEY = r"Software\Allmydata"
_BDIR_KEY = 'Base Dir Path'

if sys.platform not in ('win32'):
    raise ImportError, "registry cannot be used on non-windows systems"
    class WindowsError(Exception): # stupid voodoo to appease pyflakes
        pass

def get_registry_setting(key, name, _topkey=None):
    """
    This function iterates through _topkey (if not None),
    HKEY_CURRENT_USER, and HKEY_LOCAL_MACHINE before giving up.

    @note: Only supports string values.

    @param key: The key we are searching.
    @type key: String

    @param name: The name of the setting we are querying.
    @type name: String
    """
    topkeys = [_winreg.HKEY_CURRENT_USER, _winreg.HKEY_LOCAL_MACHINE]

    if _topkey:
        topkeys.insert(0, _topkey)

    for topkey in topkeys:
        try:
            regkey = _winreg.OpenKey(topkey, key)

            sublen, vallen, timestamp = _winreg.QueryInfoKey(regkey)
            for validx in xrange(vallen):
                keyname, value, keytype = _winreg.EnumValue(regkey, validx)
                if keyname == name and keytype == _winreg.REG_SZ:
                    return value

        except WindowsError:
            continue
    # We didn't find the key:
    raise KeyError, (key, name, "registry setting not found")

def set_registry_setting(key, name, data, reg_type=_winreg.REG_SZ,
                         _topkey=_winreg.HKEY_LOCAL_MACHINE, create_key_if_missing=True):
    """
    Sets a registry setting.

    defaults to string values (REG_SZ) - overridable with reg_type.
    """
    try:
        regkey = _winreg.OpenKey(_topkey, key, 0, _winreg.KEY_SET_VALUE)
    except WindowsError:
        if create_key_if_missing:
            regkey = _winreg.CreateKey(_topkey, key)
        else:
            raise KeyError, (key, "registry key not found")

    try:
        _winreg.DeleteValue(regkey, name)
    except:
        pass

    _winreg.SetValueEx(regkey, name, 0, reg_type, data)

def get_registry_value(keyname):
    """
    retrieves a registry key value from within the Software/Allmydata Inc key
    """
    try:
        return get_registry_setting(_AMD_KEY, keyname)
    except KeyError:
        return None

def get_base_dir_path():
    return get_registry_value(_BDIR_KEY)