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

Dockerfile ADD not preserving "s" file attribute. #36239

Open
pauldotknopf opened this issue Feb 7, 2018 · 12 comments
Open

Dockerfile ADD not preserving "s" file attribute. #36239

pauldotknopf opened this issue Feb 7, 2018 · 12 comments
Labels
area/builder kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. kind/question

Comments

@pauldotknopf
Copy link

pauldotknopf commented Feb 7, 2018

> ls -l root.x86_64/sbin/unix_chkpwd
-rwsr-sr-x 1 root root 31392 Jun  9  2016 root.x86_64/sbin/unix_chkpwd

Then I add the folder with the docker file.

ADD root.x86_64 /

When the image is built, the permissions are different. Running from within the container:

> ls -l /sbin/unix_chkpwd
-rwxr-xr-x 1 root root 31392 Jun  9  2016 /sbin/unix_chkpwd
> docker --version
Docker version 18.01.0-ce, build 03596f51b1
@pauldotknopf
Copy link
Author

pauldotknopf commented Feb 7, 2018

It works if I add a tar.gz, and let Docker extract the tarbal.

ADD archlinux-bootstrap-2018.02.01-x86_64.tar.gz /
RUN ls -l /root.x86_64/sbin/unix_chkpwd

This is the output.

-rwsr-sr-x 1 root root 31392 Jun  9  2016 /root.x86_64/sbin/unix_chkpwd

@AkihiroSuda
Copy link
Member

@tonistiigi @vdemeester @dnephin

Was this intentional?

@dnephin
Copy link
Member

dnephin commented Feb 8, 2018

I'm not aware of any reason this would be intentional.

@pauldotknopf
Copy link
Author

Original question which helped me figure out what the issue was: https://unix.stackexchange.com/questions/422411/pam-authentication-failure-with-valid-password

@pauldotknopf
Copy link
Author

What is the status of this? Any estimate for fix?

@AkihiroSuda
Copy link
Member

cc @tonistiigi PTAL?

@tonistiigi tonistiigi added the kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. label Jul 19, 2018
@SmilingNavern
Copy link

I would like to try to fix this one.

@AkihiroSuda
Copy link
Member

Thanks, PR is appreciated

@SmilingNavern
Copy link

Okay, i think i got it. It looks like file with permissions is created before issuing chown syscall on it. And in linux if you make chown that discards suid bit permissions.

@SmilingNavern
Copy link

SmilingNavern commented Nov 8, 2018

@AkihiroSuda i've created PR for this bug, but i am not sure about implementation. I would be glad to read your comments on this one

@thaJeztah
Copy link
Member

Looks like this issue only affects the classic builder, and is fixed with BuildKit enabled;

mkdir repro-36239 && cd repro-36239 
touch 1.bin
chmod 700 1.bin
chmod u+xs 1.bin

ls -la 1.bin
# -rws------ 1 root root 0 Jan 28 10:16 1.bin

echo -e 'FROM busybox:latest\nADD 1.bin /1.bin' > Dockerfile

DOCKER_BUILDKIT=0 docker build -t test .
docker run --rm test ls -la /1.bin
# -rwx------    1 root     root             0 Jan 28 10:16 /1.bin


DOCKER_BUILDKIT=1 docker build -t test .
docker run --rm test ls -la /1.bin
# -rws------    1 root     root             0 Jan 28 10:16 /1.bin

@thaJeztah
Copy link
Member

Just to check; docker cp and docker commit als seem to work;

docker run -di --name test busybox

docker cp ./1.bin test:/
docker exec test ls -la /1.bin
# -rws------    1 root     root             0 Jan 28 10:16 /1.bin

docker commit test testimage
docker run --rm testimage ls -la /1.bin
# -rws------    1 root     root             0 Jan 28 10:16 /1.bin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/builder kind/bug Bugs are bugs. The cause may or may not be known at triage time so debugging may be needed. kind/question
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants