Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update wsl.exe description #378

Merged
merged 5 commits into from
Jun 6, 2024
Merged

update wsl.exe description #378

merged 5 commits into from
Jun 6, 2024

Conversation

unrooted
Copy link
Contributor

@unrooted unrooted commented Jun 3, 2024

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)
image

my changes:

  • updated the 3rd section, which stated Cats /etc/shadow file as root, however, it showed wsl.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)

image

  • removed the 4th section, which stated that --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 is wslg, to verify my statement and that the user wslg has not such perms, here's the proof, with a simple example of ls /boot (which, fun fact, is used only by the 'system' WSL distro)

image

  • more minor and merely a cosmetic change, added Windows 11 to all of those

I hope my changes are OK. Please state if any changes should be made to my updated descriptions.

@unrooted
Copy link
Contributor Author

unrooted commented Jun 4, 2024

hi, I've made some changes:

  • updated wsl.yml once again as I wasn't happy with my suggested change, now it should be more universal, explaining that the executing user can be changed via -u, as well as the WSL distro on which the command will be executed can be changed with -d parameter
    image

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'
    image

  • 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)
    image

P.S. sorry for using the same example over and over again, but I think it illustrates my points properly

@wietze
Copy link
Member

wietze commented Jun 6, 2024

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.

Copy link
Member

@wietze wietze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That being said, happy with your changes. Thank you for contributing and for your detailed explainers in the PR, much appreciated 🔥

@wietze wietze merged commit 03b527b into LOLBAS-Project:master Jun 6, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants