summaryrefslogtreecommitdiff
path: root/azurelinuxagent/distro/default/osutil.py
diff options
context:
space:
mode:
authorBen Howard <ben.howard@ubuntu.com>2015-12-07 16:48:51 -0700
committerusd-importer <ubuntu-server@lists.ubuntu.com>2015-12-08 16:10:11 +0000
commit542c7a834728ad35d7f5f98cacdf78d86721656f (patch)
tree6850cbc7ce3dec800c1b50f23da6b76077198159 /azurelinuxagent/distro/default/osutil.py
parentf6e3f158c2fb9021b37654ea20839ec7a4308d52 (diff)
parentf4e6aca60e419eafbdf11bdd631d35cf785735ae (diff)
downloadvyos-walinuxagent-542c7a834728ad35d7f5f98cacdf78d86721656f.tar.gz
vyos-walinuxagent-542c7a834728ad35d7f5f98cacdf78d86721656f.zip
Import patches-applied version 2.1.2-0ubuntu1 to applied/ubuntu/xenial-proposed
Imported using git-ubuntu import. Changelog parent: f6e3f158c2fb9021b37654ea20839ec7a4308d52 Unapplied parent: f4e6aca60e419eafbdf11bdd631d35cf785735ae New changelog entries: * New upstream release (LP: #1523715): - Bug fixes for Ubuntu 15.10 on Azure - Enablement for Azure Stack - Dropped patch for systemd job as upstream now includes it.
Diffstat (limited to 'azurelinuxagent/distro/default/osutil.py')
-rw-r--r--azurelinuxagent/distro/default/osutil.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/azurelinuxagent/distro/default/osutil.py b/azurelinuxagent/distro/default/osutil.py
index 8e3fb77..00a57cc 100644
--- a/azurelinuxagent/distro/default/osutil.py
+++ b/azurelinuxagent/distro/default/osutil.py
@@ -117,22 +117,16 @@ class DefaultOSUtil(object):
"retcode:{1}, "
"output:{2}").format(username, retcode, out))
- def chpasswd(self, username, password, use_salt=True, salt_type=6,
- salt_len=10):
+ def chpasswd(self, username, password, crypt_id=6, salt_len=10):
if self.is_sys_user(username):
raise OSUtilError(("User {0} is a system user. "
"Will not set passwd.").format(username))
- passwd_hash = textutil.gen_password_hash(password, use_salt, salt_type,
- salt_len)
- try:
- passwd_content = fileutil.read_file(self.passwd_file_path)
- passwd = passwd_content.split("\n")
- new_passwd = [x for x in passwd if not x.startswith(username)]
- new_passwd.append("{0}:{1}:14600::::::".format(username, passwd_hash))
- fileutil.write_file(self.passwd_file_path, "\n".join(new_passwd))
- except IOError as e:
+ passwd_hash = textutil.gen_password_hash(password, crypt_id, salt_len)
+ cmd = "usermod -p '{0}' {1}".format(passwd_hash, username)
+ ret, output = shellutil.run_get_output(cmd, log_cmd=False)
+ if ret != 0:
raise OSUtilError(("Failed to set password for {0}: {1}"
- "").format(username, e))
+ "").format(username, output))
def conf_sudoer(self, username, nopasswd):
# for older distros create sudoers.d
@@ -344,9 +338,10 @@ class DefaultOSUtil(object):
raise OSUtilError("Failed to umount dvd.")
def eject_dvd(self, chk_err=True):
- retcode = shellutil.run("eject")
+ dvd = self.get_dvd_device()
+ retcode = shellutil.run("eject {0}".format(dvd))
if chk_err and retcode != 0:
- raise OSUtilError("Failed to eject dvd")
+ raise OSUtilError("Failed to eject dvd: ret={0}".format(retcode))
def load_atappix_mod(self):
if self.is_atapiix_mod_loaded():