xSmurf 9 years ago
parent 66725621e8
commit fd929aba6b

@ -162,7 +162,7 @@ func (fs *Filesystem) bind(from string, to string, flags int, u *user.User) erro
return bindMount(src, to, mntflags) 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) to = path.Join(fs.Root(), to)
_, err := os.Stat(to) _, err := os.Stat(to)

@ -2,12 +2,12 @@ package fs
import ( import (
"fmt" "fmt"
"os"
"os/exec" "os/exec"
"os/user" "os/user"
"path" "path"
"path/filepath" "path/filepath"
"strings" "strings"
"os"
) )
func resolvePath(p string, u *user.User) ([]string, error) { func resolvePath(p string, u *user.User) ([]string, error) {

@ -13,9 +13,9 @@ import (
//Internal //Internal
//External //External
"github.com/op/go-logging"
"github.com/j-keck/arping" "github.com/j-keck/arping"
"github.com/milosgajdos83/tenus" "github.com/milosgajdos83/tenus"
"github.com/op/go-logging"
) )
func BridgeInit(bridgeMAC string, nmIgnoreFile string, log *logging.Logger) (*HostNetwork, error) { func BridgeInit(bridgeMAC string, nmIgnoreFile string, log *logging.Logger) (*HostNetwork, error) {

@ -7,8 +7,8 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/op/go-logging"
"github.com/milosgajdos83/tenus" "github.com/milosgajdos83/tenus"
"github.com/op/go-logging"
) )
const ( const (

@ -146,7 +146,7 @@ func nsSocketListener(fd uintptr, proto ProtoType, lAddr string) (net.Listener,
/** /**
* Connect/Server * 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) rConn, err := socketConnect(pid, proto, rAddr)
if err != nil { if err != nil {
log.Error("Socket: %+v.", err) log.Error("Socket: %+v.", err)
@ -159,7 +159,7 @@ func proxyServerConn(pid int, conn *net.Conn, proto ProtoType, rAddr string, log
return nil 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 == "" { if dest == "" {
dest = "127.0.0.1" dest = "127.0.0.1"
} }

@ -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}) resp, err := clientSend(&MountFilesMsg{Files: files})
if err != nil { if err != nil {
return err 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}) resp, err := clientSend(&UnmountFileMsg{File: file})
if err != nil { if err != nil {
return err return err

@ -281,7 +281,6 @@ func (d *daemonState) handleMountFiles(msg *MountFilesMsg, m *ipc.Message) error
return m.Respond(&OkMsg{}) return m.Respond(&OkMsg{})
} }
func (d *daemonState) handleUnmountFile(msg *UnmountFileMsg, m *ipc.Message) error { func (d *daemonState) handleUnmountFile(msg *UnmountFileMsg, m *ipc.Message) error {
sbox := d.sandboxById(msg.Id) sbox := d.sandboxById(msg.Id)
if sbox == nil { if sbox == nil {
@ -293,8 +292,6 @@ func (d *daemonState) handleUnmountFile(msg *UnmountFileMsg, m *ipc.Message) err
return m.Respond(&OkMsg{}) return m.Respond(&OkMsg{})
} }
func (d *daemonState) sandboxById(id int) *Sandbox { func (d *daemonState) sandboxById(id int) *Sandbox {
for _, sb := range d.sandboxes { for _, sb := range d.sandboxes {
if sb.id == id { if sb.id == id {

@ -235,12 +235,12 @@ func (sbox *Sandbox) MountFiles(files []string, readonly bool, binpath string,
for _, mfile := range files { for _, mfile := range files {
found := false found := false
for _, mmfile := range sbox.mountedFiles { for _, mmfile := range sbox.mountedFiles {
if (mfile == mmfile) { if mfile == mmfile {
found = true found = true
break; break
} }
} }
if (!found) { if !found {
sbox.mountedFiles = append(sbox.mountedFiles, mfile) sbox.mountedFiles = append(sbox.mountedFiles, mfile)
} }
} }
@ -284,7 +284,7 @@ func (sbox *Sandbox) whitelistArgumentFiles(binpath, pwd string, args []string,
} }
} }
if len(files) > 0 { if len(files) > 0 {
sbox.MountFiles(files, false, binpath, log); sbox.MountFiles(files, false, binpath, log)
} }
} }

@ -107,7 +107,7 @@ func setupRootfs(fsys *fs.Filesystem, useFullDev bool) error {
return err return err
} }
if (!useFullDev) { if !useFullDev {
for _, d := range basicDevices { for _, d := range basicDevices {
if err := fsys.CreateDevice(d.path, d.dev, d.mode); err != nil { if err := fsys.CreateDevice(d.path, d.dev, d.mode); err != nil {
return err return err

@ -1,5 +1,6 @@
// +build linux,!gccgo // +build linux,!gccgo
package mount package mount
// extern int enter_mount_namespace(void); // extern int enter_mount_namespace(void);
/* /*
#include <stdlib.h> #include <stdlib.h>
@ -60,7 +61,7 @@ func Main(mode int) {
} }
for _, fpath := range os.Args[start:] { for _, fpath := range os.Args[start:] {
cpath, err := cleanPath(fpath, homedir) cpath, err := cleanPath(fpath, homedir)
if (err != nil || cpath == "") { if err != nil || cpath == "" {
log.Error("%v", err) log.Error("%v", err)
os.Exit(1) os.Exit(1)
} }

Loading…
Cancel
Save