[lxc-devel] [lxd/master] tree-wide: replace file Chmod() with os.Chmod()

brauner on Github lxc-bot at linuxcontainers.org
Wed May 3 13:15:44 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 616 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170503/5345a703/attachment.bin>
-------------- next part --------------
From 60eb9ddcb7896e6279f34d07da9055002a5310ec Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 3 May 2017 15:12:02 +0200
Subject: [PATCH] tree-wide: replace file Chmod() with os.Chmod()

The file chmod that go uses calls out to syscall.Fchmod() which is not
implemented for Windows. The os.Chmod() method call out to syscall.Chmod()
which seems to be implemented on all platforms if I read the go sources
correctly.

Closes #3275.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 client.go      | 2 +-
 lxc/file.go    | 2 +-
 shared/util.go | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/client.go b/client.go
index 6a28d06..c665294 100644
--- a/client.go
+++ b/client.go
@@ -1974,7 +1974,7 @@ func (c *Client) RecursivePullFile(container string, p string, targetDir string)
 		}
 		defer f.Close()
 
-		err = f.Chmod(os.FileMode(mode))
+		err = os.Chmod(target, os.FileMode(mode))
 		if err != nil {
 			return err
 		}
diff --git a/lxc/file.go b/lxc/file.go
index 679c00e..67ecbaf 100644
--- a/lxc/file.go
+++ b/lxc/file.go
@@ -331,7 +331,7 @@ func (c *fileCmd) pull(config *lxd.Config, args []string) error {
 			}
 			defer f.Close()
 
-			err = f.Chmod(os.FileMode(mode))
+			err = os.Chmod(targetPath, os.FileMode(mode))
 			if err != nil {
 				return err
 			}
diff --git a/shared/util.go b/shared/util.go
index ff6a576..43cba25 100644
--- a/shared/util.go
+++ b/shared/util.go
@@ -561,7 +561,8 @@ func TextEditor(inPath string, inContent []byte) ([]byte, error) {
 			return []byte{}, err
 		}
 
-		if err = f.Chmod(0600); err != nil {
+		err = os.Chmod(f.Name(), 0600)
+		if err != nil {
 			f.Close()
 			os.Remove(f.Name())
 			return []byte{}, err


More information about the lxc-devel mailing list