[SLOF] [PATCH] slof/fs/accept: Allow Unix LF line endings, too

Alexey Kardashevskiy aik at ozlabs.ru
Mon Aug 30 22:58:41 AEST 2021



On 30/08/2021 20:53, Thomas Huth wrote:
> Currently SLOF only accepts CR (0x0d) line endings at the command prompt,
> since this is the default line ending used on serial consoles. However,
> sometimes people try to connect to SLOF directly in a way that uses the
> typical Unix LF line endings (0x0a) which are then completely ignored,
> for example running QEMU like this:
> 
>   qemu-system-ppc64 -nodefaults \
>      -chardev socket,path=/tmp/mysocket,wait=off,id=cs0,server=on \
>      -device spapr-vty,id=serial0,reg=0x30000000,chardev=cs0
> 
> and then connect to that Unix socket via "nc -U /tmp/mysocket".
> 
> For such use cases, allow the 0x0a line ending in SLOF, too.
> 
> Signed-off-by: Thomas Huth <thuth at redhat.com>
> ---
>   I'm not quite sure anymore ... didn't we already run into this problem
>   a couple of times in the past already? Was there a reason that we never
>   allowed 0x0a here, too?

I do not remember anything like this and git blame suggests the code is 
from the initial commit. David poked me today about it and I came up 
with the same patch which does not seem breaking anything but I did not 
test everything (unix socket, tcp socket, telnet on/off), did you? ;)

But the question now is how come qemu's stdin sends 0xd on "enter" to 
SLOF. I kinda understand why "nc" does this (it just does not do 
anything funny) but I am lost with the shell and tty. All I can see is 
that qemu_chr_set_echo_stdio() sets tty.c_iflag to 0 which means we 
should have the same problem with -stdio but we do not - vty_receive() 
receives 0xd on "enter" while "strace cat" in the same terminal gives 
0xa. Ideas?


> 
>   slof/fs/accept.fs | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/slof/fs/accept.fs b/slof/fs/accept.fs
> index cb6f2fa..26e9216 100644
> --- a/slof/fs/accept.fs
> +++ b/slof/fs/accept.fs
> @@ -392,6 +392,7 @@ TABLE-EXECUTE handle-control
>      1b emit 37 emit
>      BEGIN
>         key dup 0d <>
> +      over 0a <> and
>      WHILE
>         dup 9 <> IF 0 to ?tab-pressed THEN \ reset state machine
>         dup 7f = IF drop 8 THEN \ Handle DEL as if it was BS. ??? bogus
> 

-- 
Alexey


More information about the SLOF mailing list