2014-04-17 17:43:01 -04:00
|
|
|
package daemon
|
2014-02-14 20:15:40 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2014-09-24 09:07:11 -04:00
|
|
|
"io"
|
2014-02-14 20:15:40 -05:00
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2014-09-15 20:51:06 -04:00
|
|
|
"sort"
|
2014-02-14 20:15:40 -05:00
|
|
|
"strings"
|
2014-05-05 17:45:14 -04:00
|
|
|
|
2014-10-24 18:11:48 -04:00
|
|
|
log "github.com/Sirupsen/logrus"
|
2014-07-24 18:19:50 -04:00
|
|
|
"github.com/docker/docker/daemon/execdriver"
|
2014-10-29 15:06:51 -04:00
|
|
|
"github.com/docker/docker/pkg/chrootarchive"
|
2014-07-24 18:19:50 -04:00
|
|
|
"github.com/docker/docker/pkg/symlink"
|
2015-03-11 11:42:49 -04:00
|
|
|
"github.com/docker/docker/pkg/system"
|
2014-08-28 10:18:08 -04:00
|
|
|
"github.com/docker/docker/volumes"
|
2014-02-14 20:15:40 -05:00
|
|
|
)
|
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
type Mount struct {
|
|
|
|
MountToPath string
|
|
|
|
container *Container
|
|
|
|
volume *volumes.Volume
|
|
|
|
Writable bool
|
2014-10-06 13:30:42 -04:00
|
|
|
copyData bool
|
2014-12-12 11:01:05 -05:00
|
|
|
from *Container
|
2015-01-26 17:31:30 -05:00
|
|
|
isBind bool
|
2014-08-08 11:00:18 -04:00
|
|
|
}
|
|
|
|
|
2014-09-24 09:07:11 -04:00
|
|
|
func (mnt *Mount) Export(resource string) (io.ReadCloser, error) {
|
|
|
|
var name string
|
|
|
|
if resource == mnt.MountToPath[1:] {
|
|
|
|
name = filepath.Base(resource)
|
|
|
|
}
|
|
|
|
path, err := filepath.Rel(mnt.MountToPath[1:], resource)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return mnt.volume.Export(path, name)
|
|
|
|
}
|
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
func (container *Container) prepareVolumes() error {
|
2014-02-14 20:15:40 -05:00
|
|
|
if container.Volumes == nil || len(container.Volumes) == 0 {
|
|
|
|
container.Volumes = make(map[string]string)
|
|
|
|
container.VolumesRW = make(map[string]bool)
|
|
|
|
}
|
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
return container.createVolumes()
|
2014-02-14 20:15:40 -05:00
|
|
|
}
|
|
|
|
|
2014-09-15 20:51:06 -04:00
|
|
|
// sortedVolumeMounts returns the list of container volume mount points sorted in lexicographic order
|
|
|
|
func (container *Container) sortedVolumeMounts() []string {
|
|
|
|
var mountPaths []string
|
|
|
|
for path := range container.Volumes {
|
|
|
|
mountPaths = append(mountPaths, path)
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.Strings(mountPaths)
|
|
|
|
return mountPaths
|
|
|
|
}
|
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
func (container *Container) createVolumes() error {
|
|
|
|
mounts, err := container.parseVolumeMountConfig()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
2014-08-21 17:57:46 -04:00
|
|
|
}
|
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
for _, mnt := range mounts {
|
|
|
|
if err := mnt.initialize(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2014-08-21 17:57:46 -04:00
|
|
|
}
|
|
|
|
|
2014-12-12 11:01:05 -05:00
|
|
|
// On every start, this will apply any new `VolumesFrom` entries passed in via HostConfig, which may override volumes set in `create`
|
|
|
|
return container.applyVolumesFrom()
|
2014-08-28 10:18:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (m *Mount) initialize() error {
|
|
|
|
// No need to initialize anything since it's already been initialized
|
2014-12-12 11:01:05 -05:00
|
|
|
if hostPath, exists := m.container.Volumes[m.MountToPath]; exists {
|
|
|
|
// If this is a bind-mount/volumes-from, maybe it was passed in at start instead of create
|
|
|
|
// We need to make sure bind-mounts/volumes-from passed on start can override existing ones.
|
2015-01-26 17:31:30 -05:00
|
|
|
if (!m.volume.IsBindMount && !m.isBind) && m.from == nil {
|
2014-12-12 11:01:05 -05:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if m.volume.Path == hostPath {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure we remove these old volumes we don't actually want now.
|
|
|
|
// Ignore any errors here since this is just cleanup, maybe someone volumes-from'd this volume
|
2015-02-10 13:45:50 -05:00
|
|
|
if v := m.container.daemon.volumes.Get(hostPath); v != nil {
|
|
|
|
v.RemoveContainer(m.container.ID)
|
|
|
|
m.container.daemon.volumes.Delete(v.Path)
|
|
|
|
}
|
2014-08-28 10:18:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// This is the full path to container fs + mntToPath
|
|
|
|
containerMntPath, err := symlink.FollowSymlinkInScope(filepath.Join(m.container.basefs, m.MountToPath), m.container.basefs)
|
2014-08-21 17:57:46 -04:00
|
|
|
if err != nil {
|
2014-08-28 10:18:08 -04:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
m.container.VolumesRW[m.MountToPath] = m.Writable
|
|
|
|
m.container.Volumes[m.MountToPath] = m.volume.Path
|
|
|
|
m.volume.AddContainer(m.container.ID)
|
2014-10-06 13:30:42 -04:00
|
|
|
if m.Writable && m.copyData {
|
2014-08-28 10:18:08 -04:00
|
|
|
// Copy whatever is in the container at the mntToPath to the volume
|
|
|
|
copyExistingContents(containerMntPath, m.volume.Path)
|
2014-08-21 17:57:46 -04:00
|
|
|
}
|
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
return nil
|
|
|
|
}
|
2014-08-21 17:57:46 -04:00
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
func (container *Container) VolumePaths() map[string]struct{} {
|
|
|
|
var paths = make(map[string]struct{})
|
|
|
|
for _, path := range container.Volumes {
|
|
|
|
paths[path] = struct{}{}
|
2014-08-21 17:57:46 -04:00
|
|
|
}
|
2014-08-28 10:18:08 -04:00
|
|
|
return paths
|
2014-08-21 17:57:46 -04:00
|
|
|
}
|
|
|
|
|
2014-10-08 13:13:32 -04:00
|
|
|
func (container *Container) registerVolumes() {
|
2015-01-16 14:48:25 -05:00
|
|
|
for path := range container.VolumePaths() {
|
|
|
|
if v := container.daemon.volumes.Get(path); v != nil {
|
|
|
|
v.AddContainer(container.ID)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
// if container was created with an old daemon, this volume may not be registered so we need to make sure it gets registered
|
|
|
|
writable := true
|
|
|
|
if rw, exists := container.VolumesRW[path]; exists {
|
|
|
|
writable = rw
|
|
|
|
}
|
|
|
|
v, err := container.daemon.volumes.FindOrCreateVolume(path, writable)
|
|
|
|
if err != nil {
|
|
|
|
log.Debugf("error registering volume %s: %v", path, err)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
v.AddContainer(container.ID)
|
2014-10-08 13:13:32 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
func (container *Container) derefVolumes() {
|
|
|
|
for path := range container.VolumePaths() {
|
|
|
|
vol := container.daemon.volumes.Get(path)
|
|
|
|
if vol == nil {
|
|
|
|
log.Debugf("Volume %s was not found and could not be dereferenced", path)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
vol.RemoveContainer(container.ID)
|
|
|
|
}
|
|
|
|
}
|
2014-02-14 20:15:40 -05:00
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
func (container *Container) parseVolumeMountConfig() (map[string]*Mount, error) {
|
|
|
|
var mounts = make(map[string]*Mount)
|
|
|
|
// Get all the bind mounts
|
|
|
|
for _, spec := range container.hostConfig.Binds {
|
|
|
|
path, mountToPath, writable, err := parseBindMountSpec(spec)
|
2014-08-21 17:57:46 -04:00
|
|
|
if err != nil {
|
2014-08-28 10:18:08 -04:00
|
|
|
return nil, err
|
2014-08-21 17:57:46 -04:00
|
|
|
}
|
2015-02-06 17:00:53 -05:00
|
|
|
// Check if a bind mount has already been specified for the same container path
|
|
|
|
if m, exists := mounts[mountToPath]; exists {
|
|
|
|
return nil, fmt.Errorf("Duplicate volume %q: %q already in use, mounted from %q", path, mountToPath, m.volume.Path)
|
|
|
|
}
|
2014-08-28 10:18:08 -04:00
|
|
|
// Check if a volume already exists for this and use it
|
2014-09-26 20:42:24 -04:00
|
|
|
vol, err := container.daemon.volumes.FindOrCreateVolume(path, writable)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2014-02-14 20:15:40 -05:00
|
|
|
}
|
2014-10-06 13:30:42 -04:00
|
|
|
mounts[mountToPath] = &Mount{
|
|
|
|
container: container,
|
|
|
|
volume: vol,
|
|
|
|
MountToPath: mountToPath,
|
|
|
|
Writable: writable,
|
2015-01-26 17:31:30 -05:00
|
|
|
isBind: true, // in case the volume itself is a normal volume, but is being mounted in as a bindmount here
|
2014-10-06 13:30:42 -04:00
|
|
|
}
|
2014-02-14 20:15:40 -05:00
|
|
|
}
|
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
// Get the rest of the volumes
|
|
|
|
for path := range container.Config.Volumes {
|
|
|
|
// Check if this is already added as a bind-mount
|
2014-10-20 15:27:26 -04:00
|
|
|
path = filepath.Clean(path)
|
2014-08-28 10:18:08 -04:00
|
|
|
if _, exists := mounts[path]; exists {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2014-10-08 15:01:25 -04:00
|
|
|
// Check if this has already been created
|
|
|
|
if _, exists := container.Volumes[path]; exists {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2015-01-14 22:30:28 -05:00
|
|
|
if stat, err := os.Stat(filepath.Join(container.basefs, path)); err == nil {
|
|
|
|
if !stat.IsDir() {
|
|
|
|
return nil, fmt.Errorf("file exists at %s, can't create volume there")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-26 20:42:24 -04:00
|
|
|
vol, err := container.daemon.volumes.FindOrCreateVolume("", true)
|
2014-08-28 10:18:08 -04:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2014-10-06 13:30:42 -04:00
|
|
|
mounts[path] = &Mount{
|
|
|
|
container: container,
|
|
|
|
MountToPath: path,
|
|
|
|
volume: vol,
|
|
|
|
Writable: true,
|
|
|
|
copyData: true,
|
|
|
|
}
|
2014-08-21 17:57:46 -04:00
|
|
|
}
|
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
return mounts, nil
|
2014-08-21 17:57:46 -04:00
|
|
|
}
|
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
func parseBindMountSpec(spec string) (string, string, bool, error) {
|
2014-08-06 15:27:58 -04:00
|
|
|
var (
|
2014-08-28 10:18:08 -04:00
|
|
|
path, mountToPath string
|
|
|
|
writable bool
|
|
|
|
arr = strings.Split(spec, ":")
|
2014-08-06 15:27:58 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
switch len(arr) {
|
|
|
|
case 2:
|
2014-08-28 10:18:08 -04:00
|
|
|
path = arr[0]
|
|
|
|
mountToPath = arr[1]
|
|
|
|
writable = true
|
2014-08-06 15:27:58 -04:00
|
|
|
case 3:
|
2014-08-28 10:18:08 -04:00
|
|
|
path = arr[0]
|
|
|
|
mountToPath = arr[1]
|
|
|
|
writable = validMountMode(arr[2]) && arr[2] == "rw"
|
2014-08-06 15:27:58 -04:00
|
|
|
default:
|
2014-08-28 10:18:08 -04:00
|
|
|
return "", "", false, fmt.Errorf("Invalid volume specification: %s", spec)
|
2014-08-06 15:27:58 -04:00
|
|
|
}
|
2014-08-08 11:00:18 -04:00
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
if !filepath.IsAbs(path) {
|
|
|
|
return "", "", false, fmt.Errorf("cannot bind mount volume: %s volume paths must be absolute.", path)
|
2014-08-08 11:00:18 -04:00
|
|
|
}
|
|
|
|
|
2014-10-20 15:27:26 -04:00
|
|
|
path = filepath.Clean(path)
|
|
|
|
mountToPath = filepath.Clean(mountToPath)
|
2014-08-28 10:18:08 -04:00
|
|
|
return path, mountToPath, writable, nil
|
2014-08-06 15:27:58 -04:00
|
|
|
}
|
|
|
|
|
2014-12-18 09:57:36 -05:00
|
|
|
func parseVolumesFromSpec(spec string) (string, string, error) {
|
|
|
|
specParts := strings.SplitN(spec, ":", 2)
|
|
|
|
if len(specParts) == 0 {
|
|
|
|
return "", "", fmt.Errorf("malformed volumes-from specification: %s", spec)
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
id = specParts[0]
|
|
|
|
mode = "rw"
|
|
|
|
)
|
|
|
|
if len(specParts) == 2 {
|
|
|
|
mode = specParts[1]
|
|
|
|
if !validMountMode(mode) {
|
|
|
|
return "", "", fmt.Errorf("invalid mode for volumes-from: %s", mode)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return id, mode, nil
|
|
|
|
}
|
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
func (container *Container) applyVolumesFrom() error {
|
|
|
|
volumesFrom := container.hostConfig.VolumesFrom
|
2014-12-18 09:57:36 -05:00
|
|
|
if len(volumesFrom) > 0 && container.AppliedVolumesFrom == nil {
|
|
|
|
container.AppliedVolumesFrom = make(map[string]struct{})
|
|
|
|
}
|
2014-02-14 20:15:40 -05:00
|
|
|
|
2014-12-18 09:57:36 -05:00
|
|
|
mountGroups := make(map[string][]*Mount)
|
2014-10-23 08:50:06 -04:00
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
for _, spec := range volumesFrom {
|
2014-12-18 09:57:36 -05:00
|
|
|
id, mode, err := parseVolumesFromSpec(spec)
|
2014-08-28 10:18:08 -04:00
|
|
|
if err != nil {
|
|
|
|
return err
|
2014-02-14 20:15:40 -05:00
|
|
|
}
|
2014-12-18 09:57:36 -05:00
|
|
|
if _, exists := container.AppliedVolumesFrom[id]; exists {
|
|
|
|
// Don't try to apply these since they've already been applied
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2014-12-16 18:06:35 -05:00
|
|
|
c, err := container.daemon.Get(id)
|
|
|
|
if err != nil {
|
2015-02-24 06:42:51 -05:00
|
|
|
return fmt.Errorf("Could not apply volumes of non-existent container %q.", id)
|
2014-12-18 09:57:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
fromMounts = c.VolumeMounts()
|
|
|
|
mounts []*Mount
|
|
|
|
)
|
|
|
|
|
|
|
|
for _, mnt := range fromMounts {
|
|
|
|
mnt.Writable = mnt.Writable && (mode == "rw")
|
|
|
|
mounts = append(mounts, mnt)
|
|
|
|
}
|
|
|
|
mountGroups[id] = mounts
|
2014-10-23 08:50:06 -04:00
|
|
|
}
|
2014-05-19 18:18:37 -04:00
|
|
|
|
2014-12-18 09:57:36 -05:00
|
|
|
for id, mounts := range mountGroups {
|
2014-08-28 10:18:08 -04:00
|
|
|
for _, mnt := range mounts {
|
2014-12-12 11:01:05 -05:00
|
|
|
mnt.from = mnt.container
|
2014-08-28 10:18:08 -04:00
|
|
|
mnt.container = container
|
2014-10-23 08:50:06 -04:00
|
|
|
if err := mnt.initialize(); err != nil {
|
2014-08-28 10:18:08 -04:00
|
|
|
return err
|
|
|
|
}
|
2014-05-19 18:18:37 -04:00
|
|
|
}
|
2014-12-18 09:57:36 -05:00
|
|
|
container.AppliedVolumesFrom[id] = struct{}{}
|
2014-05-19 18:18:37 -04:00
|
|
|
}
|
2014-08-21 17:57:46 -04:00
|
|
|
return nil
|
2014-05-19 18:04:51 -04:00
|
|
|
}
|
2014-02-14 20:15:40 -05:00
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
func validMountMode(mode string) bool {
|
|
|
|
validModes := map[string]bool{
|
|
|
|
"rw": true,
|
|
|
|
"ro": true,
|
2014-05-19 18:04:51 -04:00
|
|
|
}
|
2014-06-02 17:16:30 -04:00
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
return validModes[mode]
|
2014-05-19 18:04:51 -04:00
|
|
|
}
|
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
func (container *Container) setupMounts() error {
|
2015-02-06 07:31:53 -05:00
|
|
|
mounts := []execdriver.Mount{}
|
|
|
|
|
|
|
|
// Mount user specified volumes
|
|
|
|
// Note, these are not private because you may want propagation of (un)mounts from host
|
|
|
|
// volumes. For instance if you use -v /usr:/usr and the host later mounts /usr/share you
|
|
|
|
// want this new mount in the container
|
|
|
|
// These mounts must be ordered based on the length of the path that it is being mounted to (lexicographic)
|
|
|
|
for _, path := range container.sortedVolumeMounts() {
|
|
|
|
mounts = append(mounts, execdriver.Mount{
|
|
|
|
Source: container.Volumes[path],
|
|
|
|
Destination: path,
|
|
|
|
Writable: container.VolumesRW[path],
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
if container.ResolvConfPath != "" {
|
|
|
|
mounts = append(mounts, execdriver.Mount{Source: container.ResolvConfPath, Destination: "/etc/resolv.conf", Writable: true, Private: true})
|
2014-05-19 18:04:51 -04:00
|
|
|
}
|
2014-04-24 21:22:22 -04:00
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
if container.HostnamePath != "" {
|
|
|
|
mounts = append(mounts, execdriver.Mount{Source: container.HostnamePath, Destination: "/etc/hostname", Writable: true, Private: true})
|
2014-05-19 18:04:51 -04:00
|
|
|
}
|
2014-04-24 21:22:22 -04:00
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
if container.HostsPath != "" {
|
2014-12-01 14:54:14 -05:00
|
|
|
mounts = append(mounts, execdriver.Mount{Source: container.HostsPath, Destination: "/etc/hosts", Writable: true, Private: true})
|
|
|
|
}
|
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
container.command.Mounts = mounts
|
2014-08-08 11:00:18 -04:00
|
|
|
return nil
|
|
|
|
}
|
2014-05-19 18:04:51 -04:00
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
func (container *Container) VolumeMounts() map[string]*Mount {
|
|
|
|
mounts := make(map[string]*Mount)
|
|
|
|
|
|
|
|
for mountToPath, path := range container.Volumes {
|
|
|
|
if v := container.daemon.volumes.Get(path); v != nil {
|
|
|
|
mounts[mountToPath] = &Mount{volume: v, container: container, MountToPath: mountToPath, Writable: container.VolumesRW[mountToPath]}
|
|
|
|
}
|
2014-05-19 18:18:37 -04:00
|
|
|
}
|
2014-08-08 11:00:18 -04:00
|
|
|
|
2014-08-28 10:18:08 -04:00
|
|
|
return mounts
|
2014-05-19 18:18:37 -04:00
|
|
|
}
|
|
|
|
|
2014-06-02 17:16:30 -04:00
|
|
|
func copyExistingContents(source, destination string) error {
|
|
|
|
volList, err := ioutil.ReadDir(source)
|
2014-05-19 18:18:37 -04:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(volList) > 0 {
|
2014-06-02 17:16:30 -04:00
|
|
|
srcList, err := ioutil.ReadDir(destination)
|
2014-05-19 18:04:51 -04:00
|
|
|
if err != nil {
|
2014-03-18 18:28:40 -04:00
|
|
|
return err
|
2014-02-14 20:15:40 -05:00
|
|
|
}
|
2014-05-19 18:18:37 -04:00
|
|
|
|
|
|
|
if len(srcList) == 0 {
|
|
|
|
// If the source volume is empty copy files from the root into the volume
|
2014-10-29 15:06:51 -04:00
|
|
|
if err := chrootarchive.CopyWithTar(source, destination); err != nil {
|
2014-02-14 20:15:40 -05:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
2014-05-19 18:18:37 -04:00
|
|
|
}
|
2014-03-18 18:28:40 -04:00
|
|
|
|
2014-06-02 17:16:30 -04:00
|
|
|
return copyOwnership(source, destination)
|
|
|
|
}
|
|
|
|
|
|
|
|
// copyOwnership copies the permissions and uid:gid of the source file
|
|
|
|
// into the destination file
|
|
|
|
func copyOwnership(source, destination string) error {
|
2015-03-11 11:42:49 -04:00
|
|
|
stat, err := system.Stat(source)
|
|
|
|
if err != nil {
|
2014-05-19 18:18:37 -04:00
|
|
|
return err
|
|
|
|
}
|
2014-06-02 17:16:30 -04:00
|
|
|
|
2015-03-11 11:42:49 -04:00
|
|
|
if err := os.Chown(destination, int(stat.Uid()), int(stat.Gid())); err != nil {
|
2014-05-19 18:18:37 -04:00
|
|
|
return err
|
|
|
|
}
|
2014-06-02 17:16:30 -04:00
|
|
|
|
2015-03-11 11:42:49 -04:00
|
|
|
return os.Chmod(destination, os.FileMode(stat.Mode()))
|
2014-03-18 18:28:40 -04:00
|
|
|
}
|