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 messgae reported when attempting
to promote a dataset outside of its encryption root.

Fixes: 8905

Signed-off-by: Tom Caputi <tcaputi@datto.com>
  • Loading branch information
Tom Caputi committed Jun 19, 2019
1 parent df24bcf commit e59377d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions lib/libzfs/libzfs_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -4107,6 +4107,13 @@ zfs_promote(zfs_handle_t *zhp)

if (ret != 0) {
switch (ret) {
case EACCES:
/* There is a conflicting snapshot name. */
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"cannot move 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 @@ -1683,11 +1683,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 e59377d

Please sign in to comment.