diff --git a/fs/fs.go b/fs/fs.go index fbf73a6..5e14eab 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -162,7 +162,7 @@ func (fs *Filesystem) bind(from string, to string, flags int, u *user.User) erro return bindMount(src, to, mntflags) } -func (fs *Filesystem) UnbindPath(to string) (error) { +func (fs *Filesystem) UnbindPath(to string) error { to = path.Join(fs.Root(), to) _, err := os.Stat(to) @@ -173,7 +173,7 @@ func (fs *Filesystem) UnbindPath(to string) (error) { // XXX fs.log.Info("unbinding %s", to) - if err := syscall.Unmount(to, syscall.MNT_DETACH/* | syscall.MNT_FORCE*/); err != nil { + if err := syscall.Unmount(to, syscall.MNT_DETACH /* | syscall.MNT_FORCE*/); err != nil { return err } diff --git a/fs/resolve.go b/fs/resolve.go index 3d628a7..e35ff19 100644 --- a/fs/resolve.go +++ b/fs/resolve.go @@ -2,12 +2,12 @@ package fs import ( "fmt" + "os" "os/exec" "os/user" "path" "path/filepath" "strings" - "os" ) func resolvePath(p string, u *user.User) ([]string, error) { diff --git a/network/daemon.go b/network/daemon.go index 9802103..074417f 100644 --- a/network/daemon.go +++ b/network/daemon.go @@ -13,9 +13,9 @@ import ( //Internal //External - "github.com/op/go-logging" "github.com/j-keck/arping" "github.com/milosgajdos83/tenus" + "github.com/op/go-logging" ) func BridgeInit(bridgeMAC string, nmIgnoreFile string, log *logging.Logger) (*HostNetwork, error) { @@ -100,13 +100,13 @@ func NetInit(stn *SandboxNetwork, htn *HostNetwork, childPid int, log *logging.L rand.Seed(time.Now().Unix() ^ int64((os.Getpid() + childPid))) log.Info("Configuring host veth pair '%s' with: %s", stn.VethHost, stn.Ip+"/"+htn.Class) -/* - // Fetch the bridge from the ifname - br, err := tenus.BridgeFromName(ozDefaultInterfaceBridge) - if err != nil { - return fmt.Errorf("Unable to attach to bridge interface %, %s.", ozDefaultInterfaceBridge, err) - } -*/ + /* + // Fetch the bridge from the ifname + br, err := tenus.BridgeFromName(ozDefaultInterfaceBridge) + if err != nil { + return fmt.Errorf("Unable to attach to bridge interface %, %s.", ozDefaultInterfaceBridge, err) + } + */ // Make sure the bridge is configured and the link is up // This really shouldn't be needed, but Network-Manager is a PITA // and even if you actualy ignore the interface there's a race diff --git a/network/network.go b/network/network.go index f5914bb..f85e03c 100644 --- a/network/network.go +++ b/network/network.go @@ -7,8 +7,8 @@ import ( "strconv" "strings" - "github.com/op/go-logging" "github.com/milosgajdos83/tenus" + "github.com/op/go-logging" ) const ( @@ -21,9 +21,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/oz-daemon/client.go b/oz-daemon/client.go index 393cc10..c029918 100644 --- a/oz-daemon/client.go +++ b/oz-daemon/client.go @@ -102,7 +102,7 @@ func KillSandbox(id int) error { } } -func MountFiles(files []string) (error) { +func MountFiles(files []string) error { resp, err := clientSend(&MountFilesMsg{Files: files}) if err != nil { return err @@ -117,7 +117,7 @@ func MountFiles(files []string) (error) { } } -func UnmountFile(file string) (error) { +func UnmountFile(file string) error { resp, err := clientSend(&UnmountFileMsg{File: file}) if err != nil { return err diff --git a/oz-daemon/daemon.go b/oz-daemon/daemon.go index 96a12ee..19542fd 100644 --- a/oz-daemon/daemon.go +++ b/oz-daemon/daemon.go @@ -281,7 +281,6 @@ func (d *daemonState) handleMountFiles(msg *MountFilesMsg, m *ipc.Message) error return m.Respond(&OkMsg{}) } - func (d *daemonState) handleUnmountFile(msg *UnmountFileMsg, m *ipc.Message) error { sbox := d.sandboxById(msg.Id) if sbox == nil { @@ -293,8 +292,6 @@ func (d *daemonState) handleUnmountFile(msg *UnmountFileMsg, m *ipc.Message) err return m.Respond(&OkMsg{}) } - - func (d *daemonState) sandboxById(id int) *Sandbox { for _, sb := range d.sandboxes { if sb.id == id { diff --git a/oz-daemon/launch.go b/oz-daemon/launch.go index fb7c81c..742d5ad 100644 --- a/oz-daemon/launch.go +++ b/oz-daemon/launch.go @@ -215,7 +215,7 @@ func (sbox *Sandbox) launchProgram(binpath, cpath, pwd string, args []string, lo } } -func (sbox *Sandbox) MountFiles(files []string, readonly bool, binpath string, log *logging.Logger) error { +func (sbox *Sandbox) MountFiles(files []string, readonly bool, binpath string, log *logging.Logger) error { pmnt := path.Join(binpath, "bin", "oz-mount") args := files if readonly { @@ -235,12 +235,12 @@ func (sbox *Sandbox) MountFiles(files []string, readonly bool, binpath string, for _, mfile := range files { found := false for _, mmfile := range sbox.mountedFiles { - if (mfile == mmfile) { + if mfile == mmfile { found = true - break; + break } } - if (!found) { + if !found { sbox.mountedFiles = append(sbox.mountedFiles, mfile) } } @@ -284,7 +284,7 @@ func (sbox *Sandbox) whitelistArgumentFiles(binpath, pwd string, args []string, } } if len(files) > 0 { - sbox.MountFiles(files, false, binpath, log); + sbox.MountFiles(files, false, binpath, log) } } diff --git a/oz-daemon/protocol.go b/oz-daemon/protocol.go index d76fd79..c60f505 100644 --- a/oz-daemon/protocol.go +++ b/oz-daemon/protocol.go @@ -64,13 +64,13 @@ type KillSandboxMsg struct { } type MountFilesMsg struct { - Id int "MountFiles" - Files []string + Id int "MountFiles" + Files []string ReadOnly bool } type UnmountFileMsg struct { - Id int "UnmountFile" + Id int "UnmountFile" File string } diff --git a/oz-init/init.go b/oz-init/init.go index e533241..d3b14a2 100644 --- a/oz-init/init.go +++ b/oz-init/init.go @@ -311,7 +311,7 @@ func (st *initState) launchApplication(cpath, pwd string, cmdArgs []string) (*ex if st.profile.Seccomp.Mode == oz.PROFILE_SECCOMP_WHITELIST { st.log.Notice("Enabling seccomp whitelist for: %s", cpath) - cmdArgs = append([]string{"-w",cpath}, cmdArgs...) + cmdArgs = append([]string{"-w", cpath}, cmdArgs...) cpath = path.Join(st.config.PrefixPath, "bin", "oz-seccomp") } cmd := exec.Command(cpath) diff --git a/oz-init/rootfs.go b/oz-init/rootfs.go index 18e84ba..b4822d6 100644 --- a/oz-init/rootfs.go +++ b/oz-init/rootfs.go @@ -107,7 +107,7 @@ func setupRootfs(fsys *fs.Filesystem, useFullDev bool) error { return err } - if (!useFullDev) { + if !useFullDev { for _, d := range basicDevices { if err := fsys.CreateDevice(d.path, d.dev, d.mode); err != nil { return err diff --git a/oz-mount/mount.go b/oz-mount/mount.go index bd6a666..fdac966 100644 --- a/oz-mount/mount.go +++ b/oz-mount/mount.go @@ -1,5 +1,6 @@ // +build linux,!gccgo package mount + // extern int enter_mount_namespace(void); /* #include @@ -45,13 +46,13 @@ func Main(mode int) { os.Exit(1) } fsys := fs.NewFilesystem(config, log) - homedir := os.Getenv("_OZ_HOMEDIR") + homedir := os.Getenv("_OZ_HOMEDIR") if homedir == "" { log.Error("Homedir must be set!") os.Exit(1) } os.Setenv("_OZ_HOMEDIR", "") - + start := 1 readonly := false if os.Args[1] == "--readonly" { @@ -60,7 +61,7 @@ func Main(mode int) { } for _, fpath := range os.Args[start:] { cpath, err := cleanPath(fpath, homedir) - if (err != nil || cpath == "") { + if err != nil || cpath == "" { log.Error("%v", err) os.Exit(1) } diff --git a/oz-seccomp/seccomp.go b/oz-seccomp/seccomp.go index f7b7a50..6cf3ae2 100644 --- a/oz-seccomp/seccomp.go +++ b/oz-seccomp/seccomp.go @@ -31,7 +31,7 @@ func Main() { log.Error("oz-seccomp wrapper must be called from oz-init!") os.Exit(1) } - + var getvar = func(name string) string { val := os.Getenv(name) if val == "" {