From f23045350f8abc1320a5288bc5b19f363edb11f4 Mon Sep 17 00:00:00 2001 From: brl Date: Thu, 25 Jun 2015 13:05:35 -0400 Subject: [PATCH] gofmt --- config.go | 30 +++++++++++++++--------------- network/network.go | 6 +++--- network/proxy.go | 14 +++++++------- ns/linux_x86_64.go | 6 ++---- ns/ns.go | 8 ++++---- profile.go | 2 +- 6 files changed, 32 insertions(+), 34 deletions(-) diff --git a/config.go b/config.go index 0c3ec88..024d8a4 100644 --- a/config.go +++ b/config.go @@ -24,22 +24,22 @@ type Config struct { EnvironmentVars []string `json:"environment_vars" desc:"Default environment variables passed to sandboxes"` } -const OzVersion = "0.0.1" +const OzVersion = "0.0.1" const DefaultConfigPath = "/etc/oz/oz.conf" func NewDefaultConfig() *Config { return &Config{ - ProfileDir: "/var/lib/oz/cells.d", - ShellPath: "/bin/bash", - InitPath: "/usr/local/bin/oz-init", - ClientPath: "/usr/local/bin/oz", - SandboxPath: "/srv/oz", - NMIgnoreFile: "/etc/NetworkManager/conf.d/oz.conf", - BridgeMACAddr: "6A:A8:2E:56:E8:9C", - DivertSuffix: "unsafe", - UseFullDev: false, - AllowRootShell: false, - LogXpra: false, + ProfileDir: "/var/lib/oz/cells.d", + ShellPath: "/bin/bash", + InitPath: "/usr/local/bin/oz-init", + ClientPath: "/usr/local/bin/oz", + SandboxPath: "/srv/oz", + NMIgnoreFile: "/etc/NetworkManager/conf.d/oz.conf", + BridgeMACAddr: "6A:A8:2E:56:E8:9C", + DivertSuffix: "unsafe", + UseFullDev: false, + AllowRootShell: false, + LogXpra: false, EnvironmentVars: []string{ "USER", "USERNAME", "LOGNAME", "LANG", "LANGUAGE", "_", @@ -49,12 +49,12 @@ func NewDefaultConfig() *Config { func LoadConfig(cpath string) (*Config, error) { if _, err := os.Stat(cpath); os.IsNotExist(err) { - return nil,err + return nil, err } if err := checkConfigPermissions(cpath); err != nil { return nil, err } - + bs, err := ioutil.ReadFile(cpath) if err != nil { return nil, err @@ -84,7 +84,7 @@ func checkPathRootPermissions(fpath string) error { if (fstat.Mode().Perm() & syscall.S_IWOTH) != 0 { return fmt.Errorf("writable by everyone!", fpath) } - if (fstat.Mode().Perm() & syscall.S_IWGRP) != 0 && fstat.Sys().(*syscall.Stat_t).Gid != 0 { + if (fstat.Mode().Perm()&syscall.S_IWGRP) != 0 && fstat.Sys().(*syscall.Stat_t).Gid != 0 { return fmt.Errorf("writable by someone else than root!", err) } return nil diff --git a/network/network.go b/network/network.go index 1c3bdc4..63e47bc 100644 --- a/network/network.go +++ b/network/network.go @@ -20,9 +20,9 @@ const ( type NetType string -const( - TYPE_HOST NetType = "host" - TYPE_EMPTY NetType = "empty" +const ( + TYPE_HOST NetType = "host" + TYPE_EMPTY NetType = "empty" TYPE_BRIDGE NetType = "bridge" ) diff --git a/network/proxy.go b/network/proxy.go index 77fa55f..799482c 100644 --- a/network/proxy.go +++ b/network/proxy.go @@ -1,6 +1,6 @@ package network -import( +import ( //Builtin "fmt" "io" @@ -16,16 +16,16 @@ import( type ProxyType string -const( +const ( PROXY_CLIENT ProxyType = "client" PROXY_SERVER ProxyType = "server" ) type ProtoType string -const( - PROTO_TCP ProtoType = "tcp" - PROTO_UDP ProtoType = "udp" +const ( + PROTO_TCP ProtoType = "tcp" + PROTO_UDP ProtoType = "udp" PROTO_SOCKET ProtoType = "socket" ) @@ -146,7 +146,7 @@ func nsSocketListener(fd uintptr, proto ProtoType, lAddr string) (net.Listener, /** * Connect/Server **/ -func proxyServerConn(pid int, conn *net.Conn, proto ProtoType, rAddr string, log *logging.Logger, ready sync.WaitGroup) (error) { +func proxyServerConn(pid int, conn *net.Conn, proto ProtoType, rAddr string, log *logging.Logger, ready sync.WaitGroup) error { rConn, err := socketConnect(pid, proto, rAddr) if err != nil { log.Error("Socket: %+v.", err) @@ -159,7 +159,7 @@ func proxyServerConn(pid int, conn *net.Conn, proto ProtoType, rAddr string, log return nil } -func newProxyServer(pid int, proto ProtoType, dest string, port int, log *logging.Logger, ready sync.WaitGroup) (error) { +func newProxyServer(pid int, proto ProtoType, dest string, port int, log *logging.Logger, ready sync.WaitGroup) error { if dest == "" { dest = "127.0.0.1" } diff --git a/ns/linux_x86_64.go b/ns/linux_x86_64.go index 2b73689..a0abf58 100644 --- a/ns/linux_x86_64.go +++ b/ns/linux_x86_64.go @@ -1,9 +1,7 @@ package ns -import ( - -) +import () const ( - SYS_SETNS = 308 + SYS_SETNS = 308 ) diff --git a/ns/ns.go b/ns/ns.go index e515330..2c9965e 100644 --- a/ns/ns.go +++ b/ns/ns.go @@ -1,11 +1,11 @@ package ns -import( - "syscall" +import ( "errors" "os" "path" "strconv" + "syscall" ) type Namespace struct { @@ -37,7 +37,7 @@ func init() { } } -func Set(fd, nsType uintptr) (error) { +func Set(fd, nsType uintptr) error { _, _, err := syscall.Syscall(SYS_SETNS, uintptr(fd), uintptr(nsType), 0) if err != 0 { return errors.New("Unable to set namespace") @@ -81,6 +81,6 @@ func Open(nsPath string) (uintptr, error) { return fd.Fd(), nil } -func Close(fd uintptr) (error) { +func Close(fd uintptr) error { return syscall.Close(int(fd)) } diff --git a/profile.go b/profile.go index 2ab5a91..855ce58 100644 --- a/profile.go +++ b/profile.go @@ -92,7 +92,7 @@ func NewDefaultProfile() *Profile { return &Profile{ Multi: false, AllowFiles: false, - XServer: XServerConf{ + XServer: XServerConf{ Enabled: true, EnableTray: false, UseDBUS: false,