From af7e55034c9a558bd9b5ab70e63b1865c78f5cfa Mon Sep 17 00:00:00 2001 From: Sugumaran L Date: Fri, 22 Oct 2021 17:36:11 +0900 Subject: [PATCH] warning messages requested by the BIOS team --- thinklmi-user/thinklmi.c | 45 ++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/thinklmi-user/thinklmi.c b/thinklmi-user/thinklmi.c index 30a6ebd..1036fbf 100644 --- a/thinklmi-user/thinklmi.c +++ b/thinklmi-user/thinklmi.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "../thinklmi-kernel/think-lmi.h" @@ -66,15 +67,22 @@ void thinklmi_get(int fd, char * argv2) void thinklmi_set(int fd, char * argv2, char* argv3) { char setting_string[TLMI_GETSET_MAXLEN]; - strncpy(setting_string, argv2, TLMI_SETTINGS_MAXLEN); - strcat(setting_string, ","); - strncat(setting_string, argv3, TLMI_SETTINGS_MAXLEN); + char option; - if(ioctl(fd, THINKLMI_SET_SETTING, &setting_string) == -1) { - perror("Unable to change setting"); - } else { - printf("BIOS Setting changed\n"); - printf("Setting will not change until reboot\n"); + printf("Please check whether the setting name is Valid\n"); + printf("please complete authentication if BIOS password is set\n"); + printf("Do you want to continue (Y/N):"); + scanf("%c", &option); + if(tolower(option) == 'y' && tolower(option) != 'n') { + strncpy(setting_string, argv2, TLMI_SETTINGS_MAXLEN); + strcat(setting_string, ","); + strncat(setting_string, argv3, TLMI_SETTINGS_MAXLEN); + if(ioctl(fd, THINKLMI_SET_SETTING, &setting_string) == -1) { + perror("Unable to change setting"); + } else { + printf("BIOS Setting changed\n"); + printf("Setting will not change until reboot\n"); + } } } @@ -132,14 +140,21 @@ void thinklmi_lmiopcode(int fd, char *admin, char *passtype, char *oldpass, char void thinklmi_tpmtype(int fd, char *tpmtype) { char setting_string[TLMI_GETSET_MAXLEN]; - snprintf(setting_string, TLMI_GETSET_MAXLEN, "%s;", tpmtype); - if(ioctl(fd, THINKLMI_TPMTYPE, &setting_string) == -1) { - perror("Tpm type change failed"); - } else { - printf("Tpm type changed\n"); - printf("Setting will not change until reboot\n"); - } + char option; + printf("Before switching TPM, please make sure the TPM is not in use and all TPM related applications\n"); + printf("must be disabled, otherwise the TPM will be cleared and you may not be able to access your data\n"); + printf("\n Do you wish to continue(Y/N):"); + scanf("%c", &option); + if(tolower(option) == 'y' && tolower(option) != 'n') { + snprintf(setting_string, TLMI_GETSET_MAXLEN, "%s;", tpmtype); + if(ioctl(fd, THINKLMI_TPMTYPE, &setting_string) == -1) { + perror("Tpm type change failed"); + } else { + printf("Tpm type changed\n"); + printf("Setting will not change until reboot\n"); + } + } } void thinklmi_load_default(int fd)