Subject: bug#72450: 29.1; Tramp Failed to Parse OS Name and Version for Windows 11

From: Duncan Greatwood <[email-masked]>
Date: Mon, 5 Aug 2024 15:14:50 -0700

Response below,

Thanks again.

On Mon, Aug 5, 2024 at 1:28 AM Michael Albinus <[email-masked]>
wrote:

> Duncan Greatwood <[email-masked]> writes:
>
> > Hi Michael and Eli -
>
> Hi Duncan,
>
> >     sh-5.2$ uname --version
> >     uname (GNU coreutils) 8.32
> >     Copyright (C) 2020 Free Software Foundation, Inc.
> >     License GPLv3+: GNU GPL version 3 or later
> >     <https://gnu.org/licenses/gpl.html>.
> >     This is free software: you are free to change and redistribute it.
> >     There is NO WARRANTY, to the extent permitted by law.
> >
> >     Written by David MacKenzie.
> >     sh-5.2$
> >
> > If I may, the extra characters in the emacs error message might not
> > come from the uname on windows - that uname seems to work OK on the
> > windows side at least - it could be a misparsing in emacs (or even an
> > mistake gathering the error message, I suppose).
>
> I also don't believe it comes from uname itself. '[17;120H’' looks
> rather like an escape code sequence, perhaps emitted from the underlying
> shell.

[DG] Yes, makes sense.

> Something like cursor position, window setting, whatever. A
> search didn't gave me a clue what's this.
>
> After connecting the remote host via ssh, Tramp sends as very first
> command something like
>
> --8<---------------cut here---------------start------------->8---
> # exec env TERM='dumb' INSIDE_EMACS='31.0.50,tramp:2.8.0-pre' ENV=''
> HISTFILE=~/.tramp_history PROMPT_COMMAND=''
> PS1=///245adade605348c086dac6d8f612435c\#\$ PS2='' PS3='' /bin/sh  -i
> --8<---------------cut here---------------end--------------->8---
>
> Note the TERM='dumb' setting, which ought to suppress such code
> sequences.
>
[DG] FWIW, I entered this command directly at the "sh" prompt on Windows,
and it looks OK AFAIK:
sh-5.2$ exec env TERM='dumb' INSIDE_EMACS='31.0.50,tramp:2.8.0-pre' ENV=''
HISTFILE=~/.tramp_history PROMPT_COMMAND=''
PS1=///245adade605348c086dac6d8f612435c\#\$ PS2='' PS3='' /bin/sh  -i
///245adade605348c086dac6d8f612435c#$
///245adade605348c086dac6d8f612435c#$echo $TERM
dumb
///245adade605348c086dac6d8f612435c#$echo $INSIDE_EMACS
31.0.50,tramp:2.8.0-pre

>
> Somehow, this doesn't seem to work as expected in your case. Perhaps due
> to calling /bin/sh. See below for debugging instructions.
>
> > i) the target windows machine is not directly accessible right now, it
> > is accessible via an intervening ssh proxy;
>
> That's a valid point. So we need to find a solution.
>
> > ii) SMB seems pretty retro to me in 2024, but maybe that's just me.
>
> Yes, it is just you.
>
[DG] Fair enough.

On this basis, I configured a mount on the Linux machine of the Windows
share using cifs/smb. fstab entry thus:
//WINDOWS-IP/WINDOWS-SHARE-NAME LINUX-MOUNT-DIR cifs
credentials=CREDS-FOR-WINDOWS-STORED-IN-LINUX,rw,uid=1000,gid=1000,file_mode=0755,dir_mode=0755
0 0
(where 1000 is the UID and GID of my Linux user)

Then I used the normal tramp /ssh:... form to open LINUX-MOUNT-DIR and then
open a file contained on the mount. I.e. With emacs running on macOS, this
is going macOS -> (ssh) -> Linux -> (smb) -> Windows. And it seems to work
just as you'd hope.

So this seems to be an option for the use case of access via an SSH proxy,
provided the user has admin rights on the proxy (the Linux machine in this
case) to install on the proxy a CIFS mount of the Windows share.

>
> > From an emacs perspective, it seems a shame not to be able to use ssh,
> > given that modern Windows commonly supports ssh and provides a bash
> > shell. Depending on your own available bandwidth etc. of course.
>
> That is NOT a shame. MS Windows is a non-free operation system,
> therefore it isn't a primary target for Emacs development.
>
> And it doesn't seem to be important. I'm working for Tramp for more than
> 20 years. During this time, nobody has contributed anything for the sake
> of MS Windows. And I don't use MS Windows myself; if possible, I fix
> things, that's it.

I, along with many others, appreciate all your efforts.

>
>
> > BTW, emacs seems to be taking some time before finally producing an
> > error message. If there is a way to log what is happening in emacs -
> > what tramp is trying, what happens, etc., I'd be happy to. Or LMK how
> > I could help otherwise.
>
> Set tramp-verbose to 6 in a new Emacs session, prior the ssh
> connection. When it has failed, there is a *debug tramp/ssh ...*
> buffer; please send it as attachment.
>
[DG] Firstly, my apologies - I can't recreate the "uname parsing issue"
directly now. Instead, emacs will go to a time out trying to access the
Windows machine via the ssh proxy. I don't know what's changed.

In any case, I am enclosing the debug output file. It is 86MB, so I am
sharing via Google Drive, hopefully that's OK.
https://drive.google.com/file/d/1aH1c-58rfOmjKVBqqfJ9QpzY5m-ltmDQ/view?usp=sharing

This is with the Windows machine using /usr/bin/sh as the default shell for
ssh login. Confirmed at the client command prompt - if I do "ssh WINDOWS",
I log in and get the "sh" prompt.

> > Best
> > -DG
> Best regards, Michael.

-- 
NOTICE: This email and its attachments may contain privileged and 
confidential information, only for the viewing and use of the intended 
recipient. If you are not the intended recipient, you are hereby notified 
that any disclosure, copying, distribution, acting upon, or use of the 
information contained in this email and its attachments is strictly 
prohibited and that this email and its attachments must be immediately 
returned to the sender and deleted from your system. If you received this 
email erroneously, please notify the sender immediately.  Xage Security, 
Inc. and its affiliates will never request personal information (e.g., 
passwords, Social Security numbers) via email.  Report suspicious emails to 
[email-masked] <mailto:[email-masked]>