-
Notifications
You must be signed in to change notification settings - Fork 403
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
Rust: Permissions Question #851
Comments
Hi 👋 Thanks for opening a detailed issue.
As I believe, updating
@CodeMan99 Let me know if that makes sense to you, thanks! |
Opened devcontainers/features#754 |
I am not completely sure to be honest. I don't think the feature creates So the rust feature still isn't responsible for the creation of the problem directory. |
I think I missed the part where you switch the users between running Curious, @CodeMan99 why do you switch users? I believe these Features/images were created hoping that the same user is been used for lifecycle of the dev container. Else, it would cause permission issues as seen in this issue ^ |
Usage of root is build-like usage. For example, using Then, during development |
Yes, that is correct. All Feature's install scripts are run with the With the Hence, I believe you should do either of the following to fix the issue -
|
The folder is created with exactly these permissions. root ➜ / $ cargo install --quiet bacon
root ➜ / $ ls -ld $CARGO_HOME/registry
drwxr-sr-x 5 root rustlang 4096 Nov 14 19:04 /usr/local/cargo/registry The
This advice does not resolve the issue. Example devcontainer.json file: {
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bullseye",
"features": {
"ghcr.io/lee-orr/rusty-dev-containers/bacon:0": {}
}
} This very simple configuration creates the problem:
So again, what is the correct course of action? Use of |
Let me clarify a little - "the course of action" is a question of who needs to own this knowledge.
|
A configuração de umask influencia as permissões padrão atribuídas a novos arquivos e diretórios criados pelos processos no sistema. O valor padrão, umask 022, significa que as permissões padrão são 755 para diretórios e 644 para arquivos. Se você deseja alterar o valor padrão do umask, pode fazer isso no arquivo de perfil (como .bashrc ou .bash_profile) do usuário ou no script de inicialização do contêiner. Aqui está um exemplo de como você poderia configurar o umask em um arquivo de perfil (por exemplo, .bashrc) no Dockerfile: FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye Configurando o umask no perfil do usuárioRUN echo "umask 022" >> /etc/skel/.bashrc Configurando o umask para o usuário existente 'vscode'RUN echo "umask 022" >> /home/vscode/.bashrc Dockerfile Copy code Configurando o umask no perfil do usuárioRUN echo "umask 022" >> /etc/skel/.bashrc Configurando o umask para o usuário existente 'vscode'RUN echo "umask 022" >> /home/vscode/.bashrc Lembre-se de que esta é uma sugestão geral, e a configuração específica pode depender dos requisitos e das práticas recomendadas em sua organização. Certifique-se de ajustar conforme necessário para atender às suas necessidades específicas. Parece que o problema está relacionado às permissões do diretório Aqui estão as etapas que você pode adicionar ao seu Dockerfile: FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye
# Adiciona o usuário 'vscode' ao grupo 'rustlang'
RUN usermod -aG rustlang vscode
# Define as permissões do diretório '/usr/local/cargo/registry'
RUN chown root:rustlang /usr/local/cargo/registry && chmod 775 /usr/local/cargo/registry
# Configura o umask no perfil do usuário
RUN echo "umask 022" >> /etc/skel/.bashrc
RUN echo "umask 022" >> /home/vscode/.bashrc
FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye
# Adiciona o usuário 'vscode' ao grupo 'rustlang'
RUN usermod -aG rustlang vscode
# Define as permissões do diretório '/usr/local/cargo/registry'
RUN chown root:rustlang /usr/local/cargo/registry && chmod 775 /usr/local/cargo/registry
# Configura o umask no perfil do usuário
RUN echo "umask 022" >> /etc/skel/.bashrc
RUN echo "umask 022" >> /home/vscode/.bashrc Estas são as principais alterações:
Depois de adicionar essas linhas ao seu Dockerfile e reconstruir a imagem, o usuário Peço desculpas pela confusão anterior. Parece que mesmo após adicionar o usuário A solução proposta anteriormente para alterar as permissões do diretório pode não ser suficiente. É possível que as permissões específicas do arquivo Uma solução mais robusta pode ser garantir que todos os arquivos e diretórios dentro de FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye
# Adiciona o usuário 'vscode' ao grupo 'rustlang'
RUN usermod -aG rustlang vscode
# Define as permissões do diretório '/usr/local/cargo/registry'
RUN chown -R root:rustlang /usr/local/cargo/registry && chmod -R 775 /usr/local/cargo/registry
# Configura o umask no perfil do usuário
RUN echo "umask 022" >> /etc/skel/.bashrc
RUN echo "umask 022" >> /home/vscode/.bashrc
FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye
# Adiciona o usuário 'vscode' ao grupo 'rustlang'
RUN usermod -aG rustlang vscode
# Define as permissões do diretório '/usr/local/cargo/registry'
RUN chown -R root:rustlang /usr/local/cargo/registry && chmod -R 775 /usr/local/cargo/registry
# Configura o umask no perfil do usuário
RUN echo "umask 022" >> /etc/skel/.bashrc
RUN echo "umask 022" >> /home/vscode/.bashrc Nesta versão, a alteração Após fazer essas alterações e reconstruir a imagem, tente novamente instalar o |
This PR is what I want. non-root@702362714ab7:~$ ls -l $CARGO_HOME
total 24
drwxrwxrwx 1 root root 4096 May 22 08:04 bin
-rwxr-xr-x 1 root rustlang 690 May 21 16:06 config.toml
-rw-rw-rw- 1 root root 308 May 14 03:57 env
drwxrwxr-x 1 root root 4096 May 22 08:04 registry
non-root@702362714ab7:~$ ls -l $RUSTUP_HOME
total 20
drwxrwxrwx 1 root root 4096 May 22 09:04 downloads
-rw-rw-rw- 1 root root 151 May 14 03:58 settings.toml
drwxrwxrwx 1 root root 4096 May 22 09:04 tmp
drwxrwxrwx 1 root root 4096 May 22 09:04 toolchains
drwxrwxrwx 1 root root 4096 May 22 09:04 update-hashes Can this PR be merged? |
Scenario
The rust image currently has
umask 022
set.$ docker run -it --rm --user root mcr.microsoft.com/devcontainers/rust:1-1-bullseye root ➜ / $ umask 0022 root ➜ / $ grep ^rustlang /etc/group rustlang:x:999:vscode
Should a build step, such as a feature use
cargo install
the resulting permissions prevent group write usage.root ➜ / $ cargo install --quiet bacon root ➜ / $ ls -ld $CARGO_HOME/registry drwxr-sr-x 5 root rustlang 4096 Nov 14 19:04 /usr/local/cargo/registry
Which then in turn breaks user-level usage of other cargo commands.
Question
What is the correct course of action?
umask 002
here, at the image level? Perhaps in/etc/profile
?umask 002
inside featureinstall.sh
scripts?The text was updated successfully, but these errors were encountered: