Example #1
0
func (r *Remote) DirPerms(dir string, mode os.FileMode) (bool, error) {
	resp, err := r.RunCmd("ls -ld %s | awk '{printf $1}'", r.path(dir))
	if err != nil {
		return false, err
	}

	fmt.Println(resp, []byte(mode.String()), string(resp), mode.String())

	if string(resp) == mode.String()+"\n" {
		return true, nil
	}

	return false, nil
}
Example #2
0
File: perm.go Project: goftp/ftpd
func hasPerm(mode os.FileMode, idx int, rOrW string) bool {
	return string(mode.String()[idx]) == rOrW
}
Example #3
0
func (s *IntegrationTestSuite) assertFilePresent(c *chk.C, path string, perm os.FileMode, readableByNobodyUser bool) {
	info, err := os.Stat(path)
	c.Assert(err, chk.IsNil)
	if (info.Mode() & os.ModeSymlink) != 0 {
		linkedFile, err := os.Readlink(path)
		c.Assert(err, chk.IsNil)
		s.assertFilePresent(c, linkedFile, perm, readableByNobodyUser)
	} else {
		if info.Mode().Perm() != perm {
			c.Errorf("File %s has permission \"%s\" but expected \"%s\"", path, info.Mode().String(), perm.String())
		}
	}

	if readableByNobodyUser {
		for i := path; i != "/"; i = filepath.Dir(i) {
			info, err = os.Stat(i)
			c.Assert(err, chk.IsNil)
			c.Assert(info.Mode().Perm()&0005, chk.Not(chk.Equals), 0)
		}
	}
}