~johannes.erdfelt/openstack-guest-agents/gentoo-dns

« back to all changes in this revision

Viewing changes to unix/commands/password.py

  • Committer: Johannes Erdfelt
  • Date: 2012-02-13 17:26:31 UTC
  • mfrom: (108.1.1 trunk)
  • Revision ID: johannes.erdfelt@rackspace.com-20120213172631-k9fgpu4igmtgzwqh
MergeĀ lp:~johannes.erdfelt/openstack-guest-agents/lp931507

Show diffs side-by-side

added added

removed removed

Lines of Context:
259
259
                f.write(line)
260
260
                continue
261
261
            if s_password.startswith('$'):
262
 
                # Format is '$ID$SALT$PASSWORD$' where ID defines the
 
262
                # Format is '$ID$SALT$HASH' where ID defines the
263
263
                # ecnryption type.  We'll re-use that, and make a salt
264
264
                # that's the same size as the old
265
 
                salt_data = s_password.split('$')
266
 
                # salt_data[0] will be '', [1] will be ID, [2] will be salt
267
 
                salt = '$%s$%s$' % (salt_data[1],
268
 
                        _make_salt(len(salt_data[2])))
 
265
                salt_data = s_password[1:].split('$')
 
266
                salt = '$%s$%s$' % (salt_data[0],
 
267
                        _make_salt(len(salt_data[1])))
269
268
            else:
270
 
                salt = _make_salt(2)
 
269
                # Default to MD5 as a minimum level of compatibility
 
270
                salt = '$1$%s$' % _make_salt(8)
271
271
            enc_pass = agentlib.encrypt_password(password, salt)
272
272
            f.write("%s:%s:%s" % (s_user, enc_pass, s_rest))
273
273
        f.close()