Skip to content
New issue

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

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

Already on GitHub? # to your account

spawned processes have umask = 0077 #416

Closed
zeusintuivo opened this issue Jan 5, 2021 · 9 comments
Closed

spawned processes have umask = 0077 #416

zeusintuivo opened this issue Jan 5, 2021 · 9 comments
Labels
bug Something isn't working

Comments

@zeusintuivo
Copy link

Describe the bug

using a mac. actually I could replicate in two macs. while using wezterm, all the permissions for file and folders got lost to user 501. and permissions blocked to rw- --- --- so, it breaks the entire mac systems.

Environment (please complete the following information):

  • OS:macOS Catalina and BigSur
  • Version: WezTerm-macos-20201101-103216-403d002d

To Reproduce

Steps to reproduce the behavior.

open wezterm
start installing brew or mysql or anything, and watch your system become unstable
check the rights of /usr/local/Cellar for example or anything you installed would be ruined, blocked or not accessible

Configuration

no file

Expected behavior

Expected to be able to use it normally with no repercutions

Screenshots

NA

Session Recording

NA

Additional context

@wez @dsp @misaelnieto

@zeusintuivo zeusintuivo added the bug Something isn't working label Jan 5, 2021
@wez
Copy link
Member

wez commented Jan 5, 2021

I suspect that you might have an issue with your umask in your shell configuration.
Can you try to minimize what you're running?

For example; try the following and share the output:

  • start wezterm
  • run umask
  • touch /tmp/a-file
  • ls -l /tmp/a-file

Compare that with eg: Terminal.app

wezterm doesn't know anything about brew or /usr/local/Cellar and doesn't have code to go and actively change the permissions across the the system, and can't hook into what brew is doing, so it seems unlikely that it is literally doing what you've described in this issue.

@zeusintuivo
Copy link
Author

I am aware the wezterm does not know anything about brew. But something is off. I already killed two MAC laptops, I started to set up. Then I added wezterm, and oops. All chaos. I had to go to recovery mode and fix the file permissions manually. Both had the same issues. I find that terribly bad. Unless I could be wrong and it was brew. But wait a minute I also downloaded MySQL from website install, not the brew version, and it also managed to do something to the permissions, of those folders. Not the installers, but when I ran commands from the terminal to setup MySQL setup, So right now, my suspicion is wezterm. My second suspicions could be a new shitty macOS issue with Catalina and Big Sur, where macOS systems a becoming more and more unstable with every new macOS release.

@wez
Copy link
Member

wez commented Jan 6, 2021

At this point there's not much for me to go on. I asked for you to run some basic commands to help prove/disprove the most likely source of permissions that anyone using a shell in a terminal is likely to face; until I see that I have no concrete information on what is happening. Beyond that, the way that terminals and shells work, it is "impossible" for there to be any additional side effects bleeding down from the terminal emulator after the shell is started.

From what you've described, I would suspect that something went wrong with installing some of the other software you mentioned: that seems like a much more likely candidate, especially if you are using sudo or similar to elevate the privileges of the commands that are being run.

Please keep in mind that none of the other users of wezterm have run into behavior that is similar to what you have described.

@MuhammedZakir
Copy link
Contributor

MuhammedZakir commented Jan 7, 2021

When executing umask, I get 077 for wezterm and 022 for all other terminals (Terminal.app, iTerm2, Kitty & Alacritty).

Edit: for touch /tmp/a-file, ls -l /tmp/a-file: -rw------- for wezterm and -rw-r--r-- for others.

@zeusintuivo
Copy link
Author

zeusintuivo commented Jan 7, 2021

Sorry, it took me long to respond, but I was busy fixing those laptops.
In the mac I got the same problem as result bad result as stated by @MuhammedZakir
(Terminal.app, iTerm2, Kitty & Alacritty)

touch /tmp/a-file, ls -l /tmp/a-file: == -rw-r--r--

(wezterm)
touch /tmp/a-file, ls -l /tmp/a-file: == -rw-------

In Linux Fedora, there seems to no issue.
(Gnome-Terminal, Guake, Terminator)

touch /tmp/a-file, ls -l /tmp/a-file: == -rw-r--r--

(wezterm)
touch /tmp/a-file, ls -l /tmp/a-file: == -rw-r--r--

In conclusion, installing anything in a macOS using from inside wezterm, now, it will mangle the file systems terribly. I had to reset the harddrive and reinstall the entire system in one and the other just the entire /usr had to be recreated mainly.

Could it be a Rust problem ?

wez added a commit that referenced this issue Jan 7, 2021
wezterm sets a more restrictive umask (`0o077`) by default so that any files
that it creates (eg: unix domain socket, log files) are more secure
by default.

However, some environments rely on the more general default of (`0o022`)
without checking that it is set.

This matters because programs spawned by wezterm inherit its more
restricted umask.

I hadn't noticed this because I've had `umask 022` in my shell RC files
since sometime in the 1990's.

This commit adds some plumbing to the pty layer to specify an optional
umask for the child process, and some more to our umask saver helper
so that any thread can determine the saved umask without needing a
reference to the saver itself, which may be in a different crate.

The logic in the config crate has been adjusted to connect the saved
value to the default command builder arguments.

The net result of this is that running `wezterm -n start bash -- --norc`
and typing `umask` in the resultant window now prints `0022`.

refs: #416
@wez
Copy link
Member

wez commented Jan 7, 2021

wezterm sets umask 077 so that unix domain socket(s) used by the multiplexer, and log files are safer, but doesn't restore the prior umask when spawning child commands.

I hadn't noticed this because I've had umask 022 in my shell rc files since sometime in the 1990's because I couldn't trust the default on whatever weird flavor of unix I was running in at the time.

I would recommend that you also put umask 022 in your shell configs to ensure a consistent experience in general.

I've pushed a commit that restores the umask to whatever it was set to by the process that spawned wezterm so that this should be less surprising.

FWIW, if a software installation process is sensitive to umask, I would consider it a bug in the installer; the umask isn't required to have any particular value (if it was, it wouldn't be a feature of unix systems; it would just be hardcoded) and security conscious unix users do often set a more restrictive umask.

@wez wez changed the title destroys file systems in mac spawned processes have umask = 0077 Jan 7, 2021
wez added a commit that referenced this issue Jan 7, 2021
wez added a commit that referenced this issue Jan 7, 2021
@wez wez closed this as completed Jan 9, 2021
@tntljc
Copy link

tntljc commented Feb 10, 2022

@wez This issue seems reoccur recently?
I'm using wezterm 20220101-133340-7edc5b5a
I killed server and restart wezterm, the umask is 0077:

~$ umask -S
u=rwx,g=,o=

@wez
Copy link
Member

wez commented Feb 10, 2022

@tntljc please file a separate issue and include all of the information requested by the form, thanks!

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants