mirror of git://gcc.gnu.org/git/gcc.git
re PR go/48503 (http/cgi FAILs if libgcc_s.so.1 isn't in default ld.so.1 search path)
PR go/48503 libgo: Bring over http/cgi environment inheritance patches. From-SVN: r172864
This commit is contained in:
parent
eb601ae15a
commit
90eadacd1e
|
|
@ -25,20 +25,30 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var trailingPort = regexp.MustCompile(`:([0-9]+)$`)
|
var trailingPort = regexp.MustCompile(`:([0-9]+)$`)
|
||||||
|
|
||||||
|
var osDefaultInheritEnv = map[string][]string{
|
||||||
|
"darwin": []string{"DYLD_LIBRARY_PATH"},
|
||||||
|
"freebsd": []string{"LD_LIBRARY_PATH"},
|
||||||
|
"hpux": []string{"LD_LIBRARY_PATH", "SHLIB_PATH"},
|
||||||
|
"linux": []string{"LD_LIBRARY_PATH"},
|
||||||
|
"windows": []string{"SystemRoot", "COMSPEC", "PATHEXT", "WINDIR"},
|
||||||
|
}
|
||||||
|
|
||||||
// Handler runs an executable in a subprocess with a CGI environment.
|
// Handler runs an executable in a subprocess with a CGI environment.
|
||||||
type Handler struct {
|
type Handler struct {
|
||||||
Path string // path to the CGI executable
|
Path string // path to the CGI executable
|
||||||
Root string // root URI prefix of handler or empty for "/"
|
Root string // root URI prefix of handler or empty for "/"
|
||||||
|
|
||||||
Env []string // extra environment variables to set, if any
|
Env []string // extra environment variables to set, if any, as "key=value"
|
||||||
Logger *log.Logger // optional log for errors or nil to use log.Print
|
InheritEnv []string // environment variables to inherit from host, as "key"
|
||||||
Args []string // optional arguments to pass to child process
|
Logger *log.Logger // optional log for errors or nil to use log.Print
|
||||||
|
Args []string // optional arguments to pass to child process
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||||
|
|
@ -110,6 +120,24 @@ func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||||
env = append(env, h.Env...)
|
env = append(env, h.Env...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path := os.Getenv("PATH")
|
||||||
|
if path == "" {
|
||||||
|
path = "/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin"
|
||||||
|
}
|
||||||
|
env = append(env, "PATH="+path)
|
||||||
|
|
||||||
|
for _, e := range h.InheritEnv {
|
||||||
|
if v := os.Getenv(e); v != "" {
|
||||||
|
env = append(env, e+"="+v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, e := range osDefaultInheritEnv[runtime.GOOS] {
|
||||||
|
if v := os.Getenv(e); v != "" {
|
||||||
|
env = append(env, e+"="+v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cwd, pathBase := filepath.Split(h.Path)
|
cwd, pathBase := filepath.Split(h.Path)
|
||||||
if cwd == "" {
|
if cwd == "" {
|
||||||
cwd = "."
|
cwd = "."
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue