This commit is contained in:
Julien Vehent 2015-09-09 12:37:29 -04:00
Родитель c0d285e344
Коммит f2456f57ce
7 изменённых файлов: 120 добавлений и 123 удалений

10
vendor/github.com/golang/sys/windows/registry/value.go сгенерированный поставляемый
Просмотреть файл

@ -108,7 +108,7 @@ func (k Key) GetStringValue(name string) (val string, valtype uint32, err error)
if len(data) == 0 {
return "", typ, nil
}
u := (*[1 << 10]uint16)(unsafe.Pointer(&data[0]))[:]
u := (*[1 << 29]uint16)(unsafe.Pointer(&data[0]))[:]
return syscall.UTF16ToString(u), typ, nil
}
@ -185,7 +185,7 @@ func ExpandString(value string) (string, error) {
return "", err
}
if n <= uint32(len(r)) {
u := (*[1 << 15]uint16)(unsafe.Pointer(&r[0]))[:]
u := (*[1 << 29]uint16)(unsafe.Pointer(&r[0]))[:]
return syscall.UTF16ToString(u), nil
}
r = make([]uint16, n)
@ -208,7 +208,7 @@ func (k Key) GetStringsValue(name string) (val []string, valtype uint32, err err
if len(data) == 0 {
return nil, typ, nil
}
p := (*[1 << 24]uint16)(unsafe.Pointer(&data[0]))[:len(data)/2]
p := (*[1 << 29]uint16)(unsafe.Pointer(&data[0]))[:len(data)/2]
if len(p) == 0 {
return nil, typ, nil
}
@ -296,7 +296,7 @@ func (k Key) setStringValue(name string, valtype uint32, value string) error {
if err != nil {
return err
}
buf := (*[1 << 10]byte)(unsafe.Pointer(&v[0]))[:len(v)*2]
buf := (*[1 << 29]byte)(unsafe.Pointer(&v[0]))[:len(v)*2]
return k.setValue(name, valtype, buf)
}
@ -326,7 +326,7 @@ func (k Key) SetStringsValue(name string, value []string) error {
ss += s + "\x00"
}
v := utf16.Encode([]rune(ss + "\x00"))
buf := (*[1 << 10]byte)(unsafe.Pointer(&v[0]))[:len(v)*2]
buf := (*[1 << 29]byte)(unsafe.Pointer(&v[0]))[:len(v)*2]
return k.setValue(name, MULTI_SZ, buf)
}

10
vendor/github.com/gorilla/mux/route.go сгенерированный поставляемый
Просмотреть файл

