butlerx / wetty

Terminal in browser over http/https. (Ajaxterm/Anyterm alternative, but much better)
https://butlerx.github.io/wetty
MIT License
4.26k stars 670 forks source link

yarn start with --command does not work #459

Closed john-deng closed 6 months ago

john-deng commented 1 year ago

Describe the bug

yarn start with argument --command does not work, but it is ok on official released docker container with the same git tag

To Reproduce Steps to reproduce the behavior:

  1. clone the source code
git clone https://github.com/butlerx/wetty.git
  1. build
yarn install 

yarn install v1.22.19
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/5] Validating package.json...
[2/5] Resolving packages...
success Already up-to-date.
Done in 0.71s.

yarn build   

yarn run v1.22.19
$ snowpack build
[21:24:44] [snowpack] ! building files...
[21:24:46] [sass] Command completed.
[21:24:46] [snowpack] ✔ files built. [1.59s]
[21:24:46] [snowpack] ! building dependencies...
[21:24:55] [tsc] Command completed.
[21:24:57] [tsc] Command completed.
[21:24:58] [esinstall] /home/ide/workspace/wetty-source/node_modules/file-type/index.js:1045:16 Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification
[21:24:59] [snowpack] ✔ dependencies built. [13.20s]
[21:24:59] [snowpack] ! writing to disk...
[21:24:59] [snowpack] ✔ write complete. [0.24s]
[21:24:59] [snowpack] ▶ Build Complete!
Done in 16.80s.

 yarn start --port=8080 --base / --command /bin/bash

yarn run v1.22.19
$ NODE_ENV=production node . --port=8080 --base / --command /bin/bash
{"base":"/","label":"Wetty","level":"info","message":"Starting server","port":8080,"timestamp":"2023-01-29T12:24:07.205Z","title":"WeTTY - The Web Terminal Emulator"}
{"connection":"http","label":"Wetty","level":"info","message":"Server started","port":8080,"timestamp":"2023-01-29T12:24:07.224Z"}
{"label":"Wetty","level":"info","message":"Connection accepted.","timestamp":"2023-01-29T12:24:10.598Z"}
{"label":"Wetty","level":"info","message":"Authentication Type: password","timestamp":"2023-01-29T12:24:10.599Z"}
  1. open the service on web browser

  2. It prompt "Enter your username" which is incorrect, it should run bash directly.

Screenshots (Error) image

Expected behavior

Screenshots (Expect) image

Desktop (please complete the following information):

john-deng commented 1 year ago

Never mind, I just find the root cause by myself.

As you can see the screenshot below, because the workspace is run with non-root user which WeTTY is restrict in command.ts, after the restruction is removed, the terminal works as I expected.

const localhost = (host: string): boolean =>
  process.getuid() === 0 &&
  (host === 'localhost' || host === '0.0.0.0' || host === '127.0.0.1');

image

github-actions[bot] commented 7 months ago

Stale issue message