summaryrefslogtreecommitdiff
path: root/daemon/archive.go
Commit message (Collapse)AuthorAgeFilesLines
* daemon: refactor isOnlineFSOperationPermittedCory Snider2022-10-261-20/+0
| | | | | | | It is only applicable to Windows so it does not need to be called from platform-generic code. Fix locking in the Windows implementation. Signed-off-by: Cory Snider <csnider@mirantis.com>
* daemon: dupe the archive implementationCory Snider2022-10-261-304/+0
| | | | | | | | | | | The Linux implementation needs to diverge significantly from the Windows one in order to fix platform-specific bugs. Cut the generic implementation out of daemon/archive.go and paste identical, verbatim copies of that implementation into daemon/archive_{windows,linux}.go to make it easier to compare the progression of changes to the respective implementations through Git history. Signed-off-by: Cory Snider <csnider@mirantis.com>
* daemon: replace ErrExtractPointNotDirectory with errdefsSebastiaan van Stijn2022-09-271-8/+3
| | | | | | | | | | | | | | | | It was only used in a single location, and the ErrExtractPointNotDirectory was not checked for, or used as a sentinel error. This error was introduced in c32dde5baadc8c472666ef9d5cead13ab6de28ea. It was never used as a sentinel error, but from that commit, it looks like it was added as a package variable to mirror already existing errors defined at the package level. This patch removes the exported variable, and replaces the error with an errdefs.InvalidParameter(), so that the API also returns the correct (400) status code. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* daemon: replace ErrRootFSReadOnly with errdefsSebastiaan van Stijn2022-09-271-1/+1
| | | | | | | | | | | | | | | | It was only used in a single location, and the ErrRootFSReadOnly was not checked for, or used as a sentinel error. This error was introduced in c32dde5baadc8c472666ef9d5cead13ab6de28ea, originally named `ErrContainerRootfsReadonly`. It was never used as a sentinel error, but from that commit, it looks like it was added as a package variable to mirror the coding style of already existing errors defined at the package level. This patch removes the exported variable, and replaces the error with an errdefs.InvalidParameter(), so that the API also returns the correct (400) status code. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* daemon: clean up vestiges of ContainerFSCory Snider2022-09-231-38/+6
| | | | | | | | | Now that the type of Container.BaseFS has been reverted to a string, values can never implement the extractor or archiver interfaces. Rip out the dead code to support archiving and unarchiving through those interfcaes. Signed-off-by: Cory Snider <csnider@mirantis.com>
* pkg/containerfs: alias ContainerFS to stringCory Snider2022-09-231-6/+6
| | | | | | Drop the constructor and redundant string() type-casts. Signed-off-by: Cory Snider <csnider@mirantis.com>
* pkg/containerfs: simplify ContainerFS typeCory Snider2022-09-231-6/+6
| | | | | | Iterate towards dropping the type entirely. Signed-off-by: Cory Snider <csnider@mirantis.com>
* pkg/containerfs: drop Driver abstractionCory Snider2022-09-231-2/+2
| | | | | | | | | | The Driver abstraction was needed for Linux Containers on Windows, support for which has since been removed. There is no direct equivalent to Lchmod() in the standard library so continue to use the containerd/continuity version. Signed-off-by: Cory Snider <csnider@mirantis.com>
* pkg/containerfs: drop PathDriver abstractionCory Snider2022-09-231-17/+15
| | | | | | | With LCOW support removed, there is no need to support non-native file paths any longer. Signed-off-by: Cory Snider <csnider@mirantis.com>
* daemon: rename variables that collide with imported package namesSebastiaan van Stijn2020-04-141-15/+15
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* daemon: fix docker cp when container source is /Tibor Vass2019-06-131-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before 7a7357da, archive.TarResourceRebase was being used to copy files and folders from the container. That function splits the source path into a dirname + basename pair to support copying a file: if you wanted to tar `dir/file` it would tar from `dir` the file `file` (as part of the IncludedFiles option). However, that path splitting logic was kept for folders as well, which resulted in weird inputs to archive.TarWithOptions: if you wanted to tar `dir1/dir2` it would tar from `dir1` the directory `dir2` (as part of IncludedFiles option). Although it was weird, it worked fine until we started chrooting into the container rootfs when doing a `docker cp` with container source set to `/` (cf 3029e765). The fix is to only do the path splitting logic if the source is a file. Unfortunately, 7a7357da added support for LCOW by duplicating some of this subtle logic. Ideally we would need to do more refactoring of the archive codebase to properly encapsulate these behaviors behind well- documented APIs. This fix does not do that. Instead, it fixes the issue inline. Signed-off-by: Tibor Vass <tibor@docker.com>
* Add chroot for tar packing operationsBrian Goff2019-06-031-4/+4
| | | | | | | | Previously only unpack operations were supported with chroot. This adds chroot support for packing operations. This prevents potential breakouts when copying data from a container. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Pass root to chroot to for chroot UntarBrian Goff2019-06-031-3/+4
| | | | | | | | | | | This is useful for preventing CVE-2018-15664 where a malicious container process can take advantage of a race on symlink resolution/sanitization. Before this change chrootarchive would chroot to the destination directory which is attacker controlled. With this patch we always chroot to the container's root which is not attacker controlled. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Add canonical import commentDaniel Nephin2018-02-051-1/+1
| | | | Signed-off-by: Daniel Nephin <dnephin@docker.com>
* Move api/errdefs to errdefsBrian Goff2018-01-111-1/+1
| | | | Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Add helpers to create errdef errorsBrian Goff2018-01-111-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of having to create a bunch of custom error types that are doing nothing but wrapping another error in sub-packages, use a common helper to create errors of the requested type. e.g. instead of re-implementing this over and over: ```go type notFoundError struct { cause error } func(e notFoundError) Error() string { return e.cause.Error() } func(e notFoundError) NotFound() {} func(e notFoundError) Cause() error { return e.cause } ``` Packages can instead just do: ``` errdefs.NotFound(err) ``` Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* LCOW: Implemented support for docker cp + buildAkash Gupta2017-09-141-15/+70
| | | | | | | | | | This enables docker cp and ADD/COPY docker build support for LCOW. Originally, the graphdriver.Get() interface returned a local path to the container root filesystem. This does not work for LCOW, so the Get() method now returns an interface that LCOW implements to support copying to and from the container. Signed-off-by: Akash Gupta <akagup@microsoft.com>
* Remove string checking in API error handlingBrian Goff2017-08-151-12/+43
| | | | | | | | | | | | | | Use strongly typed errors to set HTTP status codes. Error interfaces are defined in the api/errors package and errors returned from controllers are checked against these interfaces. Errors can be wraeped in a pkg/errors.Causer, as long as somewhere in the line of causes one of the interfaces is implemented. The special error interfaces take precedence over Causer, meaning if both Causer and one of the new error interfaces are implemented, the Causer is not traversed. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Fix copy when used with scratch and images with empty RootFSDaniel Nephin2017-06-081-1/+1
| | | | | | | | | | | | | | | Commit the rwLayer to get the correct DiffID Refacator copy in thebuilder move more code into exportImage cleanup some windows tests Release the newly commited layer. Set the imageID on the buildStage after exporting a new image. Move archiver to BuildManager. Have ReleaseableLayer.Commit return a layer and store the Image from exportImage in the local imageSources cache Remove NewChild from image interface. Signed-off-by: Daniel Nephin <dnephin@docker.com>
* Remove CopyOnBuild from the daemon.Daniel Nephin2017-06-081-103/+1
| | | | | | | | Add CreateImage() to the daemon Refactor daemon.Comit() and expose a Image.NewChild() Update copy to use IDMappings. Signed-off-by: Daniel Nephin <dnephin@docker.com>
* Remove error return from RootPairDaniel Nephin2017-06-071-1/+1
| | | | | | There is no case which would resolve in this error. The root user always exists, and if the id maps are empty, the default value of 0 is correct. Signed-off-by: Daniel Nephin <dnephin@docker.com>
* Remove unused functions from archive.Daniel Nephin2017-06-071-6/+1
| | | | Signed-off-by: Daniel Nephin <dnephin@docker.com>
* Partial refactor of UID/GID usage to use a unified struct.Daniel Nephin2017-06-071-7/+6
| | | | Signed-off-by: Daniel Nephin <dnephin@docker.com>
* Expose a smaller interface for the Builder retrieving images from daemonDaniel Nephin2017-05-101-33/+0
| | | | | | | Removes 3 methods from the builder.Backend interface Remove the coupling between imageContexts, imageMounts and the builder. Signed-off-by: Daniel Nephin <dnephin@docker.com>
* Refactor remote context parsingTonis Tiigi2017-04-251-10/+19
| | | | | | | Redefine a better interface for remote context dependency. Separate Dockerfile build instruction from remote context. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
* daemon/archive.go: Fix copy routines to preserve UID.Erik Hollensbe2017-04-121-9/+14
| | | | | | | This changes the long-standing bug of copy operations not preserving the UID/GID information after the files arrive to the container. Signed-off-by: Erik Hollensbe <github@hollensbe.org>
* Add support for COPY from previous rootfsTonis Tiigi2017-03-231-1/+34
| | | | Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
* Windows: Fail fs ops on running Hyper-V containers gracefullyJohn Howard (VM)2017-03-151-0/+20
| | | | Signed-off-by: John Howard (VM) <jhoward@ntdev.microsoft.com>
* Fix uneccessary calls to `volume.Unmount()`Brian Goff2016-11-101-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #22564 When an error occurs on mount, there should not be any call later to unmount. This can throw off refcounting in the underlying driver unexpectedly. Consider these two cases: ``` $ docker run -v foo:/bar busybox true ``` ``` $ docker run -v foo:/bar -w /foo busybox true ``` In the first case, if mounting `foo` fails, the volume driver will not get a call to unmount (this is the incorrect behavior). In the second case, the volume driver will not get a call to unmount (correct behavior). This occurs because in the first case, `/bar` does not exist in the container, and as such there is no call to `volume.Mount()` during the `create` phase. It will error out during the `start` phase. In the second case `/bar` is created before dealing with the volume because of the `-w`. Because of this, when the volume is being setup docker will try to copy the image path contents in the volume, in which case it will attempt to mount the volume and fail. This happens during the `create` phase. This makes it so the container will not be created (or at least fully created) and the user gets the error on `create` instead of `start`. The error handling is different in these two phases. Changed to only send `unmount` if the volume is mounted. While investigating the cause of the reported issue I found some odd behavior in unmount calls so I've cleaned those up a bit here as well. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Add engine-api types to dockerMichael Crosby2016-09-071-1/+1
| | | | | | | This moves the types for the `engine-api` repo to the existing types package. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
* Windows: docker cp consistent pathsJohn Howard2016-05-061-0/+7
| | | | Signed-off-by: John Howard <jhoward@microsoft.com>
* Fix copy chown settings to not default to real rootPhil Estes2016-02-181-3/+3
| | | | | | | | | This corrects `docker cp` behavior when user namespaces are enabled. Instead of chown'ing copied-in files to real root (0,0), the code queries for the remapped root uid & gid and sets the chown option properly. Docker-DCO-1.1-Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com> (github: estesp)
* Remove package daemonbuilder.Anusha Ragunathan2016-02-011-0/+99
| | | | | | | | | | | | | Currently, daemonbuilder package (part of daemon) implemented the builder backend. However, it was a very thin wrapper around daemon methods and caused an implementation dependency for api/server build endpoint. api/server buildrouter should only know about the backend implementing the /build API endpoint. Removing daemonbuilder involved moving build specific methods to respective files in the daemon, where they fit naturally. Signed-off-by: Anusha Ragunathan <anusha@docker.com>
* Modify import paths to point to the new engine-api package.David Calavera2016-01-061-1/+1
| | | | Signed-off-by: David Calavera <david.calavera@gmail.com>
* Add volume events.David Calavera2015-12-301-6/+6
| | | | Signed-off-by: David Calavera <david.calavera@gmail.com>
* Fix typos found across repositoryJustas Brazauskas2015-12-131-1/+1
| | | | Signed-off-by: Justas Brazauskas <brazauskasjustas@gmail.com>
* Rename `Daemon.Get` to `Daemon.GetContainer`.David Calavera2015-12-111-4/+4
| | | | | | This is more aligned with `Daemon.GetImage` and less confusing. Signed-off-by: David Calavera <david.calavera@gmail.com>
* Move Container to its own package.David Calavera2015-12-031-79/+20
| | | | | | | | So other packages don't need to import the daemon package when they want to use this struct. Signed-off-by: David Calavera <david.calavera@gmail.com> Signed-off-by: Tibor Vass <tibor@docker.com>
* Remove further references to the daemon within containers.David Calavera2015-11-041-4/+4
| | | | Signed-off-by: David Calavera <david.calavera@gmail.com>
* Decouple daemon and container to log events.David Calavera2015-11-041-3/+3
| | | | | | Create a supervisor interface to let the container monitor to emit events. Signed-off-by: David Calavera <david.calavera@gmail.com>
* Move `Daemon.containerCopy` to daemon/archive.goDavid Calavera2015-11-041-0/+65
| | | | | | It's the only place where it's used. Signed-off-by: David Calavera <david.calavera@gmail.com>
* Decouple daemon and container to mount and unmount filesystems.David Calavera2015-11-041-17/+17
| | | | | | | | Side effects: - Decouple daemon and container to start containers. - Decouple daemon and container to copy files. Signed-off-by: David Calavera <david.calavera@gmail.com>
* Revert "Merge pull request #16228 from duglin/ContextualizeEvents"Tibor Vass2015-09-291-25/+24
| | | | | | | | | | | | | | | | | | | | | Although having a request ID available throughout the codebase is very valuable, the impact of requiring a Context as an argument to every function in the codepath of an API request, is too significant and was not properly understood at the time of the review. Furthermore, mixing API-layer code with non-API-layer code makes the latter usable only by API-layer code (one that has a notion of Context). This reverts commit de4164043546d2b9ee3bf323dbc41f4979c84480, reversing changes made to 7daeecd42d7bb112bfe01532c8c9a962bb0c7967. Signed-off-by: Tibor Vass <tibor@docker.com> Conflicts: api/server/container.go builder/internals.go daemon/container_unix.go daemon/create.go
* Add context.RequestID to event streamDoug Davis2015-09-241-24/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | This PR adds a "request ID" to each event generated, the 'docker events' stream now looks like this: ``` 2015-09-10T15:02:50.000000000-07:00 [reqid: c01e3534ddca] de7c5d4ca927253cf4e978ee9c4545161e406e9b5a14617efb52c658b249174a: (from ubuntu) create ``` Note the `[reqID: c01e3534ddca]` part, that's new. Each HTTP request will generate its own unique ID. So, if you do a `docker build` you'll see a series of events all with the same reqID. This allow for log processing tools to determine which events are all related to the same http request. I didn't propigate the context to all possible funcs in the daemon, I decided to just do the ones that needed it in order to get the reqID into the events. I'd like to have people review this direction first, and if we're ok with it then I'll make sure we're consistent about when we pass around the context - IOW, make sure that all funcs at the same level have a context passed in even if they don't call the log funcs - this will ensure we're consistent w/o passing it around for all calls unnecessarily. ping @icecrime @calavera @crosbymichael Signed-off-by: Doug Davis <dug@us.ibm.com>
* Merge pull request #15834 from Microsoft/10662-fixdockercpAlexander Morozov2015-09-011-1/+17
|\ | | | | Windows: Fix docker cp
| * Windows: Fix docker cpJohn Howard2015-08-251-1/+17
| | | | | | | | Signed-off-by: John Howard <jhoward@microsoft.com>
* | golint fixes for daemon/ packageMorgan Bauer2015-08-271-8/+8
|/ | | | | | | | | | | | - some method names were changed to have a 'Locking' suffix, as the downcased versions already existed, and the existing functions simply had locks around the already downcased version. - deleting unused functions - package comment - magic numbers replaced by golang constants - comments all over Signed-off-by: Morgan Bauer <mbauer@us.ibm.com>
* typofix - https://github.com/vlajos/misspell_fixerVeres Lajos2015-08-071-1/+1
| | | | Signed-off-by: Veres Lajos <vlajos@gmail.com>
* Fix `docker cp` Behavior With SymlinksJosh Hawn2015-07-301-74/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [pkg/archive] Update archive/copy path handling - Remove unused TarOptions.Name field. - Add new TarOptions.RebaseNames field. - Update some of the logic around path dir/base splitting. - Update some of the logic behind archive entry name rebasing. [api/types] Add LinkTarget field to PathStat [daemon] Fix stat, archive, extract of symlinks These operations *should* resolve symlinks that are in the path but if the resource itself is a symlink then it *should not* be resolved. This patch puts this logic into a common function `resolvePath` which resolves symlinks of the path's dir in scope of the container rootfs but does not resolve the final element of the path. Now archive, extract, and stat operations will return symlinks if the path is indeed a symlink. [api/client] Update cp path hanling [docs/reference/api] Update description of stat Add the linkTarget field to the header of the archive endpoint. Remove path field. [integration-cli] Fix/Add cp symlink test cases Copying a symlink should do just that: copy the symlink NOT copy the target of the symlink. Also, the resulting file from the copy should have the name of the symlink NOT the name of the target file. Copying to a symlink should copy to the symlink target and not modify the symlink itself. Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
* Windows: Factoring out unused fieldsJohn Howard2015-07-271-14/+9
| | | | Signed-off-by: John Howard <jhoward@microsoft.com>