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 <behlendorf1@llnl.gov>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes openzfs#8905
Closes openzfs#8935
  • Loading branch information
Tom Caputi authored and tonyhutter committed Sep 17, 2019
1 parent b0d0528 commit a9c4713
Show file tree
Hide file tree
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
Expand Up @@ -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,
Expand Down
8 changes: 6 additions & 2 deletions module/zfs/dsl_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a9c4713

Please sign in to comment.