@ -200,15 +200,7 @@ func (m headerMatcher) Match(r *http.Request, match *RouteMatch) bool {
// "X-Requested-With", "XMLHttpRequest")
//
// The above route will only match if both request header values match.
// Alternatively, you can provide a regular expression and match the header as follows:
//
// r.Headers("Content-Type", "application/(text|json)",
// "X-Requested-With", "XMLHttpRequest")
//
// The above route will the same as the previous example, with the addition of matching
// application/text as well.
//
// It the value is an empty string, it will match any value if the key is set.
// If the value is an empty string, it will match any value if the key is set.
func (r *Route) Headers(pairs ...string) *Route {
if r.err == nil {
var headers map[string]string

34
vendor/github.com/jvehent/service-go/service_linux.go сгенерированный поставляемый
Просмотреть файл

@ -2,14 +2,16 @@ package service
import (
"fmt"
"github.com/kardianos/osext"
"io/ioutil"
"log/syslog"
"os"
"os/exec"
"os/signal"
"path/filepath"
"strings"
"text/template"
"github.com/kardianos/osext"
)
const (
@ -20,23 +22,29 @@ const (
// the default flavor is initSystemV. we lookup the command line of
// process 1 to detect systemd or upstart
func getFlavor() (flavor initFlavor, err error) {
func getFlavor() (initFlavor, error) {
initCmd, err := ioutil.ReadFile("/proc/1/cmdline")
if err != nil {
return
return initSystemV, err
}
init := fmt.Sprintf("%s", initCmd)
init := fmt.Sprintf("%s", initCmd[:len(initCmd)-1])
if strings.Contains(init, "init [") {
flavor = initSystemV
} else if strings.Contains(init, "systemd") {
flavor = initSystemd
} else if strings.Contains(init, "init") {
flavor = initUpstart
} else {
// failed to detect init system, falling back to sysvinit
flavor = initSystemV
return initSystemV, nil
}
return
if strings.Contains(init, "systemd") {
return initSystemd, nil
}
if strings.Contains(init, "init") {
// not so fast! you may think this is upstart, but it may be
// a symlink to systemd... yeah, debian does that... ( x )
target, err := filepath.EvalSymlinks(init)
if err == nil && strings.Contains(target, "systemd") {
return initSystemd, nil
}
return initUpstart, nil
}
// failed to detect init system, falling back to sysvinit
return initSystemV, nil
}
func newService(c *Config) (Service, error) {

130
vendor/golang.org/x/net/webdav/webdav.go сгенерированный поставляемый
Просмотреть файл

@ -13,6 +13,7 @@ import (
"net/http"
"net/url"
"os"
"path"
"runtime"
"strings"
"time"
@ -38,6 +39,8 @@ func init() {
}
type Handler struct {
// Prefix is the URL path prefix to strip from WebDAV resource paths.
Prefix string
// FileSystem is the virtual file system.
FileSystem FileSystem
// LockSystem is the lock management system.
@ -47,6 +50,16 @@ type Handler struct {
Logger func(*http.Request, error)
}
func (h *Handler) stripPrefix(p string) (string, int, error) {
if h.Prefix == "" {
return p, http.StatusOK, nil
}
if r := strings.TrimPrefix(p, h.Prefix); len(r) < len(p) {
return r, http.StatusOK, nil
}
return p, http.StatusNotFound, errPrefixMismatch
}
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
status, err := http.StatusBadRequest, errUnsupportedMethod
if h.FileSystem == nil {
@ -175,8 +188,12 @@ func (h *Handler) confirmLocks(r *http.Request, src, dst string) (release func()
}
func (h *Handler) handleOptions(w http.ResponseWriter, r *http.Request) (status int, err error) {
reqPath, status, err := h.stripPrefix(r.URL.Path)
if err != nil {
return status, err
}
allow := "OPTIONS, LOCK, PUT, MKCOL"
if fi, err := h.FileSystem.Stat(r.URL.Path); err == nil {
if fi, err := h.FileSystem.Stat(reqPath); err == nil {
if fi.IsDir() {
allow = "OPTIONS, LOCK, GET, HEAD, POST, DELETE, PROPPATCH, COPY, MOVE, UNLOCK, PROPFIND"
} else {
@ -192,8 +209,12 @@ func (h *Handler) handleOptions(w http.ResponseWriter, r *http.Request) (status
}
func (h *Handler) handleGetHeadPost(w http.ResponseWriter, r *http.Request) (status int, err error) {
reqPath, status, err := h.stripPrefix(r.URL.Path)
if err != nil {
return status, err
}
// TODO: check locks for read-only access??
f, err := h.FileSystem.OpenFile(r.URL.Path, os.O_RDONLY, 0)
f, err := h.FileSystem.OpenFile(reqPath, os.O_RDONLY, 0)
if err != nil {
return http.StatusNotFound, err
}
@ -203,19 +224,23 @@ func (h *Handler) handleGetHeadPost(w http.ResponseWriter, r *http.Request) (sta
return http.StatusNotFound, err
}
if !fi.IsDir() {
etag, err := findETag(h.FileSystem, h.LockSystem, r.URL.Path, fi)
etag, err := findETag(h.FileSystem, h.LockSystem, reqPath, fi)
if err != nil {
return http.StatusInternalServerError, err
}
w.Header().Set("ETag", etag)
}
// Let ServeContent determine the Content-Type header.
http.ServeContent(w, r, r.URL.Path, fi.ModTime(), f)
http.ServeContent(w, r, reqPath, fi.ModTime(), f)
return 0, nil
}
func (h *Handler) handleDelete(w http.ResponseWriter, r *http.Request) (status int, err error) {
release, status, err := h.confirmLocks(r, r.URL.Path, "")
reqPath, status, err := h.stripPrefix(r.URL.Path)
if err != nil {
return status, err
}
release, status, err := h.confirmLocks(r, reqPath, "")
if err != nil {
return status, err
}
@ -226,20 +251,24 @@ func (h *Handler) handleDelete(w http.ResponseWriter, r *http.Request) (status i
// "godoc os RemoveAll" says that "If the path does not exist, RemoveAll
// returns nil (no error)." WebDAV semantics are that it should return a
// "404 Not Found". We therefore have to Stat before we RemoveAll.
if _, err := h.FileSystem.Stat(r.URL.Path); err != nil {
if _, err := h.FileSystem.Stat(reqPath); err != nil {
if os.IsNotExist(err) {
return http.StatusNotFound, err
}
return http.StatusMethodNotAllowed, err
}
if err := h.FileSystem.RemoveAll(r.URL.Path); err != nil {
if err := h.FileSystem.RemoveAll(reqPath); err != nil {
return http.StatusMethodNotAllowed, err
}
return http.StatusNoContent, nil
}
func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request) (status int, err error) {
release, status, err := h.confirmLocks(r, r.URL.Path, "")
reqPath, status, err := h.stripPrefix(r.URL.Path)
if err != nil {
return status, err
}
release, status, err := h.confirmLocks(r, reqPath, "")
if err != nil {
return status, err
}
@ -247,7 +276,7 @@ func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request) (status int,
// TODO(rost): Support the If-Match, If-None-Match headers? See bradfitz'
// comments in http.checkEtag.
f, err := h.FileSystem.OpenFile(r.URL.Path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666)
f, err := h.FileSystem.OpenFile(reqPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
return http.StatusNotFound, err
}
@ -264,7 +293,7 @@ func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request) (status int,
if closeErr != nil {
return http.StatusMethodNotAllowed, closeErr
}
etag, err := findETag(h.FileSystem, h.LockSystem, r.URL.Path, fi)
etag, err := findETag(h.FileSystem, h.LockSystem, reqPath, fi)
if err != nil {
return http.StatusInternalServerError, err
}
@ -273,7 +302,11 @@ func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request) (status int,
}
func (h *Handler) handleMkcol(w http.ResponseWriter, r *http.Request) (status int, err error) {
release, status, err := h.confirmLocks(r, r.URL.Path, "")
reqPath, status, err := h.stripPrefix(r.URL.Path)
if err != nil {
return status, err
}
release, status, err := h.confirmLocks(r, reqPath, "")
if err != nil {
return status, err
}
@ -282,7 +315,7 @@ func (h *Handler) handleMkcol(w http.ResponseWriter, r *http.Request) (status in
if r.ContentLength > 0 {
return http.StatusUnsupportedMediaType, nil
}
if err := h.FileSystem.Mkdir(r.URL.Path, 0777); err != nil {
if err := h.FileSystem.Mkdir(reqPath, 0777); err != nil {
if os.IsNotExist(err) {
return http.StatusConflict, err
}
@ -304,7 +337,16 @@ func (h *Handler) handleCopyMove(w http.ResponseWriter, r *http.Request) (status
return http.StatusBadGateway, errInvalidDestination
}
dst, src := u.Path, r.URL.Path
src, status, err := h.stripPrefix(r.URL.Path)
if err != nil {
return status, err
}
dst, status, err := h.stripPrefix(u.Path)
if err != nil {
return status, err
}
if dst == "" {
return http.StatusBadGateway, errInvalidDestination
}
@ -398,8 +440,12 @@ func (h *Handler) handleLock(w http.ResponseWriter, r *http.Request) (retStatus
return http.StatusBadRequest, errInvalidDepth
}
}
reqPath, status, err := h.stripPrefix(r.URL.Path)
if err != nil {
return status, err
}
ld = LockDetails{
Root: r.URL.Path,
Root: reqPath,
Duration: duration,
OwnerXML: li.Owner.InnerXML,
ZeroDepth: depth == 0,
@ -418,8 +464,8 @@ func (h *Handler) handleLock(w http.ResponseWriter, r *http.Request) (retStatus
}()
// Create the resource if it didn't previously exist.
if _, err := h.FileSystem.Stat(r.URL.Path); err != nil {
f, err := h.FileSystem.OpenFile(r.URL.Path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666)
if _, err := h.FileSystem.Stat(reqPath); err != nil {
f, err := h.FileSystem.OpenFile(reqPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666)
if err != nil {
// TODO: detect missing intermediate dirs and return http.StatusConflict?
return http.StatusInternalServerError, err
@ -468,7 +514,11 @@ func (h *Handler) handleUnlock(w http.ResponseWriter, r *http.Request) (status i
}
func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) (status int, err error) {
fi, err := h.FileSystem.Stat(r.URL.Path)
reqPath, status, err := h.stripPrefix(r.URL.Path)
if err != nil {
return status, err
}
fi, err := h.FileSystem.Stat(reqPath)
if err != nil {
if os.IsNotExist(err) {
return http.StatusNotFound, err
@ -489,13 +539,13 @@ func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) (status
mw := multistatusWriter{w: w}
walkFn := func(path string, info os.FileInfo, err error) error {
walkFn := func(reqPath string, info os.FileInfo, err error) error {
if err != nil {
return err
}
var pstats []Propstat
if pf.Propname != nil {
pnames, err := propnames(h.FileSystem, h.LockSystem, path)
pnames, err := propnames(h.FileSystem, h.LockSystem, reqPath)
if err != nil {
return err
}
@ -505,17 +555,17 @@ func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) (status
}
pstats = append(pstats, pstat)
} else if pf.Allprop != nil {
pstats, err = allprop(h.FileSystem, h.LockSystem, path, pf.Prop)
pstats, err = allprop(h.FileSystem, h.LockSystem, reqPath, pf.Prop)
} else {
pstats, err = props(h.FileSystem, h.LockSystem, path, pf.Prop)
pstats, err = props(h.FileSystem, h.LockSystem, reqPath, pf.Prop)
}
if err != nil {
return err
}
return mw.write(makePropstatResponse(path, pstats))
return mw.write(makePropstatResponse(path.Join(h.Prefix, reqPath), pstats))
}
walkErr := walkFS(h.FileSystem, depth, r.URL.Path, fi, walkFn)
walkErr := walkFS(h.FileSystem, depth, reqPath, fi, walkFn)
closeErr := mw.close()
if walkErr != nil {
return http.StatusInternalServerError, walkErr
@ -527,13 +577,17 @@ func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) (status
}
func (h *Handler) handleProppatch(w http.ResponseWriter, r *http.Request) (status int, err error) {
release, status, err := h.confirmLocks(r, r.URL.Path, "")
reqPath, status, err := h.stripPrefix(r.URL.Path)
if err != nil {
return status, err
}
release, status, err := h.confirmLocks(r, reqPath, "")
if err != nil {
return status, err
}
defer release()
if _, err := h.FileSystem.Stat(r.URL.Path); err != nil {
if _, err := h.FileSystem.Stat(reqPath); err != nil {
if os.IsNotExist(err) {
return http.StatusNotFound, err
}
@ -543,7 +597,7 @@ func (h *Handler) handleProppatch(w http.ResponseWriter, r *http.Request) (statu
if err != nil {
return status, err
}
pstats, err := patch(h.FileSystem, h.LockSystem, r.URL.Path, patches)
pstats, err := patch(h.FileSystem, h.LockSystem, reqPath, patches)
if err != nil {
return http.StatusInternalServerError, err
}
@ -605,29 +659,6 @@ func parseDepth(s string) int {
return invalidDepth
}
// StripPrefix is like http.StripPrefix but it also strips the prefix from any
// Destination headers, so that COPY and MOVE requests also see stripped paths.
func StripPrefix(prefix string, h http.Handler) http.Handler {
if prefix == "" {
return h
}
h = http.StripPrefix(prefix, h)
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
dsts := r.Header["Destination"]
for i, dst := range dsts {
u, err := url.Parse(dst)
if err != nil {
continue
}
if p := strings.TrimPrefix(u.Path, prefix); len(p) < len(u.Path) {
u.Path = p
dsts[i] = u.String()
}
}
h.ServeHTTP(w, r)
})
}
// http://www.webdav.org/specs/rfc4918.html#status.code.extensions.to.http11
const (
StatusMulti = 207
@ -668,6 +699,7 @@ var (
errNoFileSystem = errors.New("webdav: no file system")
errNoLockSystem = errors.New("webdav: no lock system")
errNotADirectory = errors.New("webdav: not a directory")
errPrefixMismatch = errors.New("webdav: prefix mismatch")
errRecursionTooDeep = errors.New("webdav: recursion too deep")
errUnsupportedLockInfo = errors.New("webdav: unsupported lock info")
errUnsupportedMethod = errors.New("webdav: unsupported method")

16
vendor/golang.org/x/net/webdav/webdav_test.go сгенерированный поставляемый
Просмотреть файл

@ -15,13 +15,8 @@ import (
"testing"
)
// TestStripPrefix tests the StripPrefix function. We can't test the
// StripPrefix function with the litmus test, even though all of the litmus
// test paths start with "/litmus/", because one of the first things that the
// litmus test does is "MKCOL /litmus/". That request succeeds without a
// StripPrefix, but fails with a StripPrefix because you cannot MKCOL the root
// directory of a FileSystem.
func TestStripPrefix(t *testing.T) {
// TODO: add tests to check XML responses with the expected prefix path
func TestPrefix(t *testing.T) {
const dst, blah = "Destination", "blah blah blah"
do := func(method, urlStr string, body io.Reader, wantStatusCode int, headers ...string) error {
@ -52,14 +47,13 @@ func TestStripPrefix(t *testing.T) {
}
for _, prefix := range prefixes {
fs := NewMemFS()
h := http.Handler(&Handler{
h := &Handler{
FileSystem: fs,
LockSystem: NewMemLS(),
})
}
mux := http.NewServeMux()
if prefix != "/" {
// Note that this is webdav.StripPrefix, not http.StripPrefix.
h = StripPrefix(prefix, h)
h.Prefix = prefix
}
mux.Handle(prefix, h)
srv := httptest.NewServer(mux)

10
vendor/golang.org/x/sys/windows/registry/value.go сгенерированный поставляемый
Просмотреть файл

@ -108,7 +108,7 @@ func (k Key) GetStringValue(name string) (val string, valtype uint32, err error)
if len(data) == 0 {
return "", typ, nil
}
u := (*[1 << 10]uint16)(unsafe.Pointer(&data[0]))[:]
u := (*[1 << 29]uint16)(unsafe.Pointer(&data[0]))[:]
return syscall.UTF16ToString(u), typ, nil
}
@ -185,7 +185,7 @@ func ExpandString(value string) (string, error) {
return "", err
}
if n <= uint32(len(r)) {
u := (*[1 << 15]uint16)(unsafe.Pointer(&r[0]))[:]
u := (*[1 << 29]uint16)(unsafe.Pointer(&r[0]))[:]
return syscall.UTF16ToString(u), nil
}
r = make([]uint16, n)
@ -208,7 +208,7 @@ func (k Key) GetStringsValue(name string) (val []string, valtype uint32, err err
if len(data) == 0 {
return nil, typ, nil
}
p := (*[1 << 24]uint16)(unsafe.Pointer(&data[0]))[:len(data)/2]
p := (*[1 << 29]uint16)(unsafe.Pointer(&data[0]))[:len(data)/2]
if len(p) == 0 {
return nil, typ, nil
}
@ -296,7 +296,7 @@ func (k Key) setStringValue(name string, valtype uint32, value string) error {
if err != nil {
return err
}
buf := (*[1 << 10]byte)(unsafe.Pointer(&v[0]))[:len(v)*2]
buf := (*[1 << 29]byte)(unsafe.Pointer(&v[0]))[:len(v)*2]
return k.setValue(name, valtype, buf)
}
@ -326,7 +326,7 @@ func (k Key) SetStringsValue(name string, value []string) error {
ss += s + "\x00"
}
v := utf16.Encode([]rune(ss + "\x00"))
buf := (*[1 << 10]byte)(unsafe.Pointer(&v[0]))[:len(v)*2]
buf := (*[1 << 29]byte)(unsafe.Pointer(&v[0]))[:len(v)*2]
return k.setValue(name, MULTI_SZ, buf)
}

33
vendor/gopkg.in/gcfg.v1/LICENSE сгенерированный поставляемый
Просмотреть файл

@ -1,34 +1,5 @@
Copyright (c) 2012 Péter Surányi. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
Portions of gcfg's source code have been derived from Go, and are
covered by the following license:
----------------------------------------------------------------------
Copyright (c) 2009 The Go Authors. All rights reserved.
Copyright (c) 2012 Péter Surányi. Portions Copyright (c) 2009 The Go
Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are