* libgo patch committed: Inherit environment in http/cgi
@ 2011-04-22 18:59 Ian Lance Taylor
2011-04-29 12:53 ` Rainer Orth
0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 2011-04-22 18:59 UTC (permalink / raw)
To: gcc-patches, gofrontend-dev
[-- Attachment #1: Type: text/plain, Size: 230 bytes --]
This libgo patch brings over a patch to the master Go library to inherit
environment variables in http/cgi. This should fix PR go/48503.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.
Ian
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 1954 bytes --]
diff -r 9457f9a2e900 libgo/go/http/cgi/host.go
--- a/libgo/go/http/cgi/host.go Thu Apr 21 15:51:28 2011 -0700
+++ b/libgo/go/http/cgi/host.go Fri Apr 22 11:12:38 2011 -0700
@@ -25,20 +25,30 @@
"os"
"path/filepath"
"regexp"
+ "runtime"
"strconv"
"strings"
)
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.
type Handler struct {
Path string // path to the CGI executable
Root string // root URI prefix of handler or empty for "/"
- Env []string // extra environment variables to set, if any
- Logger *log.Logger // optional log for errors or nil to use log.Print
- Args []string // optional arguments to pass to child process
+ Env []string // extra environment variables to set, if any, as "key=value"
+ InheritEnv []string // environment variables to inherit from host, as "key"
+ 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) {
@@ -110,6 +120,24 @@
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)
if cwd == "" {
cwd = "."
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: libgo patch committed: Inherit environment in http/cgi
2011-04-22 18:59 libgo patch committed: Inherit environment in http/cgi Ian Lance Taylor
@ 2011-04-29 12:53 ` Rainer Orth
2011-04-29 18:58 ` Ian Lance Taylor
0 siblings, 1 reply; 3+ messages in thread
From: Rainer Orth @ 2011-04-29 12:53 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: gcc-patches, gofrontend-dev
Ian,
> This libgo patch brings over a patch to the master Go library to inherit
> environment variables in http/cgi. This should fix PR go/48503.
not really :-) It needs the following supplement to handle Solaris and
IRIX. I'm not only including LD_LIBRARY_PATH (although this would suffice
for the testcase to pass), but also the ABI variants thereof.
Bootstrapped without regressions on i386-pc-solaris2.11 and
sparc-sun-solaris2.11. Not yet tested on mips-sgi-irix6.5, but seems
pretty obvious.
Rainer
2011-04-26 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR go/48503
* go/http/cgi/host.go (osDefaultInheritEnv): Pass LD_LIBRARY_PATH
and ABI variants on irix and solaris.
diff --git a/libgo/go/http/cgi/host.go b/libgo/go/http/cgi/host.go
--- a/libgo/go/http/cgi/host.go
+++ b/libgo/go/http/cgi/host.go
@@ -36,7 +36,9 @@ var osDefaultInheritEnv = map[string][]s
"darwin": []string{"DYLD_LIBRARY_PATH"},
"freebsd": []string{"LD_LIBRARY_PATH"},
"hpux": []string{"LD_LIBRARY_PATH", "SHLIB_PATH"},
+ "irix": []string{"LD_LIBRARY_PATH", "LD_LIBRARYN32_PATH", "LD_LIBRARY64_PATH"},
"linux": []string{"LD_LIBRARY_PATH"},
+ "solaris": []string{"LD_LIBRARY_PATH", "LD_LIBRARY_PATH_32", "LD_LIBRARY_PATH_64"},
"windows": []string{"SystemRoot", "COMSPEC", "PATHEXT", "WINDIR"},
}
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: libgo patch committed: Inherit environment in http/cgi
2011-04-29 12:53 ` Rainer Orth
@ 2011-04-29 18:58 ` Ian Lance Taylor
0 siblings, 0 replies; 3+ messages in thread
From: Ian Lance Taylor @ 2011-04-29 18:58 UTC (permalink / raw)
To: Rainer Orth; +Cc: gcc-patches, gofrontend-dev
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:
>> This libgo patch brings over a patch to the master Go library to inherit
>> environment variables in http/cgi. This should fix PR go/48503.
>
> not really :-) It needs the following supplement to handle Solaris and
> IRIX. I'm not only including LD_LIBRARY_PATH (although this would suffice
> for the testcase to pass), but also the ABI variants thereof.
Thanks. Committed.
Ian
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-04-29 17:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-22 18:59 libgo patch committed: Inherit environment in http/cgi Ian Lance Taylor
2011-04-29 12:53 ` Rainer Orth
2011-04-29 18:58 ` Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).