| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -13,6 +13,7 @@ __attribute__((constructor)) void init(void) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import "C"
 | 
					 | 
					 | 
					 | 
					import "C"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import (
 | 
					 | 
					 | 
					 | 
					import (
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						"fmt"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						"os"
 | 
					 | 
					 | 
					 | 
						"os"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						"path"
 | 
					 | 
					 | 
					 | 
						"path"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						"strings"
 | 
					 | 
					 | 
					 | 
						"strings"
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -32,7 +33,7 @@ func Main(mode int) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						log := createLogger()
 | 
					 | 
					 | 
					 | 
						log := createLogger()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						config, err := loadConfig()
 | 
					 | 
					 | 
					 | 
						config, err := loadConfig()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						if err != nil {
 | 
					 | 
					 | 
					 | 
						if err != nil {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							log.Error("Could not load configuration: %s (%+v)\n", oz.DefaultConfigPath, err)
 | 
					 | 
					 | 
					 | 
							log.Error("Could not load configuration: %s (%+v)", oz.DefaultConfigPath, err)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							os.Exit(1)
 | 
					 | 
					 | 
					 | 
							os.Exit(1)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						}
 | 
					 | 
					 | 
					 | 
						}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						
 | 
					 | 
					 | 
					 | 
						
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -50,16 +51,16 @@ func Main(mode int) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							readonly = true
 | 
					 | 
					 | 
					 | 
							readonly = true
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						}
 | 
					 | 
					 | 
					 | 
						}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						for _, fpath := range os.Args[start:] {
 | 
					 | 
					 | 
					 | 
						for _, fpath := range os.Args[start:] {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							fpath = path.Clean(fpath);
 | 
					 | 
					 | 
					 | 
							cpath, err := cleanPath(fpath, homedir)
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if !strings.HasPrefix(fpath, homedir) {
 | 
					 | 
					 | 
					 | 
							if (err != nil || cpath == "") {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								log.Warning("Ignored `%s`, only files inside of home are permitted!", fpath)
 | 
					 | 
					 | 
					 | 
								log.Error("%v", err)
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								continue
 | 
					 | 
					 | 
					 | 
								os.Exit(1)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							}
 | 
					 | 
					 | 
					 | 
							}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							switch mode {
 | 
					 | 
					 | 
					 | 
							switch mode {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							case MOUNT:
 | 
					 | 
					 | 
					 | 
							case MOUNT:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								mount(fpath, readonly, fsys, log)
 | 
					 | 
					 | 
					 | 
								mount(cpath, readonly, fsys, log)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							case UMOUNT:
 | 
					 | 
					 | 
					 | 
							case UMOUNT:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								unmount(fpath, fsys, log)
 | 
					 | 
					 | 
					 | 
								unmount(cpath, fsys, log)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							default:
 | 
					 | 
					 | 
					 | 
							default:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								log.Error("Unknown mode!")
 | 
					 | 
					 | 
					 | 
								log.Error("Unknown mode!")
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								os.Exit(1)
 | 
					 | 
					 | 
					 | 
								os.Exit(1)
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -69,17 +70,30 @@ func Main(mode int) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						os.Exit(0)
 | 
					 | 
					 | 
					 | 
						os.Exit(0)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					func cleanPath(spath, homedir string) (string, error) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						spath = path.Clean(spath)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						if !path.IsAbs(spath) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							spath = path.Join(homedir, spath)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						if !strings.HasPrefix(spath, homedir) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							return "", fmt.Errorf("only files inside of the user home are permitted")
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						return spath, nil
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					func mount(fpath string, readonly bool, fsys *fs.Filesystem, log *logging.Logger) {
 | 
					 | 
					 | 
					 | 
					func mount(fpath string, readonly bool, fsys *fs.Filesystem, log *logging.Logger) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						if _, err := os.Stat(fpath); err == nil {
 | 
					 | 
					 | 
					 | 
						//log.Notice("Adding file `%s`.", fpath)
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							//log.Notice("Adding file `%s`.", fpath)
 | 
					 | 
					 | 
					 | 
						if _, err := os.Stat(fpath); err != nil {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							flags := fs.BindCanCreate
 | 
					 | 
					 | 
					 | 
							log.Error("%v", err)
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if readonly {
 | 
					 | 
					 | 
					 | 
							os.Exit(1)
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								flags |= fs.BindReadOnly
 | 
					 | 
					 | 
					 | 
						}
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							}
 | 
					 | 
					 | 
					 | 
						flags := fs.BindCanCreate
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if err := fsys.BindPath(fpath, flags, nil); err != nil {
 | 
					 | 
					 | 
					 | 
						if readonly {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								log.Error("%v while adding `%s`!", err, fpath)
 | 
					 | 
					 | 
					 | 
							flags |= fs.BindReadOnly
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								os.Exit(1)
 | 
					 | 
					 | 
					 | 
						}
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							}
 | 
					 | 
					 | 
					 | 
						if err := fsys.BindPath(fpath, flags, nil); err != nil {
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							log.Error("%v", err)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
							os.Exit(1)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						}
 | 
					 | 
					 | 
					 | 
						}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -88,17 +102,17 @@ func unmount(fpath string, fsys *fs.Filesystem, log *logging.Logger) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						if _, err := os.Stat(sbpath); err == nil {
 | 
					 | 
					 | 
					 | 
						if _, err := os.Stat(sbpath); err == nil {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							//log.Notice("Removing file `%s`.", fpath)
 | 
					 | 
					 | 
					 | 
							//log.Notice("Removing file `%s`.", fpath)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							if err := fsys.UnbindPath(fpath); err != nil {
 | 
					 | 
					 | 
					 | 
							if err := fsys.UnbindPath(fpath); err != nil {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								log.Error("%v while removing `%s`!", err, fpath)
 | 
					 | 
					 | 
					 | 
								log.Error("%v", err)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								os.Exit(1)
 | 
					 | 
					 | 
					 | 
								os.Exit(1)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							}
 | 
					 | 
					 | 
					 | 
							}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} else {
 | 
					 | 
					 | 
					 | 
						} else {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							log.Error("%v error while removing `%s`!", err, fpath)
 | 
					 | 
					 | 
					 | 
							log.Warning("%v", err)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						}
 | 
					 | 
					 | 
					 | 
						}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					}
 | 
					 | 
					 | 
					 | 
					}
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					func createLogger() *logging.Logger {
 | 
					 | 
					 | 
					 | 
					func createLogger() *logging.Logger {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						l := logging.MustGetLogger("oz-init")
 | 
					 | 
					 | 
					 | 
						l := logging.MustGetLogger("oz-init")
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						be := logging.NewLogBackend(os.Stderr, "", 0)
 | 
					 | 
					 | 
					 | 
						be := logging.NewLogBackend(os.Stdout, "", 0)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						f := logging.MustStringFormatter("%{level:.1s} %{message}")
 | 
					 | 
					 | 
					 | 
						f := logging.MustStringFormatter("%{level:.1s} %{message}")
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						fbe := logging.NewBackendFormatter(be, f)
 | 
					 | 
					 | 
					 | 
						fbe := logging.NewBackendFormatter(be, f)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						logging.SetBackend(fbe)
 | 
					 | 
					 | 
					 | 
						logging.SetBackend(fbe)
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
 
 |