This file is indexed.

/usr/lib/python3/dist-packages/lib389/passwd.py is in python3-lib389 1.3.7.10-1ubuntu1.

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
# --- BEGIN COPYRIGHT BLOCK ---
# Copyright (C) 2016 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---

"""
This file contains helpers to generate password hashes compatible for
Directory Server.
"""

import subprocess
import random
import string
import os
import sys

BESTSCHEME = 'SSHA512'
MAJOR, MINOR, _, _, _ = sys.version_info

# We need a dict of the schemes I think ....
PWSCHEMES = [
    'SHA1',
    'SHA256',
    'SHA512',
    'SSHA',
    'SSHA256',
    'SSHA512',
]


# How do we feed our prefix into this?
def password_hash(pw, scheme=BESTSCHEME, bin_dir='/bin'):
    # Check that the binary exists
    assert(scheme in PWSCHEMES)
    pwdhashbin = os.path.join(bin_dir, 'pwdhash')
    assert(os.path.isfile(pwdhashbin))
    h = subprocess.check_output([pwdhashbin, '-s', scheme, pw]).strip()
    return h.decode('utf-8')


def password_generate(length=64):
    pw = None
    if MAJOR >= 3:
        pw = [random.choice(string.ascii_letters) for x in range(length - 1)]
    else:
        pw = [random.choice(string.letters) for x in xrange(length - 1)]
    pw.append('%s' % random.randint(0, 9))
    return "".join(pw)