[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#977877: console-setup: setupcon --setup-dir ... generates temporary file name inside etc/console-setup directory



On Sun, Sep 07, 2025 at 02:25:24PM +0200, Philip Hands wrote:
> > But all commands that setupcon would run are also copied into the
> > built-setupcon (including some patching of referenced filenames).
> 
> To put that another way, the patch is about looking for files that match
> "^tmpkbd\." and removing everything after the '.' and using what's left
> as the filename in the initrd. (which AFAICS is bound to be "tmpkbd"
> isn't it? so no need for sed)

I haven't looked at the patch at all.

> The string 'tmpkbd' only appears twice in all the code that
> codesearch.debian.net is able to search, and both those places are in
> this script, as a parameter to mktemp, to populate $TMPFILE.
> 
>   https://codesearch.debian.net/search?q=tmpkbd&literal=1
> 
> That being the case, where is the thing that is going to make use of the
> file in question, with either name?

I can reproduce a usage for it using this sequence on an otherwise 
'normal' install:

  % sudo rm /etc/console-setup/cached_*
  % setupcon --setup-dir /tmp/foo
  % find /tmp/foo
  /tmp/foo
  /tmp/foo/morefiles
  /tmp/foo/etc
  /tmp/foo/etc/console-setup
  /tmp/foo/etc/console-setup/tmpkbd.Vox0RB
  /tmp/foo/etc/console-setup/cached_UTF-8_del.kmap
  /tmp/foo/bin
  /tmp/foo/bin/setupcon
  % cat /tmp/foo/bin/setupcon
  #!/bin/sh
  # A micro-version of setupcon with static configuration.
  kbd_mode '-u'
  loadkeys '/etc/console-setup/tmpkbd.Vox0RB' > '/dev/null'
  mkdir /run/console-setup
  >/run/console-setup/keymap_loaded
  exit 0

To go back to a 'normal' state, run `sudo setupcon --save` (this recreates
/etc/console-setup/cached*).

> If (as it seems) the file we're messing about with is not used, wouldn't
> it be simpler to not bother adding it to the initrd at all?

As you can see above, it is used by the built /bin/setupcon in the loadkeys command.

> Even if this rename is required (given that it looks like the sed always
> results in 'tmpkbd') we can make it more obvious what's going on. e.g.:

I think setupcon should just always use a deterministic filename in
/etc/console-setup, and not bother with `tempfile` in this case.

Chris


Reply to: