]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
sed: update SED password when initalizing
authorGreg Joyce <gjoyce@linux.ibm.com>
Wed, 27 Mar 2024 17:40:53 +0000 (12:40 -0500)
committerDaniel Wagner <wagi@monom.org>
Thu, 28 Mar 2024 07:27:51 +0000 (08:27 +0100)
The SED key and kernel keyring were not being updated by the
initialization operation. Add password update after the other
initialization tasks are completed.

Signed-off-by: Greg Joyce <gjoyce@linux.ibm.com>
plugins/sed/sedopal_cmd.c

index 17c0c854de44a3da8937b5427b03d7f392763774..21ebd360c21935404e8c67bc7ba6e9fd310fd395 100644 (file)
@@ -169,6 +169,7 @@ int sedopal_cmd_initialize(int fd)
        struct opal_key key;
        struct opal_lr_act lr_act = {};
        struct opal_user_lr_setup lr_setup = {};
+       struct opal_new_pw new_pw = {};
 
        sedopal_ask_key = true;
        sedopal_ask_new_key = true;
@@ -218,6 +219,21 @@ int sedopal_cmd_initialize(int fd)
                return rc;
        }
 
+       /*
+        * set password
+        */
+       new_pw.new_user_pw.who = OPAL_ADMIN1;
+       new_pw.new_user_pw.opal_key.lr = 0;
+       new_pw.session.who = OPAL_ADMIN1;
+       new_pw.session.sum = 0;
+       new_pw.session.opal_key.lr = 0;
+       new_pw.session.opal_key = key;
+       new_pw.new_user_pw.opal_key = key;
+
+       rc = ioctl(fd, IOC_OPAL_SET_PW, &new_pw);
+       if (rc != 0)
+               fprintf(stderr, "Error: failed setting password - %d\n", rc);
+
        return rc;
 }