summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklós Márton <martonmiklosqdev@gmail.com>2022-03-16 23:04:46 +0100
committerAnastasia Klimchuk <aklm@chromium.org>2023-05-29 00:35:53 +0000
commitb09aad573b6a92087141ee1f4c8f86a0abaa75d5 (patch)
tree437f01ac41535afebc1dcda8196d5791bee86823
parent385b3374e37fe1919177978a32fe2f48f2217817 (diff)
downloadflashrom-b09aad573b6a92087141ee1f4c8f86a0abaa75d5.tar.gz
flashrom-b09aad573b6a92087141ee1f4c8f86a0abaa75d5.tar.bz2
flashrom-b09aad573b6a92087141ee1f4c8f86a0abaa75d5.zip
hwaccess_x86_io: Improve IO permission error messages
- Display the BSD hints only when compiled for a specific BSD - On Linux check the user's uid to see if flashrom run with root privileges - Add a note about the dmesg check if the flashrom run as root and have no IO privilege TEST=Run flashrom with internal programmed on a Secure boot enabled machine. You should not get the privilege level error, but rather a suggestion about the security policies. Change-Id: I6a6f60a5f0ac8f2b51c74661f7dad30571819680 Signed-off-by: Miklós Márton <martonmiklosqdev@gmail.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/62878 Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Peter Marheine <pmarheine@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r--hwaccess_x86_io.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/hwaccess_x86_io.c b/hwaccess_x86_io.c
index a883ed418..93d29d82d 100644
--- a/hwaccess_x86_io.c
+++ b/hwaccess_x86_io.c
@@ -66,6 +66,7 @@
#if defined(__linux__) && !defined(__ANDROID__)
#include <sys/io.h>
+#include <unistd.h>
#define IO_PORT_PERMISSION USE_IOPL
#define IO_PORT_FUNCTION USE_LIBC_TARGET_LAST
@@ -263,13 +264,24 @@ int rget_io_perms(void)
register_shutdown(platform_release_io_perms, NULL);
return 0;
}
+
msg_perr("ERROR: Could not get I/O privileges (%s).\n", strerror(errno));
- msg_perr("Make sure you are root. If you are root, your kernel may still\n"
- "prevent access based on security policies.\n");
+#if defined(__linux__) && !defined(__ANDROID__)
+ if (getuid() != 0) {
+ msg_perr("Make sure you are running flashrom with root privileges.\n");
+ } else {
+ msg_perr("Your kernel may prevent access based on security policies.\n"
+ "Issue a 'dmesg | grep flashrom' for further information\n");
+ }
+#elif defined(__OpenBSD__)
msg_perr("On OpenBSD set securelevel=-1 in /etc/rc.securelevel and\n"
"reboot, or reboot into single user mode.\n");
+#elif defined(__NetBSD__)
msg_perr("On NetBSD reboot into single user mode or make sure\n"
"that your kernel configuration has the option INSECURE enabled.\n");
+#else
+ msg_perr("Make sure you are running flashrom with root privileges.\n");
+#endif
return 1;
}