Пример #1
0
func (a *accessControl) assertHasDeleteAccessForRequest(request *http.Request) {
	if a.hasErr() {
		return
	}
	if !a.HasDeleteAccessForRequest(request) {
		var msg = fmt.Sprintf("Delete access denied on %s", request.URL)
		if a.hasErr() {
			msg = fmt.Sprintf("%s: %s", msg, a.err)
		}
		a.setErr(store.NewAccessDeniedError(msg))
	}
}
Пример #2
0
func (s *errStore) prependErr(prefix string) {
	if s.err != nil {
		var msg = fmt.Sprintf("%s: %s", prefix, s.err.Error())
		switch {
		case store.IsPathNotFoundError(s.err):
			s.err = store.NewPathNotFoundError(msg)
		case store.IsAccessDeniedError(s.err):
			s.err = store.NewAccessDeniedError(msg)
		default:
			s.err = fmt.Errorf(msg)
		}
	}
}
Пример #3
0
// assertPathValidForWriteAccess sets the error flag when the path may not be
// opened for writing by this process.
func (i *pathIO) assertPathValidForWriteAccess(p gopath.GoPath) {
	if i.hasErr() {
		return
	}
	if p.HasErr() {
		i.setErr(p.Err())
		return
	}

	if p.IsExists() {
		if !p.IsRegular() || !isPathWriteable(p) {
			i.setErr(store.NewAccessDeniedError(fmt.Sprintf(
				"path '%s' with mode %s denotes no regular file or no writeable directory",
				p.Path(), p.FileMode())))
		}
	} else {
		var d = p.Dir()
		if !isPathWriteable(d) {
			i.setErr(store.NewAccessDeniedError(
				"parent directory of '" + p.Path() + "' is not writeable"))
		}
	}
}