microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.56k stars 266 forks source link

server untar fails for root user #5603

Open jonashaag opened 2 years ago

jonashaag commented 2 years ago

Version: 1.60.1 (user setup) Commit: 83bd43bc519d15e50c4272c6cf5c1479df196a4d Date: 2021-09-10T17:07:10.714Z Electron: 13.1.8 Chrome: 91.0.4472.164 Node.js: 14.16.0 V8: 9.1.269.39-electron.0 OS: Windows_NT x64 10.0.19042

Remote OS Version: Ubuntu 20.04 Docker container

Remote Extension/Connection Type: SSH (not using Docker because it's unavailable on the Windows machine)

Steps to Reproduce:

  1. Set up new remote SSH host using v0.65.7. Works, see logs below.
  2. Upgrade to v0.65.8, still works (no new server setup attempted).
  3. Remove ~/.vscode-server on the remote, reconnect, server setup doesn't work, see logs below.

Happy to share the full logs privately.

v0.65.7 logs:

> tar: vscode-server-linux-x64/node_modules: Cannot change ownership to uid 0, gid
>  0: Permission denied
> tar: vscode-server-linux-x64: Cannot change ownership to uid 0, gid 0: Permissio
> n denied
> tar: Exiting with failure status due to previous errors
> Checking /home/X930960/.vscode-server/.83bd43bc519d15e50c4272c6cf5c1479df196a4d.
> log and /home/X930960/.vscode-server/.83bd43bc519d15e50c4272c6cf5c1479df196a4d.p
> id for a running server
> Starting server with command... /home/X930960/.vscode-server/bin/83bd43bc519d15e
> 50c4272c6cf5c1479df196a4d/server.sh --start-server --host=127.0.0.1 --enable-rem
> ote-auto-shutdown --disable-telemetry --port=0  &> "/home/X930960/.vscode-server
> /.83bd43bc519d15e50c4272c6cf5c1479df196a4d.log" < /dev/null
[...]
> Spawned remote server: 3502
> rm: cannot remove '/home/X930960/.vscode-server/.83bd43bc519d15e50c4272c6cf5c147
> 9df196a4d.token': No such file or directory
> Waiting for server log...
> Waiting for server log...
> Waiting for server log...
> Waiting for server log...
> Waiting for server log...
> Waiting for server log...
> Waiting for server log...
> Waiting for server log...
>  
> *
> * Reminder: You may only use this software with Visual Studio family products,  
> * as described in the license (https://go.microsoft.com/fwlink/?linkid=2077057) 
> *
> 
> 249d958fa3cb: start
> SSH_AUTH_SOCK====
> DISPLAY====
> webUiAccessToken====
> listeningOn==36105==
> osReleaseId==ubuntu==
> arch==x86_64==
> tmpDir==/tmp==
> platform==linux==
> unpackResult==success==
> didLocalDownload==1==
> downloadTime====
> installTime==5564==
> extInstallTime====
> serverStartTime==348==
> connectionToken==1a1a11a1-aaa1-11aa-11a1-1a1a1111111a==
> 249d958fa3cb: end
[11:03:16.438] Received install output: 
SSH_AUTH_SOCK====
DISPLAY====
webUiAccessToken====
listeningOn==36105==
osReleaseId==ubuntu==
arch==x86_64==
tmpDir==/tmp==
platform==linux==
unpackResult==success==
didLocalDownload==1==
downloadTime====
installTime==5564==
extInstallTime====
serverStartTime==348==
connectionToken==1a1a11a1-aaa1-11aa-11a1-1a1a1111111a==

[11:03:16.441] Remote server is listening on 36105
[11:03:16.442] Parsed server configuration: {"serverConfiguration":{"remoteListeningOn":{"port":36105},"osReleaseId":"ubuntu","arch":"x86_64","webUiAccessToken":"","sshAuthSock":"","display":"","tmpDir":"/tmp","platform":"linux","connectionToken":"1a1a11a1-aaa1-11aa-11a1-1a1a1111111a"},"installTime":5564,"serverStartTime":348,"didLocalDownload":true,"installUnpackCode":"success"}
[11:03:16.446] Starting forwarding server. localPort 55302 -> socksPort 55653 -> remotePort 36105
[11:03:16.449] Forwarding server listening on 55302
[11:03:16.449] Waiting for ssh tunnel to be ready
[11:03:16.452] Tunneled 36105 to local port 55302
[11:03:16.452] Resolved "ssh-remote+ap-container" to "127.0.0.1:55302"
[11:03:16.458] [Forwarding server 55302] Got connection 0
[11:03:16.476] ------

v0.65.8 logs:

> tar: vscode-server-linux-x64: Cannot change ownership to uid 0, gid 0: Permissio
> n denied
> tar: Exiting with failure status due to previous errors
[11:13:17.119] > 
> ERROR: tar exited with non-0 exit code: 0
> Already attempted local download, failing
[11:13:17.151] > 
> ffae8e01a71b: start
> exitCode==37==
> listeningOn====
> osReleaseId==ubuntu==
> arch==x86_64==
> tmpDir==/tmp==
> platform==linux==
> unpackResult==error==
> didLocalDownload==1==
[11:13:17.187] > 
> downloadTime====
> installTime==6492==
> extInstallTime====
> serverStartTime====
> ffae8e01a71b: end
[11:13:17.226] Received install output: 
exitCode==37==
listeningOn====
osReleaseId==ubuntu==
arch==x86_64==
tmpDir==/tmp==
platform==linux==
unpackResult==error==
didLocalDownload==1==
downloadTime====
installTime==6492==
extInstallTime====
serverStartTime====

[11:13:17.229] Resolver error: Error: Failed to install the VS Code Server
    at Function.ServerInstallError (c:\Users\X930960\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.8\out\extension.js:1:396975)
    at u (c:\Users\X930960\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.8\out\extension.js:1:391720)
    at Object.t.handleInstallOutput (c:\Users\X930960\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.8\out\extension.js:1:395717)
    at Object.t.tryInstall (c:\Users\X930960\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.8\out\extension.js:1:489314)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async c:\Users\X930960\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.8\out\extension.js:1:453110
    at async Object.t.withShowDetailsEvent (c:\Users\X930960\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.8\out\extension.js:1:456460)
    at async Object.t.resolve (c:\Users\X930960\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.8\out\extension.js:1:454189)
    at async c:\Users\X930960\.vscode\extensions\ms-vscode-remote.remote-ssh-0.65.8\out\extension.js:1:526942
[11:13:17.234] "install" terminal command done
[11:13:17.236] Install terminal quit with output: 
[11:13:17.247] ------
roblourens commented 2 years ago

I don't really understand why it works in the first case when you got all of these tar errors. There is definitely something wrong. You could email me the full log from the Remote-SSH output channel and we could see whether that has any useful info.

roblourens commented 2 years ago

Sorry for the slow response. Missed the email.

I don't really understand why the previous one works - it produced the same errors. I used to ignore tar errors but that was a long time ago... There are hundreds of errors of the same pattern that I see above

tar: vscode-server-linux-x64/node_modules: Cannot change ownership to uid 0, gid 0: Permission denied

you need to look at what user you are using to connect with ssh and what permissions it has on this remote system.

jonashaag commented 2 years ago

I think I figured it out, the problem is that the remote machine's ~ is on a network filesystem that has funny file permission behaviour:

$ cd
$ id
uid=0(root) gid=0(root) groups=0(root)
$ touch /tmp/test test
$ ls -l /tmp/test test
-rw-r--r-- 1 root   root  0 Oct 22 12:27 /tmp/test
-rw-r--r-- 1 930960 54615 0 Oct 22 12:27 test
$ chown 0:0 /tmp/test
$ chown 0:0 test
chown: changing ownership of 'test': Permission denied
$ chown 930960:54615 /tmp/test
$ chown 930960:54615 test
tanhakabir commented 2 years ago

Closing this issue since it looks like @jonashaag, you got it solved?

jonashaag commented 2 years ago

No it’s not solved. I can’t change anything about those permissions so I’m unable to use VSCode remote in a recent version.

roblourens commented 2 years ago

I am not an expert, I wonder whether this is a case like this?: https://superuser.com/questions/1435437/how-to-get-around-this-error-when-untarring-an-archive-tar-cannot-change-owner

If you can reproduce the error message in the log from running tar manually, and --no-same-owner fixes it, that would be useful info

jonashaag commented 2 years ago

Yes, I can reproduce with that. Here, /tmp/xxx.tar is an archive that contains a file xxx that has uid=gid=0, and my user also has uid=gid=0, but the filesystem automatically changes the uid and gid.

$ tar xfv /tmp/xxx.tar
xxx
tar: xxx: Cannot change ownership to uid 0, gid 0: Permission denied
tar: Exiting with failure status due to previous errors
$ tar xfv /tmp/xxx.tar --no-same-owner
xxx