/
usr
/
lib
/
python2.6
/
site-packages
/
cloudinit
/
config
/
/usr/lib/python2.6/site-packages/cloudinit/config
mkdir
upload
Name
Size
Mode
Actions
cc_apt_configure.py
9600
0644
edit
dl
rm
cc_apt_configure.pyc
9013
0644
edit
dl
rm
cc_apt_configure.pyo
9013
0644
edit
dl
rm
cc_apt_pipelining.py
2111
0644
edit
dl
rm
cc_apt_pipelining.pyc
1643
0644
edit
dl
rm
cc_apt_pipelining.pyo
1643
0644
edit
dl
rm
cc_bootcmd.py
1782
0644
edit
dl
rm
cc_bootcmd.pyc
1295
0644
edit
dl
rm
cc_bootcmd.pyo
1295
0644
edit
dl
rm
cc_byobu.py
2886
0644
edit
dl
rm
cc_byobu.pyc
2185
0644
edit
dl
rm
cc_byobu.pyo
2185
0644
edit
dl
rm
cc_ca_certs.py
3872
0644
edit
dl
rm
cc_ca_certs.pyc
3396
0644
edit
dl
rm
cc_ca_certs.pyo
3396
0644
edit
dl
rm
cc_chef.py
5718
0644
edit
dl
rm
cc_chef.pyc
4027
0644
edit
dl
rm
cc_chef.pyo
4027
0644
edit
dl
rm
cc_debug.py
2869
0644
edit
dl
rm
cc_debug.pyc
2444
0644
edit
dl
rm
cc_debug.pyo
2444
0644
edit
dl
rm
cc_disable_ec2_metadata.py
1312
0644
edit
dl
rm
cc_disable_ec2_metadata.pyc
873
0644
edit
dl
rm
cc_disable_ec2_metadata.pyo
873
0644
edit
dl
rm
cc_disk_setup.py
25274
0644
edit
dl
rm
cc_disk_setup.pyc
22560
0644
edit
dl
rm
cc_disk_setup.pyo
22560
0644
edit
dl
rm
cc_emit_upstart.py
1707
0644
edit
dl
rm
cc_emit_upstart.pyc
1143
0644
edit
dl
rm
cc_emit_upstart.pyo
1143
0644
edit
dl
rm
cc_final_message.py
2348
0644
edit
dl
rm
cc_final_message.pyc
1860
0644
edit
dl
rm
cc_final_message.pyo
1860
0644
edit
dl
rm
cc_foo.py
2453
0644
edit
dl
rm
cc_foo.pyc
488
0644
edit
dl
rm
cc_foo.pyo
488
0644
edit
dl
rm
cc_growpart.py
9602
0644
edit
dl
rm
cc_growpart.pyc
8928
0644
edit
dl
rm
cc_growpart.pyo
8928
0644
edit
dl
rm
cc_grub_dpkg.py
2344
0644
edit
dl
rm
cc_grub_dpkg.pyc
1543
0644
edit
dl
rm
cc_grub_dpkg.pyo
1543
0644
edit
dl
rm
cc_keys_to_console.py
1943
0644
edit
dl
rm
cc_keys_to_console.pyc
1300
0644
edit
dl
rm
cc_keys_to_console.pyo
1300
0644
edit
dl
rm
cc_landscape.py
2991
0644
edit
dl
rm
cc_landscape.pyc
2476
0644
edit
dl
rm
cc_landscape.pyo
2476
0644
edit
dl
rm
cc_locale.py
1358
0644
edit
dl
rm
cc_locale.pyc
801
0644
edit
dl
rm
cc_locale.pyo
801
0644
edit
dl
rm
cc_mcollective.py
3760
0644
edit
dl
rm
cc_mcollective.pyc
1840
0644
edit
dl
rm
cc_mcollective.pyo
1840
0644
edit
dl
rm
cc_migrator.py
3119
0644
edit
dl
rm
cc_migrator.pyc
2749
0644
edit
dl
rm
cc_migrator.pyo
2749
0644
edit
dl
rm
cc_mounts.py
8483
0644
edit
dl
rm
cc_mounts.pyc
6153
0644
edit
dl
rm
cc_mounts.pyo
6153
0644
edit
dl
rm
cc_package_update_upgrade_install.py
3523
0644
edit
dl
rm
cc_package_update_upgrade_install.pyc
2937
0644
edit
dl
rm
cc_package_update_upgrade_install.pyo
2937
0644
edit
dl
rm
cc_phone_home.py
3666
0644
edit
dl
rm
cc_phone_home.pyc
2479
0644
edit
dl
rm
cc_phone_home.pyo
2479
0644
edit
dl
rm
cc_power_state_change.py
5121
0644
edit
dl
rm
cc_power_state_change.pyc
4934
0644
edit
dl
rm
cc_power_state_change.pyo
4934
0644
edit
dl
rm
cc_puppet.py
5166
0644
edit
dl
rm
cc_puppet.pyc
3055
0644
edit
dl
rm
cc_puppet.pyo
3055
0644
edit
dl
rm
cc_resizefs.py
5697
0644
edit
dl
rm
cc_resizefs.pyc
4768
0644
edit
dl
rm
cc_resizefs.pyo
4768
0644
edit
dl
rm
cc_resolv_conf.py
3681
0644
edit
dl
rm
cc_resolv_conf.pyc
2213
0644
edit
dl
rm
cc_resolv_conf.pyo
2213
0644
edit
dl
rm
cc_rightscale_userdata.py
3575
0644
edit
dl
rm
cc_rightscale_userdata.pyc
2074
0644
edit
dl
rm
cc_rightscale_userdata.pyo
2074
0644
edit
dl
rm
cc_rsyslog.py
3412
0644
edit
dl
rm
cc_rsyslog.pyc
1848
0644
edit
dl
rm
cc_rsyslog.pyo
1848
0644
edit
dl
rm
cc_runcmd.py
1348
0644
edit
dl
rm
cc_runcmd.pyc
842
0644
edit
dl
rm
cc_runcmd.pyo
842
0644
edit
dl
rm
cc_salt_minion.py
2315
0644
edit
dl
rm
cc_salt_minion.pyc
1413
0644
edit
dl
rm
cc_salt_minion.pyo
1413
0644
edit
dl
rm
cc_scripts_per_boot.py
1369
0644
edit
dl
rm
cc_scripts_per_boot.pyc
806
0644
edit
dl
rm
cc_scripts_per_boot.pyo
806
0644
edit
dl
rm
cc_scripts_per_instance.py
1377
0644
edit
dl
rm
cc_scripts_per_instance.pyc
820
0644
edit
dl
rm
cc_scripts_per_instance.pyo
820
0644
edit
dl
rm
cc_scripts_per_once.py
1365
0644
edit
dl
rm
cc_scripts_per_once.pyc
804
0644
edit
dl
rm
cc_scripts_per_once.pyo
804
0644
edit
dl
rm
cc_scripts_user.py
1388
0644
edit
dl
rm
cc_scripts_user.pyc
788
0644
edit
dl
rm
cc_scripts_user.pyo
788
0644
edit
dl
rm
cc_scripts_vendor.py
1398
0644
edit
dl
rm
cc_scripts_vendor.pyc
924
0644
edit
dl
rm
cc_scripts_vendor.pyo
924
0644
edit
dl
rm
cc_seed_random.py
3161
0644
edit
dl
rm
cc_seed_random.pyc
2767
0644
edit
dl
rm
cc_seed_random.pyo
2767
0644
edit
dl
rm
cc_set_hostname.py
1460
0644
edit
dl
rm
cc_set_hostname.pyc
932
0644
edit
dl
rm
cc_set_hostname.pyo
932
0644
edit
dl
rm
cc_set_passwords.py
5555
0644
edit
dl
rm
cc_set_passwords.pyc
4010
0644
edit
dl
rm
cc_set_passwords.pyo
4010
0644
edit
dl
rm
cc_ssh.py
5225
0644
edit
dl
rm
cc_ssh.pyc
4104
0644
edit
dl
rm
cc_ssh.pyo
4104
0644
edit
dl
rm
cc_ssh_authkey_fingerprints.py
3648
0644
edit
dl
rm
cc_ssh_authkey_fingerprints.pyc
3507
0644
edit
dl
rm
cc_ssh_authkey_fingerprints.pyo
3507
0644
edit
dl
rm
cc_ssh_import_id.py
3039
0644
edit
dl
rm
cc_ssh_import_id.pyc
2191
0644
edit
dl
rm
cc_ssh_import_id.pyo
2191
0644
edit
dl
rm
cc_timezone.py
1316
0644
edit
dl
rm
cc_timezone.pyc
769
0644
edit
dl
rm
cc_timezone.pyo
769
0644
edit
dl
rm
cc_update_etc_hosts.py
2391
0644
edit
dl
rm
cc_update_etc_hosts.pyc
1509
0644
edit
dl
rm
cc_update_etc_hosts.pyo
1509
0644
edit
dl
rm
cc_update_hostname.py
1627
0644
edit
dl
rm
cc_update_hostname.pyc
1166
0644
edit
dl
rm
cc_update_hostname.pyo
1166
0644
edit
dl
rm
cc_users_groups.py
1265
0644
edit
dl
rm
cc_users_groups.pyc
792
0644
edit
dl
rm
cc_users_groups.pyo
792
0644
edit
dl
rm
cc_write_files.py
3554
0644
edit
dl
rm
cc_write_files.pyc
3231
0644
edit
dl
rm
cc_write_files.pyo
3231
0644
edit
dl
rm
cc_yum_add_repo.py
3944
0644
edit
dl
rm
cc_yum_add_repo.pyc
3026
0644
edit
dl
rm
cc_yum_add_repo.pyo
3026
0644
edit
dl
rm
__init__.py
1970
0644
edit
dl
rm
__init__.pyc
1349
0644
edit
dl
rm
__init__.pyo
1349
0644
edit
dl
rm
Edit:
/usr/lib/python2.6/site-packages/cloudinit/config/cc_set_passwords.py
(5555B)
# vi: ts=4 expandtab # # Copyright (C) 2009-2010 Canonical Ltd. # Copyright (C) 2012, 2013 Hewlett-Packard Development Company, L.P. # # Author: Scott Moser <scott.moser@canonical.com> # Author: Juerg Haefliger <juerg.haefliger@hp.com> # # This program 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. # # This program 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 this program. If not, see <http://www.gnu.org/licenses/>. import sys # Ensure this is aliased to a name not 'distros' # since the module attribute 'distros' # is a list of distros that are supported, not a sub-module from cloudinit import distros as ds from cloudinit import ssh_util from cloudinit import util from string import letters, digits # pylint: disable=W0402 # We are removing certain 'painful' letters/numbers PW_SET = (letters.translate(None, 'loLOI') + digits.translate(None, '01')) def handle(_name, cfg, cloud, log, args): if len(args) != 0: # if run from command line, and give args, wipe the chpasswd['list'] password = args[0] if 'chpasswd' in cfg and 'list' in cfg['chpasswd']: del cfg['chpasswd']['list'] else: password = util.get_cfg_option_str(cfg, "password", None) expire = True pw_auth = "no" change_pwauth = False plist = None if 'chpasswd' in cfg: chfg = cfg['chpasswd'] plist = util.get_cfg_option_str(chfg, 'list', plist) expire = util.get_cfg_option_bool(chfg, 'expire', expire) if not plist and password: (users, _groups) = ds.normalize_users_groups(cfg, cloud.distro) (user, _user_config) = ds.extract_default(users) if user: plist = "%s:%s" % (user, password) else: log.warn("No default or defined user to change password for.") errors = [] if plist: plist_in = [] randlist = [] users = [] for line in plist.splitlines(): u, p = line.split(':', 1) if p == "R" or p == "RANDOM": p = rand_user_password() randlist.append("%s:%s" % (u, p)) plist_in.append("%s:%s" % (u, p)) users.append(u) ch_in = '\n'.join(plist_in) + '\n' try: log.debug("Changing password for %s:", users) util.subp(['chpasswd'], ch_in) except Exception as e: errors.append(e) util.logexc(log, "Failed to set passwords with chpasswd for %s", users) if len(randlist): blurb = ("Set the following 'random' passwords\n", '\n'.join(randlist)) sys.stderr.write("%s\n%s\n" % blurb) if expire: expired_users = [] for u in users: try: util.subp(['passwd', '--expire', u]) expired_users.append(u) except Exception as e: errors.append(e) util.logexc(log, "Failed to set 'expire' for %s", u) if expired_users: log.debug("Expired passwords for: %s users", expired_users) change_pwauth = False pw_auth = None if 'ssh_pwauth' in cfg: change_pwauth = True if util.is_true(cfg['ssh_pwauth']): pw_auth = 'yes' if util.is_false(cfg['ssh_pwauth']): pw_auth = 'no' if change_pwauth: replaced_auth = False # See: man sshd_config old_lines = ssh_util.parse_ssh_config(ssh_util.DEF_SSHD_CFG) new_lines = [] i = 0 for (i, line) in enumerate(old_lines): # Keywords are case-insensitive and arguments are case-sensitive if line.key == 'passwordauthentication': log.debug("Replacing auth line %s with %s", i + 1, pw_auth) replaced_auth = True line.value = pw_auth new_lines.append(line) if not replaced_auth: log.debug("Adding new auth line %s", i + 1) replaced_auth = True new_lines.append(ssh_util.SshdConfigLine('', 'PasswordAuthentication', pw_auth)) lines = [str(l) for l in new_lines] util.write_file(ssh_util.DEF_SSHD_CFG, "\n".join(lines), mode=0600) try: cmd = cloud.distro.init_cmd # Default service cmd.append(cloud.distro.get_option('ssh_svcname', 'ssh')) cmd.append('restart') if 'systemctl' in cmd: # Switch action ordering cmd[1], cmd[2] = cmd[2], cmd[1] cmd = filter(None, cmd) # Remove empty arguments util.subp(cmd) log.debug("Restarted the ssh daemon") except: util.logexc(log, "Restarting of the ssh daemon failed") if len(errors): log.debug("%s errors occured, re-raising the last one", len(errors)) raise errors[-1] def rand_user_password(pwlen=9): return util.rand_str(pwlen, select_from=PW_SET)
Save
cmd:
run