This file is indexed.

/usr/lib/python2.7/dist-packages/cligh/config.py is in cligh 0.2-3.

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
import ConfigParser
import getpass
import os
from github import Github
from xdg import BaseDirectory
from . import utils

USERNAME = None
TOKEN = None

def get_username():
	global USERNAME
	return USERNAME

def get_token():
	global TOKEN
	return TOKEN

def get_config_dir():
	"""Return the name of the directory containing the application's config file."""
	config_dir = BaseDirectory.load_first_config('cligh')
	if config_dir is None:
		config_dir = BaseDirectory.save_config_path('cligh')
	return config_dir

def get_config_filename():
	"""Get the absolute pathname of the config file."""
	config_dir = get_config_dir()
	return os.path.join(config_dir, 'cligh.conf')

def read_config_file():
	global USERNAME, TOKEN
	config_parser = ConfigParser.ConfigParser()
	config_filename = get_config_filename()
	try:
		with open(config_filename, 'r') as f:
			config_parser.readfp(f)
	except ConfigParser.Error as e:
		utils.die("""The following error was encountered while attempting to parse the configuration file.
%s
This may indicate a mal-formed configuration file.
Recreate the file by invoking
cligh configure
""" % str(e))
	except IOError as e:
		utils.die("""The following error occurred while trying to open the configuration file.
%s.
If you have not already done so, create the configuration file using
cligh configure
at your shell prompt.
""" % str(e))

	try:
		USERNAME = config_parser.get('credentials', 'username')
		TOKEN = config_parser.get('credentials', 'token')
	except ConfigParser.Error as e:
		utils.die("""The config file is missing one or more expected options.
You should probably recreate it using these two commands:
rm %s
cligh configure
""" % config_filename)

def do_configcmd():
	"""Create an oauth token.  Write the username and token to the config
file.  Should be called the first time the application is executed."""
	dummy_validator = lambda x : True
	username = utils.read_user_input('Username', dummy_validator)
	password = getpass.getpass('Password:')
	client = Github(username, password)
	user = client.get_user()
	authorization = user.create_authorization(scopes=['user', 'repo', 'gist', 'delete_repo'], note='cligh', note_url='https://github.com/CMB/cligh')
	config_parser = ConfigParser.ConfigParser()
	config_parser.add_section('credentials')
	config_parser.set('credentials', 'username', username)
	config_parser.set('credentials', 'token', authorization.token)
	os.umask(077) # Want permissions of 0600.
	with open(get_config_filename(), 'w') as f:
		config_parser.write(f)
	print 'cligh configured and authorized for use with github.'

def make_configcmd_parser(subparsers):
	configcmd = subparsers.add_parser('configure', help='Configure cligh.')
	configcmd.set_defaults(func=do_configcmd)