Skip to content

Commit 8dfa127

Browse files
gjoyce-ibmigaw
authored andcommitted
plugins/sed: add sid password change
The existing ioctl to change password only updated the admin1 password. Add using a new ioctl IOC_OPAL_SET_SID_PW to also update the sid password so that sid and admin1 passwords are kept in sync. Signed-off-by: Greg Joyce <gjoyce@linux.ibm.com>
1 parent 9465ffc commit 8dfa127

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

plugins/sed/sedopal_cmd.c

+16-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ int sedopal_set_key(struct opal_key *key)
134134
key->key_type = OPAL_INCLUDED;
135135
#endif
136136
key->key_len = strlen(pass);
137-
memcpy(key->key, pass, key->key_len);
137+
memcpy(key->key, pass, key->key_len + 1);
138138

139139
/*
140140
* If getting a new key, ask for it to be re-entered
@@ -446,9 +446,23 @@ int sedopal_cmd_password(int fd)
446446
if (sedopal_set_key(&new_pw.new_user_pw.opal_key) != 0)
447447
return -EINVAL;
448448

449+
/*
450+
* set admin1 password
451+
*/
449452
rc = ioctl(fd, IOC_OPAL_SET_PW, &new_pw);
450-
if (rc != 0)
453+
if (rc != 0) {
451454
fprintf(stderr, "Error: failed setting password - %d\n", rc);
455+
return rc;
456+
}
457+
458+
#ifdef IOC_OPAL_SET_SID_PW
459+
/*
460+
* set sid password
461+
*/
462+
rc = ioctl(fd, IOC_OPAL_SET_SID_PW, &new_pw);
463+
if (rc != 0)
464+
fprintf(stderr, "Error: failed setting SID password - %d\n", rc);
465+
#endif
452466

453467
return rc;
454468
}

0 commit comments

Comments
 (0)