author | Julien Cristau <julien.cristau@logilab.fr> |
Tue, 05 Jan 2016 10:36:17 +0100 | |
changeset 11082 | 0cdd92261c4a |
parent 10589 | 7c23b7de2b8d |
permissions | -rw-r--r-- |
10589
7c23b7de2b8d
[py3k] print function
Samuel Trégouët <samuel.tregouet@logilab.fr>
parents:
8522
diff
changeset
|
1 |
from __future__ import print_function |
7c23b7de2b8d
[py3k] print function
Samuel Trégouët <samuel.tregouet@logilab.fr>
parents:
8522
diff
changeset
|
2 |
|
8522
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
3 |
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
|
4 |
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
|
5 |
|
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
6 |
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
|
7 |
salt = user.upassword.getvalue() |
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
8 |
if crypt_password('', salt) == salt: |
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
9 |
passwd = generate_password() |
10589
7c23b7de2b8d
[py3k] print function
Samuel Trégouët <samuel.tregouet@logilab.fr>
parents:
8522
diff
changeset
|
10 |
print('setting random password for user %s' % user.login) |
8522
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
11 |
user.set_attributes(upassword=passwd) |
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
12 |
|
85b1c4b36d1d
migration: replace empty passwords with random ones on upgrade
Julien Cristau <julien.cristau@logilab.fr>
parents:
diff
changeset
|
13 |
commit() |