Exemplo n.º 1
0
func lddcmd(c *cli.Context) {
	for _, name := range c.Args() {
		fmt.Println(name, ":")
		libs, err := ldd.GetDynLibs(name)
		if err != nil {
			log.Println("\t", err)
		}
		if len(libs) == 0 {
			fmt.Println("\t", "not a dynamic executable")
			continue
		}
		for _, lib := range libs {
			fmt.Println("\t", lib)
		}
	}
}
Exemplo n.º 2
0
func MkJail(name string, paths []string) (err error) {
	for _, path := range paths {
		path, err = exec.LookPath(path)
		if err != nil {
			return
		}
		newpath := filepath.Join(name, path)
		err = os.MkdirAll(filepath.Dir(newpath), 0770)
		if err != nil {
			return fmt.Errorf("mkdir() failed: %s", err)
		}

		if _, err = os.Stat(newpath); os.IsNotExist(err) {
			err = osx.CopyFile(newpath, path)
			if err != nil {
				return
			}
			libs, err := ldd.GetDynLibs(path)
			if err != nil {
				return err
			}
			libs = append(libs, ldd.GetDynLoader())
			for _, lib := range libs {
				newpath = filepath.Join(name, lib)
				if _, err = os.Stat(newpath); os.IsNotExist(err) {
					err = os.MkdirAll(filepath.Dir(newpath), 0770)
					if err != nil {
						return fmt.Errorf("mkdir() failed: %s", err)
					}
					err = osx.CopyFile(newpath, lib)
					if err != nil {
						return err
					}
				}
			}
		}
	}
	return
}