egdb3_11_7
.actor
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
migrate_passwd(pw_usr integer)
Parameters
Name
Type
Mode
pw_usr
integer
IN
Definition
DECLARE pw_salt TEXT; usr_row actor.usr%ROWTYPE; BEGIN /* Migrates legacy actor.usr.passwd value to actor.passwd with * a password type 'main' and returns the new salt. For backwards * compatibility with existing CHAP-style API's, we perform a * layer of intermediate MD5(MD5()) hashing. This is intermediate * hashing is not required of other passwords. */ -- Avoid calling get_salt() here, because it may result in a -- migrate_passwd() call, creating a loop. SELECT INTO pw_salt salt FROM actor.passwd WHERE usr = pw_usr AND passwd_type = 'main'; -- Only migrate passwords that have not already been migrated. IF FOUND THEN RETURN pw_salt; END IF; SELECT INTO usr_row * FROM actor.usr WHERE id = pw_usr; pw_salt := actor.create_salt('main'); PERFORM actor.set_passwd( pw_usr, 'main', MD5(pw_salt || usr_row.passwd), pw_salt); -- clear the existing password UPDATE actor.usr SET passwd = '' WHERE id = usr_row.id; RETURN pw_salt; END;