Skip to content

Commit

Permalink
plugins/sed: add sid password change
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
gjoyce-ibm authored and igaw committed Oct 9, 2024
1 parent 9465ffc commit 8dfa127
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions plugins/sed/sedopal_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ int sedopal_set_key(struct opal_key *key)
key->key_type = OPAL_INCLUDED;
#endif
key->key_len = strlen(pass);
memcpy(key->key, pass, key->key_len);
memcpy(key->key, pass, key->key_len + 1);

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

/*
* set admin1 password
*/
rc = ioctl(fd, IOC_OPAL_SET_PW, &new_pw);
if (rc != 0)
if (rc != 0) {
fprintf(stderr, "Error: failed setting password - %d\n", rc);
return rc;
}

#ifdef IOC_OPAL_SET_SID_PW
/*
* set sid password
*/
rc = ioctl(fd, IOC_OPAL_SET_SID_PW, &new_pw);
if (rc != 0)
fprintf(stderr, "Error: failed setting SID password - %d\n", rc);
#endif

return rc;
}
Expand Down

0 comments on commit 8dfa127

Please sign in to comment.