author | David Douard <david.douard@logilab.fr> |
Mon, 09 May 2016 17:05:14 +0200 | |
changeset 11235 | 636a83e65870 |
parent 8522 | 85b1c4b36d1d |
child 10589 | 7c23b7de2b8d |
permissions | -rw-r--r-- |
8522
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
1 |
from logilab.common.shellutils import generate_password |
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
2 |
from cubicweb.server.utils import crypt_password |
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
3 |
|
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
4 |
for user in rql('CWUser U WHERE U cw_source S, S name "system", U upassword P, U login L').entities(): |
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
5 |
salt = user.upassword.getvalue() |
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
6 |
if crypt_password('', salt) == salt: |
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
7 |
passwd = generate_password() |
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
8 |
print 'setting random password for user %s' % user.login |
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
9 |
user.set_attributes(upassword=passwd) |
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
10 |
|
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
11 |
commit() |