Skip to content

allow other users to write to mix_pubsub and mix_lock folders #14171

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

Merged
merged 2 commits into from
Jan 10, 2025

Conversation

SteffenDE
Copy link
Contributor

Fixes #14168.

defp init_base_path(path) do
File.mkdir_p!(path)
# ensure other users can write to the directory
_ = File.chmod(path, 0o777)
Copy link
Member

Choose a reason for hiding this comment

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

What if this fails? Because another user has created this directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's why I ignore the return value. I assume that the user that initially creates the folder has the necessary permissions.

Copy link
Member

Choose a reason for hiding this comment

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

Right, but the reason we have a report is exactly because the permissions are confusing. What if we generate a single directory like this: "mix-lock-#{user}-#{hash}". If we don't want to want to have the user there, we could urlbase64 it? Thoughts @jonatanklosko?

Copy link
Member

Choose a reason for hiding this comment

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

perhaps we should change the dir name in both cases to _2 suffix to not conflict with previous dirs created by Elixir? And if the dir is created by someone else then raising probably makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the reason we have a report is exactly because the permissions are confusing

I reproduced the problem in docker to make sure these changes work, but I don't have any objections to use multiple directories instead.

Copy link
Member

Choose a reason for hiding this comment

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

@jonatanklosko I think the safest would be to have one directory per user, then we don't have to worry about anything else. It is unlikely different users are sharing the same compilation, right?

@SteffenDE SteffenDE force-pushed the sd-mix-pubsub-chmod branch from a0d2edb to 1e80d57 Compare January 10, 2025 18:53
@SteffenDE
Copy link
Contributor Author

Changed to use separate paths per user. To reproduce:

broken on 1.18.1:

docker run --rm -it ubuntu:jammy sh -c "apt update && apt -y install git curl unzip sudo && \
  curl -fsSO https://elixir-lang.org/install.sh && \
  sh install.sh [email protected] [email protected] && \
  installs_dir=\$HOME/.elixir-install/installs && \
  export PATH=\$installs_dir/otp/27.2/bin:\$PATH && \
  export PATH=\$installs_dir/elixir/1.18.1-otp-27/bin:\$PATH && \
  chmod -R 777 /root/ && \
  useradd foo && \
  mix new project1 && \
  cd project1 && \
  mix compile && \
  cd / && \
  chmod 777 / && \
  sudo -u foo sh -c 'export PATH=/root/.elixir-install/installs/elixir/1.18.1-otp-27/bin:\$PATH && export PATH=/root/.elixir-install/installs/otp/27.2/bin:\$PATH && mix new project2 && cd project2 && mix compile'
"

works with the changes:

docker run --rm -it ubuntu:jammy sh -c "apt update && apt -y install git curl unzip build-essential sudo && \
  curl -fsSO https://elixir-lang.org/install.sh && \
  sh install.sh [email protected] [email protected] && \
  installs_dir=\$HOME/.elixir-install/installs && \
  export PATH=\$installs_dir/otp/27.2/bin:\$PATH && \
  chmod -R 777 /root/ && \
  git clone --depth 1 --branch sd-mix-pubsub-chmod https://github.com/SteffenDE/elixir.git && \
  cd elixir && \
  make compile && \
  export PATH=/elixir/bin:\$PATH && \
  useradd foo && \
  mix new project1 && \
  cd project1 && \
  mix compile && \
  cd / && \
  chmod 777 / && \
  sudo -u foo sh -c 'export PATH=/elixir/bin:\$PATH && export PATH=/root/.elixir-install/installs/otp/27.2/bin:\$PATH && mix new project2 && cd project2 && mix compile'
"

@josevalim josevalim merged commit 6657e7f into elixir-lang:main Jan 10, 2025
9 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

With Elixir 1.18, only a single user may compile a project
3 participants