efibootmgr: provide explicit error message if run as non-root

This should be less confusing for new users.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42213
This commit is contained in:
Ed Maste 2023-10-15 13:21:52 -04:00
parent 6ace92326f
commit c08ba4a588

View file

@ -1101,8 +1101,11 @@ main(int argc, char *argv[])
/*
* find_dev can operate without any efi variables
*/
if (!efi_variables_supported() && !opts.find_dev)
errx(1, "efi variables not supported on this system. root? kldload efirt?");
if (!efi_variables_supported() && !opts.find_dev) {
if (errno == EACCES && geteuid() != 0)
errx(1, "must be run as root");
errx(1, "efi variables not supported on this system. kldload efirt?");
}
read_vars();