libzfs: report permission error from umount helper

Non-root callers got "unmount failed" when ZFS_MOUNT_HELPER was set
because /bin/umount's exit status doesn't preserve errno.  Map a
non-zero helper exit to EPERM when geteuid() != 0 so the user sees
"permission denied".

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Christos Longros <[email protected]>
Closes #11740
Closes #18443
This commit is contained in:
Christos Longros authored and GitHub committed 2026-04-20 10:02:26 -07:00
1 parent 9be5431c5d
commit 7fdd2bf7d4
1 file changed
+5 -1
+5 -1
View File
@@ -406,7 +406,11 @@ do_unmount(zfs_handle_t *zhp, const char *mntpt, int flags)
argv[count] = (char *)mntpt;
rc = libzfs_run_process(argv[0], argv, STDOUT_VERBOSE|STDERR_VERBOSE);
return (rc ? EINVAL : 0);
if (rc == 0)
return (0);
if (rc > 0 && geteuid() != 0)
return (EPERM);
return (EINVAL);
}
#ifdef HAVE_MOUNT_SETATTR