Skip to content

Commit

Permalink
Fix error message on promoting encrypted dataset
Browse files Browse the repository at this point in the history
This patch corrects the error message reported when attempting
to promote a dataset outside of its encryption root.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Tom Caputi <[email protected]>
Closes #8905
Closes #8935
  • Loading branch information
Tom Caputi authored and tonyhutter committed Sep 25, 2019
1 parent cc7fe8a commit bfe5f02
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 10 additions & 0 deletions lib/libzfs/libzfs_dataset.c
Original file line number Diff line number Diff line change
@@ -4117,6 +4117,16 @@ zfs_promote(zfs_handle_t *zhp)

if (ret != 0) {
switch (ret) {
case EACCES:
/*
* Promoting encrypted dataset outside its
* encryption root.
*/
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"cannot promote dataset outside its "
"encryption root"));
return (zfs_error(hdl, EZFS_EXISTS, errbuf));

case EEXIST:
/* There is a conflicting snapshot name. */
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
8 changes: 6 additions & 2 deletions module/zfs/dsl_crypt.c
Original file line number Diff line number Diff line change
@@ -1676,11 +1676,15 @@ dsl_dataset_promote_crypt_check(dsl_dir_t *target, dsl_dir_t *origin)
* Check that the parent of the target has the same encryption root.
*/
ret = dsl_dir_get_encryption_root_ddobj(origin->dd_parent, &op_rddobj);
if (ret != 0)
if (ret == ENOENT)
return (SET_ERROR(EACCES));
else if (ret != 0)
return (ret);

ret = dsl_dir_get_encryption_root_ddobj(target->dd_parent, &tp_rddobj);
if (ret != 0)
if (ret == ENOENT)
return (SET_ERROR(EACCES));
else if (ret != 0)
return (ret);

if (op_rddobj != tp_rddobj)

0 comments on commit bfe5f02

Please sign in to comment.