From 9bb6b3acdf45a99a7a5c89e22b4f23ca7091845e Mon Sep 17 00:00:00 2001 From: Vladimir Stoiakin Date: Thu, 13 Mar 2025 12:47:16 +0300 Subject: [PATCH 01/10] unl0kr: add the CLI option to avoid suffixing a password with a newline character Appending the newline character '\n' is the right thing to do when you print a password to a tty or a text file. But different tools process it differently. For example, cryptsetup strips the newline character, but systemd-cryptsetup with a password agent does not. This commit allows to control the newline character with an option. --- man/unl0kr.1.scd | 10 ++++++---- unl0kr/command_line.c | 7 ++++++- unl0kr/command_line.h | 2 ++ unl0kr/main.c | 2 +- unl0kr/unl0kr-agent.c | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/man/unl0kr.1.scd b/man/unl0kr.1.scd index 7aa9ed5..65c30ab 100644 --- a/man/unl0kr.1.scd +++ b/man/unl0kr.1.scd @@ -32,7 +32,7 @@ password is printed to STDOUT. All other output happens on STDERR. *-g, --geometry=NxM[@X,Y]* Force a display size of N horizontal times M vertical pixels, offset horizontally by X pixels and vertically by Y pixels. -*-d --dpi=N* +*-d --dpi=N* Override the display's DPI value. *-r, --rotate=[0-3]* Rotate the UI to the given orientation. The @@ -42,11 +42,13 @@ password is printed to STDOUT. All other output happens on STDERR. * 1 - clockwise orientation (90 degrees) * 2 - upside down orientation (180 degrees) * 3 - counterclockwise orientation (270 degrees) -*-h, --help* +*-h, --help* Print this message and exit. -*-v, --verbose* +*-n* + Do not append a newline character to a password. +*-v, --verbose* Enable more detailed logging output on STDERR. -*-V, --version* +*-V, --version* Print the unl0kr version and exit. # EXAMPLES diff --git a/unl0kr/command_line.c b/unl0kr/command_line.c index 9d8f4c5..100a826 100644 --- a/unl0kr/command_line.c +++ b/unl0kr/command_line.c @@ -45,6 +45,7 @@ static void init_opts(ul_cli_opts *opts) { opts->y_offset = 0; opts->dpi = 0; opts->rotation = LV_DISPLAY_ROTATION_0; + opts->newline = true; opts->verbose = false; } @@ -77,6 +78,7 @@ static void print_usage() { " * 2 - upside down orientation (180 degrees)\n" " * 3 - counterclockwise orientation (270 degrees)\n" " -h, --help Print this message and exit\n" + " -n Do not append a newline character to a password\n" " -v, --verbose Enable more detailed logging output on STDERR\n" " -V, --version Print the unl0kr version and exit\n"); /*-------------------------------- 78 CHARS --------------------------------*/ @@ -103,7 +105,7 @@ void ul_cli_parse_opts(int argc, char *argv[], ul_cli_opts *opts) { int opt, index = 0; - while ((opt = getopt_long(argc, argv, "C:g:d:r:hvV", long_opts, &index)) != -1) { + while ((opt = getopt_long(argc, argv, "C:g:d:r:hnvV", long_opts, &index)) != -1) { switch (opt) { case 'C': opts->config_files = realloc(opts->config_files, (opts->num_config_files + 1) * sizeof(char *)); @@ -153,6 +155,9 @@ void ul_cli_parse_opts(int argc, char *argv[], ul_cli_opts *opts) { case 'h': print_usage(); exit(EXIT_SUCCESS); + case 'n': + opts->newline = false; + break; case 'v': opts->verbose = true; break; diff --git a/unl0kr/command_line.h b/unl0kr/command_line.h index b9cea7e..c6e075f 100644 --- a/unl0kr/command_line.h +++ b/unl0kr/command_line.h @@ -30,6 +30,8 @@ typedef struct { int dpi; /* Display rotation */ lv_display_rotation_t rotation; + /* If true, append a newline character to a password */ + bool newline; /* Verbose mode. If true, provide more detailed logging output on STDERR. */ bool verbose; } ul_cli_opts; diff --git a/unl0kr/main.c b/unl0kr/main.c index 5e337e1..7e99814 100644 --- a/unl0kr/main.c +++ b/unl0kr/main.c @@ -337,7 +337,7 @@ static void textarea_ready_cb(lv_event_t *event) { static void print_password_and_exit(lv_obj_t *textarea) { /* Print the password to STDOUT */ - printf("%s\n", lv_textarea_get_text(textarea)); + printf(cli_opts.newline? "%s\n" : "%s", lv_textarea_get_text(textarea)); /* Clear the screen so that when the password field was unobscured, it cannot * leak via stale display buffers after we've exited */ diff --git a/unl0kr/unl0kr-agent.c b/unl0kr/unl0kr-agent.c index 6f0b01f..e62edb8 100644 --- a/unl0kr/unl0kr-agent.c +++ b/unl0kr/unl0kr-agent.c @@ -418,7 +418,7 @@ int exec_unl0kr(char** ret_password) exit(EXIT_FAILURE); } - execl(UNL0KR_BINARY, "unl0kr", (char*) 0); + execl(UNL0KR_BINARY, UNL0KR_BINARY, "-n", (char*) 0); perror("exec() is failed"); exit(EXIT_FAILURE); From 1f0c30e88dc61b8b508696cd890393c3b7911b58 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 22 Mar 2025 20:47:14 +0000 Subject: [PATCH 02/10] man: use tabs instead of spaces (fixes build) otherwise sc-doc errors: > FAILED: man/unl0kr.1 > meson --internal exe --capture man/unl0kr.1 --feed ../man/unl0kr.1.scd -- scdoc > --- stderr --- > Error at 48:1: Tabs are required for indentation --- man/unl0kr.1.scd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/unl0kr.1.scd b/man/unl0kr.1.scd index 65c30ab..523fc61 100644 --- a/man/unl0kr.1.scd +++ b/man/unl0kr.1.scd @@ -45,7 +45,7 @@ password is printed to STDOUT. All other output happens on STDERR. *-h, --help* Print this message and exit. *-n* - Do not append a newline character to a password. + Do not append a newline character to a password. *-v, --verbose* Enable more detailed logging output on STDERR. *-V, --version* From aa28de93b98a1a1d1f029ffe62f3677b724ec583 Mon Sep 17 00:00:00 2001 From: Vladimir Stoiakin Date: Mon, 24 Mar 2025 12:30:44 +0300 Subject: [PATCH 03/10] update the URL of LVGL repository --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index fcb8f14..83e7cf6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "lvgl"] path = lvgl - url = https://github.com/littlevgl/lvgl.git + url = https://github.com/lvgl/lvgl.git From 70509e5b02580c0ae48d145c2a6b9bb3d4a8df5e Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Mon, 24 Mar 2025 19:42:26 +0100 Subject: [PATCH 04/10] Stop CI on first error --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3807a34..f43761d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ build-and-test-with-drm: image: alpine:3.19 script: + - set -e # Stop on first error - apk -q add git bash build-base meson linux-headers inih-dev libinput-dev libxkbcommon-dev libdrm-dev scdoc - git submodule init - git submodule update @@ -9,6 +10,7 @@ build-and-test-with-drm: build-and-test-without-drm: image: alpine:3.19 script: + - set -e # Stop on first error - apk -q add git bash build-base meson linux-headers inih-dev libinput-dev libxkbcommon-dev scdoc - git submodule init - git submodule update @@ -17,6 +19,7 @@ build-and-test-without-drm: build-iskey: image: alpine:3.19 script: + - set -e # Stop on first error - apk -q add git bash build-base meson linux-headers libevdev-dev - cd iskey - meson setup _build From 80d388ebff19fd2ccfb20476bcfd60f839f4b179 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Mon, 24 Mar 2025 19:48:32 +0100 Subject: [PATCH 05/10] Collect exit codes --- test/test-with-drm.sh | 14 +++++++++----- test/test-without-drm.sh | 14 +++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/test/test-with-drm.sh b/test/test-with-drm.sh index 8225510..58fc1b7 100755 --- a/test/test-with-drm.sh +++ b/test/test-with-drm.sh @@ -4,8 +4,12 @@ root=$(dirname "${BASH_SOURCE[0]}") source "$root/helpers.sh" -run_script "$root/build-with-drm.sh" -run_script "$root/test-version-matches-meson-and-changelog.sh" -run_script "$root/test-uses-fb-backend-by-default.sh" -run_script "$root/test-uses-fb-backend-if-selected-via-config.sh" -run_script "$root/test-uses-drm-backend-if-selected-via-config-and-available.sh" +rc=0 + +run_script "$root/build-with-drm.sh" || rc=1 +run_script "$root/test-version-matches-meson-and-changelog.sh" || rc=1 +run_script "$root/test-uses-fb-backend-by-default.sh" || rc=1 +run_script "$root/test-uses-fb-backend-if-selected-via-config.sh" || rc=1 +run_script "$root/test-uses-drm-backend-if-selected-via-config-and-available.sh" || rc=1 + +exit $rc diff --git a/test/test-without-drm.sh b/test/test-without-drm.sh index a8e86c9..3483041 100755 --- a/test/test-without-drm.sh +++ b/test/test-without-drm.sh @@ -4,8 +4,12 @@ root=$(dirname "${BASH_SOURCE[0]}") source "$root/helpers.sh" -run_script "$root/build-without-drm.sh" -run_script "$root/test-version-matches-meson-and-changelog.sh" -run_script "$root/test-uses-fb-backend-by-default.sh" -run_script "$root/test-uses-fb-backend-if-selected-via-config.sh" -run_script "$root/test-uses-fb-backend-if-drm-selected-via-config-but-unavailable.sh" +rc=0 + +run_script "$root/build-without-drm.sh" || rc=1 +run_script "$root/test-version-matches-meson-and-changelog.sh" || rc=1 +run_script "$root/test-uses-fb-backend-by-default.sh" || rc=1 +run_script "$root/test-uses-fb-backend-if-selected-via-config.sh" || rc=1 +run_script "$root/test-uses-fb-backend-if-drm-selected-via-config-but-unavailable.sh" || rc=1 + +exit $rc From a64ef9bad4f9018fca13f668a0cdabac0f438129 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Mon, 24 Mar 2025 19:53:08 +0100 Subject: [PATCH 06/10] Return exit code from run_script --- test/helpers.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/helpers.sh b/test/helpers.sh index 027fca9..7e80e3b 100644 --- a/test/helpers.sh +++ b/test/helpers.sh @@ -58,8 +58,10 @@ function ok() { function run_script() { info "Executing $1" - "$1" + rc=0 + "$1" || rc=1 echo + return $rc } function read_version_from_meson() { From e44dd2412ced16671b9e9bbb7fd3f66d40d55320 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Mon, 24 Mar 2025 19:55:50 +0100 Subject: [PATCH 07/10] Test fix manpage --- man/unl0kr.1.scd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/unl0kr.1.scd b/man/unl0kr.1.scd index 65c30ab..523fc61 100644 --- a/man/unl0kr.1.scd +++ b/man/unl0kr.1.scd @@ -45,7 +45,7 @@ password is printed to STDOUT. All other output happens on STDERR. *-h, --help* Print this message and exit. *-n* - Do not append a newline character to a password. + Do not append a newline character to a password. *-v, --verbose* Enable more detailed logging output on STDERR. *-V, --version* From 5b54f494a65933db52a8e8591d38e1766ce17c93 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Mon, 24 Mar 2025 19:57:14 +0100 Subject: [PATCH 08/10] Revert "Test fix manpage" This reverts commit e44dd2412ced16671b9e9bbb7fd3f66d40d55320. --- man/unl0kr.1.scd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/unl0kr.1.scd b/man/unl0kr.1.scd index 523fc61..65c30ab 100644 --- a/man/unl0kr.1.scd +++ b/man/unl0kr.1.scd @@ -45,7 +45,7 @@ password is printed to STDOUT. All other output happens on STDERR. *-h, --help* Print this message and exit. *-n* - Do not append a newline character to a password. + Do not append a newline character to a password. *-v, --verbose* Enable more detailed logging output on STDERR. *-V, --version* From 2627baeea3f643895714a4811be2c3015de66471 Mon Sep 17 00:00:00 2001 From: Vladimir Stoiakin Date: Mon, 17 Mar 2025 11:18:59 +0300 Subject: [PATCH 09/10] build: do not hardcode endianess of a system --- CHANGELOG.md | 1 + buffyboard/lv_conf.h | 3 --- meson.build | 6 +++++- unl0kr/lv_conf.h | 3 --- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7fabded..12e8b93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ If a change only affects particular applications, they are listed in parentheses - feat(buffyboard): Add a buffyboard.service systemd service (!34, @uninsane) - fix(unl0kr): Select an available DRM device instead of a hard-coded one (!35, thanks @Sorcus) - feat(unl0kr): Enable software rotation (!32, thanks @xs5871 & @craftyguy) +- misc: do not hardcode endianess of a system ## 3.2.0 (2024-06-03) diff --git a/buffyboard/lv_conf.h b/buffyboard/lv_conf.h index 23acdb9..f711ded 100644 --- a/buffyboard/lv_conf.h +++ b/buffyboard/lv_conf.h @@ -313,9 +313,6 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ * COMPILER SETTINGS *====================*/ -/*For big endian systems set to 1*/ -#define LV_BIG_ENDIAN_SYSTEM 0 - /*Define a custom attribute to `lv_tick_inc` function*/ #define LV_ATTRIBUTE_TICK_INC diff --git a/meson.build b/meson.build index 042ab15..3cc51f4 100644 --- a/meson.build +++ b/meson.build @@ -4,7 +4,11 @@ project('buffybox', 'c', meson_version: '>= 0.59.0' ) -add_project_arguments('-DPROJECT_VERSION="@0@"'.format(meson.project_version()), language: 'c') +add_project_arguments( + '-DPROJECT_VERSION="@0@"'.format(meson.project_version()), + '-DLV_BIG_ENDIAN_SYSTEM=' + (host_machine.endian() == 'big'? '1' : '0'), + language: 'c' +) depinih = dependency('inih') deplibinput = dependency('libinput') diff --git a/unl0kr/lv_conf.h b/unl0kr/lv_conf.h index d2597e2..de6a8e2 100644 --- a/unl0kr/lv_conf.h +++ b/unl0kr/lv_conf.h @@ -207,9 +207,6 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/ * COMPILER SETTINGS *====================*/ -/*For big endian systems set to 1*/ -#define LV_BIG_ENDIAN_SYSTEM 0 - /*Define a custom attribute to `lv_tick_inc` function*/ #define LV_ATTRIBUTE_TICK_INC From d5838377cbf313c4a7e4835c43c7bc20531513c4 Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Tue, 25 Mar 2025 19:34:17 +0100 Subject: [PATCH 10/10] Add proper attribution for !41 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12e8b93..ddbda4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ If a change only affects particular applications, they are listed in parentheses - feat(buffyboard): Add a buffyboard.service systemd service (!34, @uninsane) - fix(unl0kr): Select an available DRM device instead of a hard-coded one (!35, thanks @Sorcus) - feat(unl0kr): Enable software rotation (!32, thanks @xs5871 & @craftyguy) -- misc: do not hardcode endianess of a system +- misc: do not hardcode endianess of a system (!41, thanks @vstoiakin) ## 3.2.0 (2024-06-03)