summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuerg Haefliger <juergh@gmail.com>2013-06-26 09:51:59 +0200
committerJuerg Haefliger <juergh@gmail.com>2013-06-26 09:51:59 +0200
commitc8eb622ae0c3f9fab2b25112aa87a2dbf39788db (patch)
treea49ce4b098ea19b68d8dcc1a80e36c1fd0bbd2a7
parenta8e22f5707248671116b6cfea42608137e1c1873 (diff)
downloadvyos-cloud-init-c8eb622ae0c3f9fab2b25112aa87a2dbf39788db.tar.gz
vyos-cloud-init-c8eb622ae0c3f9fab2b25112aa87a2dbf39788db.zip
Use short option names for passwd utilities
SLES 11 doesn't support long option names for the passwd utilities. Use the short option names in the parent distro class and remove the custom SLES methods.
-rw-r--r--cloudinit/distros/__init__.py10
-rw-r--r--cloudinit/distros/sles.py28
2 files changed, 8 insertions, 30 deletions
diff --git a/cloudinit/distros/__init__.py b/cloudinit/distros/__init__.py
index ef5db86b..f8727fc1 100644
--- a/cloudinit/distros/__init__.py
+++ b/cloudinit/distros/__init__.py
@@ -386,7 +386,10 @@ class Distro(object):
Lock the password of a user, i.e., disable password logins
"""
try:
- util.subp(['passwd', '--lock', name])
+ # Need to use the short option name '-l' instead of '--lock'
+ # (which would be more descriptive) since SLES 11 doesn't know
+ # about long names.
+ util.subp(['passwd', '-l', name])
except Exception as e:
util.logexc(LOG, 'Failed to disable password for user %s', name)
raise e
@@ -396,7 +399,10 @@ class Distro(object):
cmd = ['chpasswd']
if hashed:
- cmd.append('--encrypted')
+ # Need to use the short option name '-e' instead of '--encrypted'
+ # (which would be more descriptive) since SLES 11 doesn't know
+ # about long names.
+ cmd.append('-e')
try:
util.subp(cmd, pass_string, logstring="chpasswd for %s" % user)
diff --git a/cloudinit/distros/sles.py b/cloudinit/distros/sles.py
index e068b4bd..95bc411a 100644
--- a/cloudinit/distros/sles.py
+++ b/cloudinit/distros/sles.py
@@ -196,31 +196,3 @@ class Distro(distros.Distro):
def update_package_sources(self):
self._runner.run("update-sources", self.package_command,
['refresh'], freq=PER_INSTANCE)
-
- # Copied from parent class and modified to use short option names since
- # the SLES command doesn't support long names (yet). This method can be
- # removed when SLES finally catches up.
- def lock_passwd(self, name):
- """
- Lock the password of a user, i.e., disable password logins
- """
- try:
- util.subp(['passwd', '-l', name])
- except Exception as e:
- util.logexc(LOG, 'Failed to disable password for user %s', name)
- raise e
-
- # Copied from parent class and modified to use short option names since
- # the SLES command doesn't support long names (yet). This method can be
- # removed when SLES finally catches up.
- def set_passwd(self, user, passwd, hashed=False):
- pass_string = '%s:%s' % (user, passwd)
- cmd = ['chpasswd']
- if hashed:
- cmd.append('-e')
- try:
- util.subp(cmd, pass_string, logstring="chpasswd for %s" % user)
- except Exception as e:
- util.logexc(LOG, "Failed to set password for %s", user)
- raise e
- return True