Package: kbd Followup-For: Bug #766240 Hello.
A rebased version of the patch is attached. While testing it, I have implemented parts of the changes described in commit 55c3c680: In the future we might want to enable building the shared libkeymap again, but before that we likely need to change debian/rules to do a proper multi-flavour build for the udeb and the deb instead of the current hand-crafted rules that duplicates part of the upstream build system.
Description: In src/showkey.c, when the keyboard mode is not K_XLATE, a warning is displayed that showkey may fail under X. I suggest to consider K_UNICODE as normal as K_XLATE, or even remove this warning since getfd() will exit() if X is detected. . Later, the code calls signal() for every known signal. This fails with SIGKILL and SIGSTOP, but this has never been detected because the return value is not tested. I suggest to update the signal list from signal(7), store it in an array for readability, and check errors. Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=766240 Author: Nicolas Boulenguez <[email protected]> --- a/src/showkey.c +++ b/src/showkey.c @@ -50,7 +50,7 @@ break; } printf(_("kb mode was %s\n"), m); - if (oldkbmode != K_XLATE) { + if ((oldkbmode != K_XLATE) && (oldkbmode != K_UNICODE)) { printf(_("[ if you are trying this under X, it might not work\n" "since the X server is also reading /dev/console ]\n")); } @@ -94,6 +94,49 @@ exit(rc); } +static const int other_signals [] = { + // Signals described in the original POSIX.1-1990 standard, + // except SIGALRM which is handled separately, + // and SIGKILL and SIGSTO which cannot be caught. + SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, SIGPIPE, + SIGTERM, SIGUSR1, SIGUSR2, SIGCHLD, SIGCONT, SIGTSTP, SIGTTIN, SIGTTOU, + // Signals described in SUSv2 and POSIX.1-2001. + SIGBUS, SIGPOLL, SIGPROF, SIGSYS, SIGTRAP, + SIGURG, SIGVTALRM, SIGXCPU, SIGXFSZ, + // Various other signals. + #ifdef SIGIOT + SIGIOT, + #endif + #ifdef SIGEMT + SIGEMT, + #endif + #ifdef SIGSTKFLT + SIGSTKFLT, + #endif + #ifdef SIGIO + SIGIO, + #endif + #ifdef SIGCLD + SIGCLD, + #endif + #ifdef SIGPWR + SIGPWR, + #endif + #ifdef SIGINFO + SIGINFO, + #endif + #ifdef SIGLOST + SIGLOST, + #endif + #ifdef SIGWINCH + SIGWINCH, + #endif + #ifdef SIGUNUSED + SIGUNUSED, + #endif +}; + + int main(int argc, char *argv[]) { const char *short_opts = "haskVt:"; @@ -198,35 +241,19 @@ kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console.")); /* the program terminates when there is no input for 10 secs */ - signal(SIGALRM, watch_dog); + if (signal(SIGALRM, watch_dog) == SIG_ERR) { + kbd_error(EXIT_FAILURE, errno, "signal SIGALRM"); + } /* if we receive a signal, we want to exit nicely, in order not to leave the keyboard in an unusable mode */ - signal(SIGHUP, die); - signal(SIGINT, die); - signal(SIGQUIT, die); - signal(SIGILL, die); - signal(SIGTRAP, die); - signal(SIGABRT, die); - signal(SIGIOT, die); - signal(SIGFPE, die); - signal(SIGKILL, die); - signal(SIGUSR1, die); - signal(SIGSEGV, die); - signal(SIGUSR2, die); - signal(SIGPIPE, die); - signal(SIGTERM, die); -#ifdef SIGSTKFLT - signal(SIGSTKFLT, die); -#endif - signal(SIGCHLD, die); - signal(SIGCONT, die); - signal(SIGSTOP, die); - signal(SIGTSTP, die); - signal(SIGTTIN, die); - signal(SIGTTOU, die); + for (i=0; i<sizeof(other_signals)/sizeof(int); i++) { + if (signal(other_signals[i], die) == SIG_ERR) { + kbd_error(EXIT_FAILURE, errno, "signal %i", other_signals[i]); + } + } get_mode(); if (tcgetattr(fd, &old) == -1)
>From 0065f699bd5091a96d5e3406535cac3a5e717454 Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez <[email protected]> Date: Tue, 24 Feb 2026 14:13:01 +0100 Subject: [PATCH 1/9] Update debian/watch to format version 5 --- debian/watch | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/debian/watch b/debian/watch index 7e2a3f4..5868a6f 100644 --- a/debian/watch +++ b/debian/watch @@ -1,4 +1,6 @@ -version=4 -opts=filenamemangle=s%v?@ANY_VERSION@%@PACKAGE@-$1.tar.gz%,\ - uversionmangle=s/(.*)-((RC|rc|pre|dev|beta|alpha|a|b)\d*)$/$1~$2/ \ - https://github.com/legionus/kbd/tags .*/v?(\d\S+)@ARCHIVE_EXT@ +Version: 5 + +Template: Github +Owner: legionus +Project: kbd +Uversion-Mangle: auto -- 2.47.3
>From 64fc3ad871e3ac510e173bb4ffaf61c5cb2a90a2 Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez <[email protected]> Date: Tue, 24 Feb 2026 14:13:27 +0100 Subject: [PATCH 2/9] Remove obsolete debian/kbd.dirs --- debian/kbd.dirs | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 debian/kbd.dirs diff --git a/debian/kbd.dirs b/debian/kbd.dirs deleted file mode 100644 index ca882bb..0000000 --- a/debian/kbd.dirs +++ /dev/null @@ -1,2 +0,0 @@ -usr/bin -usr/sbin -- 2.47.3
>From 895ae03234fc4f955aac0c726a223c904195fcaa Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez <[email protected]> Date: Tue, 24 Feb 2026 14:14:36 +0100 Subject: [PATCH 3/9] Remove obsolete console-utilities virtual package --- debian/control | 2 -- 1 file changed, 2 deletions(-) diff --git a/debian/control b/debian/control index 73e53bf..89eeef0 100644 --- a/debian/control +++ b/debian/control @@ -14,8 +14,6 @@ Package: kbd Architecture: linux-any Depends: ${shlibs:Depends}, ${misc:Depends} Recommends: console-setup | console-data -Provides: console-utilities -Conflicts: console-utilities Description: Linux console font and keytable utilities This package allows you to set up the Linux console, change the font, resize text mode virtual consoles and remap the keyboard. -- 2.47.3
>From e2b3792b1bc82298daee71e47120d7afb2b349cd Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez <[email protected]> Date: Tue, 24 Feb 2026 14:15:34 +0100 Subject: [PATCH 4/9] Wrap and sort build dependencies --- debian/control | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/debian/control b/debian/control index 89eeef0..c5a1dca 100644 --- a/debian/control +++ b/debian/control @@ -3,8 +3,15 @@ Section: utils Priority: optional Maintainer: Console utilities maintainers <[email protected]> Uploaders: Michael Schutte <[email protected]>, Anton Zinoviev <[email protected]> -Build-Depends: dpkg-dev (>= 1.16.1), debhelper-compat (= 13), - linuxdoc-tools, gettext, flex, bison, pkgconf, check +Build-Depends: + bison, + check, + debhelper-compat (= 13), + dpkg-dev (>= 1.16.1), + flex, + gettext, + linuxdoc-tools, + pkgconf, Standards-Version: 4.1.5 Homepage: https://kbd-project.org/ Vcs-Git: https://salsa.debian.org/debian/kbd.git -- 2.47.3
>From 96b52aae2b141c31fd77274cba0776fbb6d9ef8a Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez <[email protected]> Date: Tue, 24 Feb 2026 14:15:59 +0100 Subject: [PATCH 5/9] Remove obsolete version restriction on the dpkg-dev build dependency --- debian/control | 1 - 1 file changed, 1 deletion(-) diff --git a/debian/control b/debian/control index c5a1dca..af8fc53 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,6 @@ Build-Depends: bison, check, debhelper-compat (= 13), - dpkg-dev (>= 1.16.1), flex, gettext, linuxdoc-tools, -- 2.47.3
>From 6366e3beb2d1dd277fa1ec465d736797cc2a673b Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez <[email protected]> Date: Tue, 24 Feb 2026 14:17:50 +0100 Subject: [PATCH 6/9] Standards-Version 4.7.3 --- debian/control | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/debian/control b/debian/control index af8fc53..e59a5c9 100644 --- a/debian/control +++ b/debian/control @@ -1,6 +1,5 @@ Source: kbd Section: utils -Priority: optional Maintainer: Console utilities maintainers <[email protected]> Uploaders: Michael Schutte <[email protected]>, Anton Zinoviev <[email protected]> Build-Depends: @@ -11,7 +10,7 @@ Build-Depends: gettext, linuxdoc-tools, pkgconf, -Standards-Version: 4.1.5 +Standards-Version: 4.7.3 Homepage: https://kbd-project.org/ Vcs-Git: https://salsa.debian.org/debian/kbd.git Vcs-Browser: https://salsa.debian.org/debian/kbd -- 2.47.3
>From 0d0a1fb9a20631f3f4475f54ada2420034c77324 Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez <[email protected]> Date: Tue, 24 Feb 2026 14:11:54 +0100 Subject: [PATCH 7/9] Simplify debian/rules Instal mk_modmap with a debhelper configuration file. When debian/rules install files by itself, select the right place directly instead of moving some later. Export build flags and tools instead of setting them manually for the compilations not using ./configure. Build out of the source tree. This simplifies the clean target, but also makes it possible to build twice in a row (for deb and udeb). I assume '-Os -g' was intending '-Os $(filter-out -O%,$(CFLAGS))'. Set this during configuration instead of duplicating the setting for each Make. Delegate as much as possible to dh_install. --- debian/kbd.install | 1 + debian/rules | 97 ++++++++++++++++++++-------------------------- 2 files changed, 44 insertions(+), 54 deletions(-) create mode 100644 debian/kbd.install diff --git a/debian/kbd.install b/debian/kbd.install new file mode 100644 index 0000000..19789ae --- /dev/null +++ b/debian/kbd.install @@ -0,0 +1 @@ +data/keymaps/i386/mk_modmap usr/bin diff --git a/debian/rules b/debian/rules index 684a0b0..768319d 100755 --- a/debian/rules +++ b/debian/rules @@ -1,85 +1,74 @@ #!/usr/bin/make -f -TOPDIR = $(shell pwd) -KBD = $(TOPDIR)/debian/kbd -KBD_DOC = $(KBD)/usr/share/doc/kbd -KBD_UDEB = $(TOPDIR)/debian/kbd-udeb +KBD = '$(CURDIR)'/debian/kbd # build these twice, once optimized for size (for kbd-udeb) UDEB_BINARIES = loadkeys kbd_mode setfont # non-standard binaries to build -EXTRA_BINARIES = screendump setlogcons setvesablank -CONTRIB_BINARIES = codepage splitfont vcstime +EXTRA_BINARIES_bin = screendump setlogcons +EXTRA_BINARIES_sbin = setvesablank +EXTRA_BINARIES = $(EXTRA_BINARIES_bin) $(EXTRA_BINARIES_sbin) +CONTRIB_BINARIES_bin = codepage splitfont +CONTRIB_BINARIES_sbin = vcstime +CONTRIB_BINARIES = $(CONTRIB_BINARIES_bin) $(CONTRIB_BINARIES_sbin) # we don’t want these in /usr/bin -MOVE_TO_USR_SBIN = vcstime setvesablank kbdrate +MOVE_TO_USR_SBIN = kbdrate -include /usr/share/dpkg/architecture.mk - -ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) - CROSS := CC=$(DEB_HOST_GNU_TYPE)-gcc -endif +# Export because contrib/ has no autoconf stuff. +DPKG_EXPORT_BUILDFLAGS := 1 +DPKG_EXPORT_BUILDTOOLS := 1 +include /usr/share/dpkg/buildflags.mk +include /usr/share/dpkg/buildtools.mk %: dh $@ override_dh_auto_clean: - dh_auto_clean - [ ! -f Makefile ] || $(MAKE) clean - cd src/ && rm -f $(EXTRA_BINARIES) *-udeb - cd contrib/ && rm -f $(CONTRIB_BINARIES) - rm -f po/gr.po # replaced by el.po - # cleanup modified or leftover files from previous build - ! test -p tests/testsuite.dir/at-job-fifo || rm -f tests/testsuite.dir/at-job-fifo - rm -f po/*.gmo po/stamp-po - # force rebuilding of generated code - rm -f src/libkeymap/analyze.h src/libkeymap/analyze.c + rm -fr bld/ +conf_args := --enable-nls --disable-libkeymap --disable-vlock override_dh_auto_configure: - dh_auto_configure -- \ - --enable-nls \ - --disable-libkeymap \ - --disable-vlock +ifeq (, $(filter noudeb, $(DEB_BUILD_PROFILES))) + CFLAGS='-Os $(filter-out -O%,$(CFLAGS))' \ + dh_auto_configure -Bbld/udeb -- $(conf_args) +endif + dh_auto_configure -Bbld/deb -- $(conf_args) override_dh_auto_build: ifeq (, $(filter noudeb, $(DEB_BUILD_PROFILES))) - $(MAKE) -C src/libkeymap CFLAGS="-Os -g" analyze.h - $(MAKE) -C src/libcommon CFLAGS="-Os -g" - $(MAKE) -C src/libkbdfile CFLAGS="-Os -g" - $(MAKE) -C src/libkeymap CFLAGS="-Os -g" - $(MAKE) -C src/libkfont CFLAGS="-Os -g" - $(MAKE) -C src/ CFLAGS="-Os -g" $(UDEB_BINARIES) - cd src/ && for ITEM in $(UDEB_BINARIES); do mv $$ITEM $$ITEM-udeb; done - $(MAKE) -C src/libkeymap clean - $(MAKE) -C src/libcommon clean - $(MAKE) -C src/libkbdfile clean - $(MAKE) -C src/libkfont clean - $(MAKE) -C src/ clean + $(MAKE) -Cbld/udeb/src/libkeymap analyze.h + $(MAKE) -Cbld/udeb/src/libcommon + $(MAKE) -Cbld/udeb/src/libkbdfile + $(MAKE) -Cbld/udeb/src/libkeymap + $(MAKE) -Cbld/udeb/src/libkfont + $(MAKE) -Cbld/udeb/src $(UDEB_BINARIES) endif - $(MAKE) - $(MAKE) -C src/ $(EXTRA_BINARIES) - $(MAKE) $(CROSS) CFLAGS="-O2 -g" -C contrib/ $(CONTRIB_BINARIES) + $(MAKE) -Cbld/deb + $(MAKE) -Cbld/deb/src $(EXTRA_BINARIES) +# No Makefile, but flags and tools are in the environment. + $(MAKE) -Cbld VPATH=../contrib $(CONTRIB_BINARIES) + +override_dh_auto_test: + dh_auto_test -Bbld/deb override_dh_auto_install: # the kbd “core” - $(MAKE) DESTDIR=$(KBD) install-exec - $(MAKE) DESTDIR=$(KBD) -C po/ install - $(MAKE) DESTDIR=$(KBD) -C docs/man/ install + $(MAKE) DESTDIR=$(KBD) -C bld/deb/ install-exec + $(MAKE) DESTDIR=$(KBD) -C bld/deb/po/ install + $(MAKE) DESTDIR=$(KBD) -C bld/deb/docs/man/ install # some additional utilities - install -m755 $(addprefix src/,$(EXTRA_BINARIES)) $(KBD)/usr/bin/ - install -m755 $(addprefix contrib/,$(CONTRIB_BINARIES)) $(KBD)/usr/bin/ - install -m755 data/keymaps/i386/mk_modmap $(KBD)/usr/bin + dh_install -pkbd $(EXTRA_BINARIES_bin:%=bld/deb/src/%) \ + $(CONTRIB_BINARIES_bin:%=bld/%) usr/bin + dh_install -pkbd $(EXTRA_BINARIES_sbin:%=bld/deb/src/%) \ + $(CONTRIB_BINARIES_sbin:%=bld/%) usr/sbin # move everything where it belongs mv $(addprefix debian/kbd/usr/bin/,$(MOVE_TO_USR_SBIN)) $(KBD)/usr/sbin/ # prepare udeb -ifeq (, $(filter noudeb, $(DEB_BUILD_PROFILES))) - for ITEM in $(UDEB_BINARIES); do install -D -m755 src/$$ITEM-udeb $(KBD_UDEB)/usr/bin/$$ITEM; done -endif + dh_install -pkbd-udeb $(UDEB_BINARIES:%=bld/udeb/src/%) usr/bin # drop libtool files find $(KBD) -name '*.la' -delete -override_dh_installdocs: - dh_installdocs - install -d $(KBD_DOC)/charsets - cp docs/doc/iso8859.info docs/doc/iso*.txt docs/doc/cp*.txt $(KBD_DOC)/charsets + dh_install -pkbd docs/doc/iso8859.info docs/doc/iso*.txt \ + docs/doc/cp*.txt usr/share/doc/kbd/charsets -- 2.47.3
>From 4af5a37f158a322dc016f1657050c030ab5c8ccf Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez <[email protected]> Date: Tue, 24 Feb 2026 18:32:04 +0100 Subject: [PATCH 8/9] Enable hardening flags --- debian/rules | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/rules b/debian/rules index 768319d..5b45de7 100755 --- a/debian/rules +++ b/debian/rules @@ -16,6 +16,7 @@ CONTRIB_BINARIES = $(CONTRIB_BINARIES_bin) $(CONTRIB_BINARIES_sbin) # we don’t want these in /usr/bin MOVE_TO_USR_SBIN = kbdrate +DEB_BUILD_MAINT_OPTIONS := hardening=+all # Export because contrib/ has no autoconf stuff. DPKG_EXPORT_BUILDFLAGS := 1 DPKG_EXPORT_BUILDTOOLS := 1 -- 2.47.3
>From e0f99b03dfe040e61a4c7170735b15f62b8a98ac Mon Sep 17 00:00:00 2001 From: Nicolas Boulenguez <[email protected]> Date: Tue, 24 Feb 2026 18:33:28 +0100 Subject: [PATCH 9/9] Link libkeymap statically in udeb, dynamically in deb --- debian/rules | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debian/rules b/debian/rules index 5b45de7..b0c9f47 100755 --- a/debian/rules +++ b/debian/rules @@ -29,13 +29,13 @@ include /usr/share/dpkg/buildtools.mk override_dh_auto_clean: rm -fr bld/ -conf_args := --enable-nls --disable-libkeymap --disable-vlock +conf_args := --enable-nls --disable-vlock override_dh_auto_configure: ifeq (, $(filter noudeb, $(DEB_BUILD_PROFILES))) CFLAGS='-Os $(filter-out -O%,$(CFLAGS))' \ - dh_auto_configure -Bbld/udeb -- $(conf_args) + dh_auto_configure -Bbld/udeb -- $(conf_args) --disable-libkeymap endif - dh_auto_configure -Bbld/deb -- $(conf_args) + dh_auto_configure -Bbld/deb -- $(conf_args) --enable-libkeymap override_dh_auto_build: ifeq (, $(filter noudeb, $(DEB_BUILD_PROFILES))) -- 2.47.3

