Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: Deduce GOROOT for custom location of prebuilt go #10012

Closed
krnowak opened this issue Feb 26, 2015 · 8 comments
Closed

cmd/go: Deduce GOROOT for custom location of prebuilt go #10012

krnowak opened this issue Feb 26, 2015 · 8 comments

Comments

@krnowak
Copy link

krnowak commented Feb 26, 2015

Shouldn't prebuilt go's GOROOT be deduced upon go binary's path instead of being hardcoded to /usr/local/go or c:\Go (unless GOROOT env var is specified of course)? Something like following:

func getGoRootForPrebuilt() string {
    binDir := filepath.Dir(os.Args[0])
    if filepath.IsAbs(binDir) {
        return filepath.Clean(filepath.Join(binDir, ".."))
    }

    wd, err := os.Getwd()
    if err != nil {
        return defaultPrebuiltGoRoot()
    }
    return filepath.Clean(filepath.Join(wd, binDir, ".."))
}
@minux
Copy link
Member

minux commented Feb 26, 2015 via email

@krnowak
Copy link
Author

krnowak commented Feb 26, 2015

Well, I was rather thinking that this thing would be applied only for prebuilts which are easiest to install locally instead of system-wide. I don't know if such use is the most common one, though.

So kind of counter-argument for no-behavior-change-on-location-change would be users are changing the behavior for custom installs anyway. The GOROOT deduction would Do The Right Thing for both default installs (/usr/local/go or C:\go) and custom installs (anywhere else).

@minux
Copy link
Member

minux commented Feb 26, 2015 via email

@nightlyone
Copy link
Contributor

Doesn't relinking invalidate checksums of those binary files? So I wouldn't recommend it for official releases. But for roll-your-own go compiler compiled from source, that should be useful.

@minux
Copy link
Member

minux commented Feb 26, 2015 via email

@nightlyone
Copy link
Contributor

The idea is, to verify if something tempered with my binary. e.g. for forensics or security auditing. That's why I only talked about not doing that in releases.

@minux
Copy link
Member

minux commented Feb 26, 2015

On Feb 26, 2015 2:40 PM, "Ingo Oeser" notifications@github.com wrote:

The idea is, to verify if something tempered with my binary. e.g. for
forensics or security auditing. That's why I only talked about not doing
that in releases.

I believe the go linker in internal linking mode is fully deterministic now
so every time you link the program, the result is the same. I'm talking
about binary releases with installers, so I don't there is an issue with
file fingerprinting for security audit.

(And normally you do the initial checksum after the installation, so the
fact that installer modifies the file for the GOROOT shouldn't affect that.)

@adg
Copy link
Contributor

adg commented Feb 26, 2015

Seems like a lot of trouble to avoid setting an environment variable, and
since they'll be setting GOPATH anyway they might as well set GOROOT.

On 27 February 2015 at 07:02, Minux Ma notifications@github.com wrote:

On Feb 26, 2015 2:40 PM, "Ingo Oeser" notifications@github.com wrote:

The idea is, to verify if something tempered with my binary. e.g. for
forensics or security auditing. That's why I only talked about not doing
that in releases.

I believe the go linker in internal linking mode is fully deterministic now
so every time you link the program, the result is the same. I'm talking
about binary releases with installers, so I don't there is an issue with
file fingerprinting for security audit.

(And normally you do the initial checksum after the installation, so the
fact that installer modifies the file for the GOROOT shouldn't affect
that.)


Reply to this email directly or view it on GitHub
#10012 (comment).

@minux minux closed this as completed Feb 26, 2015
@mikioh mikioh changed the title Deduce GOROOT for custom location of prebuilt go cmd/go: Deduce GOROOT for custom location of prebuilt go Feb 27, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants