query="UPDATE user SET password='' WHERE password IS NULL"
try:
run_sql(query)
exceptException,msg:
print'The query "%s" produced: %s'%(query,msg)
returnFalse
returnTrue
def__migrate_column_from_string_to_blob():
query="ALTER TABLE user CHANGE password password BLOB NOT NULL"
try:
run_sql(query)
exceptException,msg:
print'The query "%s" produced: %s'%(query,msg)
returnFalse
returnTrue
def__encrypt_password():
query="UPDATE user SET password=AES_ENCRYPT(email,password)"
try:
run_sql(query)
exceptException,msg:
print'The query "%s" produced: %s'%(query,msg)
returnFalse
returnTrue
def__check_admin(admin_pwd):
query="SELECT nickname FROM user WHERE nickname='admin' AND password=AES_ENCRYPT(email, %s)"
try:
ifrun_sql(query,(admin_pwd,))[0][0]=='admin':
returnTrue
else:
returnFalse
exceptException,msg:
print'The query "%s" produced: %s'%(query,msg)
returnFalse
def__creating_backup():
query="CREATE TABLE user_backup (PRIMARY KEY id (id)) SELECT * FROM user"
try:
run_sql(query)
exceptException,msg:
print'The query "%s" produced: %s'%(query,msg)
returnFalse
returnTrue
def__removing_backup():
query="DROP TABLE user_backup"
try:
run_sql(query)
exceptException,msg:
print'The query "%s" produced: %s'%(query,msg)
returnFalse
returnTrue
def__restoring_from_backup():
query="UPDATE user SET password=''"
try:
run_sql(query)
exceptException,msg:
print'The query "%s" produced: %s'%(query,msg)
returnFalse
query="ALTER TABLE user CHANGE password password varchar(20) NULL default NULL"
try:
run_sql(query)
exceptException,msg:
print'The query "%s" produced: %s'%(query,msg)
returnFalse
query="UPDATE user,user_backup SET user.password=user_backup.password WHERE user.id=user_backup.id AND user.nickname=user_backup.nickname"
try:
run_sql(query)
exceptException,msg:
print'The query "%s" produced: %s'%(query,msg)
returnFalse
returnTrue
def__print_error(restore_backup=False):
printwrap_text_in_a_box("The kit encountered errors in migrating passwords. Please contact The CDS Invenio developers in order to get support providing all the printed messages.")
ifrestore_backup:
if__restoring_from_backup():
printwrap_text_in_a_box("Passwords were restored from the backup, but you still need to migrate them in order to use this version of CDS Invenio.")
else:
printwrap_text_in_a_box("The kit was't unable to restore passwords from the backup")