diff mbox series

[v2,2/5] tst_lockdown_enabled: Print lockdown state

Message ID 20230721091515.1353371-3-pvorel@suse.cz
State Accepted
Headers show
Series Add .skip_in_secureboot flag | expand

Commit Message

Petr Vorel July 21, 2023, 9:15 a.m. UTC
This will be used to simplify .skip_in_lockdown in next commit.

Suggested-by: Martin Doucha <mdoucha@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 lib/tst_lockdown.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Martin Doucha July 25, 2023, 11:04 a.m. UTC | #1
Hi,
Printing "Kernel lockdown: %s" instead would make more sense to the 
user. But that can be fixed during merge.

Reviewed-by: Martin Doucha <mdoucha@suse.cz>

On 21. 07. 23 11:15, Petr Vorel wrote:
> This will be used to simplify .skip_in_lockdown in next commit.
> 
> Suggested-by: Martin Doucha <mdoucha@suse.cz>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>   lib/tst_lockdown.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/tst_lockdown.c b/lib/tst_lockdown.c
> index 4ce4736c3..8f2ee6762 100644
> --- a/lib/tst_lockdown.c
> +++ b/lib/tst_lockdown.c
> @@ -47,6 +47,7 @@ int tst_lockdown_enabled(void)
>   {
>   	char line[BUFSIZ];
>   	FILE *file;
> +	int ret;
>   
>   	if (access(PATH_LOCKDOWN, F_OK) != 0) {
>   		char flag;
> @@ -65,5 +66,8 @@ int tst_lockdown_enabled(void)
>   		tst_brk(TBROK | TERRNO, "fgets %s", PATH_LOCKDOWN);
>   	SAFE_FCLOSE(file);
>   
> -	return (strstr(line, "[none]") == NULL);
> +	ret = strstr(line, "[none]") == NULL;
> +	tst_res(TINFO, "Lockdown: %s", ret ? "on" : "off");
> +
> +	return ret;
>   }
Petr Vorel July 25, 2023, 11:05 a.m. UTC | #2
Hi Martin,

> Hi,
> Printing "Kernel lockdown: %s" instead would make more sense to the user.
> But that can be fixed during merge.

+1, I'll fix that during merge.

Kind regards,
Petr

...
> > +	tst_res(TINFO, "Lockdown: %s", ret ? "on" : "off");
Petr Vorel July 25, 2023, 12:20 p.m. UTC | #3
Hi Martin,

> Hi,
> Printing "Kernel lockdown: %s" instead would make more sense to the user.
> But that can be fixed during merge.

Thanks for all suggestions, fixed and merged.

Kind regards,
Petr
diff mbox series

Patch

diff --git a/lib/tst_lockdown.c b/lib/tst_lockdown.c
index 4ce4736c3..8f2ee6762 100644
--- a/lib/tst_lockdown.c
+++ b/lib/tst_lockdown.c
@@ -47,6 +47,7 @@  int tst_lockdown_enabled(void)
 {
 	char line[BUFSIZ];
 	FILE *file;
+	int ret;
 
 	if (access(PATH_LOCKDOWN, F_OK) != 0) {
 		char flag;
@@ -65,5 +66,8 @@  int tst_lockdown_enabled(void)
 		tst_brk(TBROK | TERRNO, "fgets %s", PATH_LOCKDOWN);
 	SAFE_FCLOSE(file);
 
-	return (strstr(line, "[none]") == NULL);
+	ret = strstr(line, "[none]") == NULL;
+	tst_res(TINFO, "Lockdown: %s", ret ? "on" : "off");
+
+	return ret;
 }