Skip to content

Commit ced2164

Browse files
committed
pivy-zfs: support falling back to com.joyent.kbm:ebox property
Makes it a bit easier to import a smartos/triton encrypted pool on another machine.
1 parent ecc5bec commit ced2164

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

pivy-zfs.c

+15-6
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,11 @@ cmd_unlock(const char *fsname)
227227
#endif
228228

229229
rc = nvlist_lookup_nvlist(props, "rfd77:ebox", &prop);
230+
if (rc)
231+
rc = nvlist_lookup_nvlist(props, "com.joyent.kbm:ebox", &prop);
230232
if (rc) {
231-
errx(EXIT_ERROR, "no rfd77:ebox property "
232-
"could be read on dataset %s", fsname);
233+
errx(EXIT_ERROR, "no ebox property could be read on "
234+
"dataset %s", fsname);
233235
}
234236

235237
VERIFY0(nvlist_lookup_string(prop, "value", &b64));
@@ -359,6 +361,7 @@ cmd_rekey(const char *fsname)
359361
const uint8_t *key = NULL;
360362
const uint8_t *nkey;
361363
size_t keylen, nkeylen;
364+
const char *propname;
362365
#if defined(DMU_OT_ENCRYPTED)
363366
uint64_t kstatus;
364367
nvlist_t *nprops;
@@ -375,9 +378,15 @@ cmd_rekey(const char *fsname)
375378
props = zfs_get_user_props(ds);
376379
VERIFY(props != NULL);
377380

378-
if (nvlist_lookup_nvlist(props, "rfd77:ebox", &prop)) {
379-
errx(EXIT_ERROR, "no rfd77:ebox property "
380-
"could be read on dataset %s", fsname);
381+
propname = "rfd77:ebox";
382+
rc = nvlist_lookup_nvlist(props, propname, &prop);
383+
if (rc) {
384+
propname = "com.joyent.kbm:ebox";
385+
rc = nvlist_lookup_nvlist(props, propname, &prop);
386+
}
387+
if (rc) {
388+
errx(EXIT_ERROR, "no ebox property could be read on "
389+
"dataset %s", fsname);
381390
}
382391

383392
VERIFY0(nvlist_lookup_string(prop, "value", &b64));
@@ -458,7 +467,7 @@ cmd_rekey(const char *fsname)
458467

459468
b64 = sshbuf_dtob64(buf);
460469

461-
rc = zfs_prop_set(ds, "rfd77:ebox", b64);
470+
rc = zfs_prop_set(ds, propname, b64);
462471
if (rc != 0) {
463472
errno = rc;
464473
err(EXIT_ERROR, "failed to set ZFS property rfd77:ebox "

0 commit comments

Comments
 (0)