Skip to content

Commit

Permalink
dockerfiles/dut: fix --chown option
Browse files Browse the repository at this point in the history
The docker docs contain [1] these COPY forms:

  COPY [--chown=<user>:<group>] [--chmod=<perms>] <src>... <dest>
  COPY [--chown=<user>:<group>] [--chmod=<perms>] ["<src>",... "<dest>"]

Arguments within [ ] are optional. The square brackets are not meant to
be part of the actual instruction.

The docker docs [1] mention that "[e]ach <src> may contain wildcards and
matching will be done using Go’s filepath.Match rules". Go’s
filepath.Match [2] interprets terms in square brackets as a character
class. "[--chown=root:root]" must have been interpreted as a valid
character class until recently. A couple of days ago, building the "dut"
service started failing:

  Building dut
  #0 building with "default" instance using docker driver

  #1 [internal] load build definition from Dockerfile
  #1 transferring dockerfile: 924B done
  #1 DONE 0.0s

  #2 [internal] load .dockerignore
  #2 transferring context: 2B done
  #2 DONE 0.0s

  #3 [internal] load metadata for docker.io/library/debian:bookworm-slim
  #3 DONE 0.1s

  #4 [1/4] FROM docker.io/library/debian:bookworm-slim@sha256:89468107e4c2b9fdea2f15fc582bf92c25aa4296a661ca0202f7ea2f4fc3f48c
  #4 CACHED

  #5 [internal] load build context
  #5 transferring context: 56B done
  #5 ERROR: error from sender: invalid includepatterns: []: syntax error in pattern

Fix this by dropping the accidental square brackets around the --chown
option.

[1] https://docs.docker.com/engine/reference/builder/#copy
[2] https://pkg.go.dev/path/filepath#Match

Signed-off-by: Bastian Krause <[email protected]>
  • Loading branch information
Bastian-Krause committed Aug 7, 2023
1 parent b0fe8dc commit 0523400
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dockerfiles/staging/dut/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ RUN set -e ;\
sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
# SSH login fix. Otherwise user is kicked off after login

COPY [--chown=root:root] ./authorized_keys /root/.ssh/authorized_keys
COPY --chown=root:root ./authorized_keys /root/.ssh/authorized_keys

# As sshd scrubs ENV variables if they are set by the ENV varibale ensure to put the into /etc/profile as shown below
ENV NOTVISIBLE "in users profile"
Expand Down

0 comments on commit 0523400

Please sign in to comment.