Closed unrooted closed 4 months ago
hi, I've made some changes:
-u
, as well as the WSL distro on which the command will be executed can be changed with -d
parameter
I also have an idea for possible 'side notes', however, I'm not aware on how should apply them to the current page layout, my current suggestions regarding such 'side notes', include:
there are some limitations with --exec
flag for wsl.exe (might be more than what I've currently tested, we'd need more people and ideas to properly test it), I've noticed it has problems with sourcing the file and then returning the value (such as on example below), as well as for more complex commands, simple wsl -e cat /etc/os-release
will work, but not wsl -e cat /etc/os-release | grep '^VERSION'
, then it has to be executed fully with, for example, bash: wsl -e bash -c "cat /etc/os-release | grep '^VERSION'
I think that we can update the description in the bash.yml file to describe that it will be executed as the default user on the default WSL distro (but someone has to confirm whether bash.exe is able to work without any WSL distros installed)
P.S. sorry for using the same example over and over again, but I think it illustrates my points properly
To your point about grep
, this is most likely due to quotes/escaping in cmd
/powershell
, especially the pipe character.
As you already highlight, the below options work
wsl -- bash -c "cat /etc/os-release | grep '^VERSION'"
wsl -e bash -c "cat /etc/os-release | grep '^VERSION'"
this also works in cmd.exe
, without the need of bash
:
wsl -- cat /etc/os-release ^| grep '^^VERSION'
The bottom line is that this is more a matter of dealing with WSL, which is outside the scope of this project.
hi, I've made some changes to the wsl.yml file as things seem to have changed in the WSL world (I was using the default 'just' Ubuntu with WSL2 on Windows 11)
my changes:
Cats /etc/shadow file as root
, however, it showedwsl.exe --exec bash -c 'cat file'
as an example command to do so, however, it would point to the default user on our default distro, rather than straight execute as root (quick verification of which user is actually being used below)--system
is all we need to execute commands as root, however, due to changes done recently to the WSL, it's not true anymore, as it would now use the default user in the 'system' WSL, which iswslg
, to verify my statement and that the userwslg
has not such perms, here's the proof, with a simple example ofls /boot
(which, fun fact, is used only by the 'system' WSL distro)Windows 11
to all of thoseI hope my changes are OK. Please state if any changes should be made to my updated descriptions.