зеркало из https://github.com/mozilla/mig.git
[minor] automatically set gpg agent socket if exists (bug 1141900)
This commit is contained in:
Родитель
6a1bdcccd6
Коммит
f0b5599337
|
@ -28,7 +28,10 @@ func main() {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cli := client.NewClient(conf, version)
|
||||
cli, err = client.NewClient(conf, "agent-search-"+version)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
agents, err := cli.EvaluateAgentTarget(strings.Join(flag.Args(), " "))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
@ -58,8 +58,7 @@ type GpgConf struct {
|
|||
}
|
||||
|
||||
// NewClient initiates a new instance of a Client
|
||||
func NewClient(conf Configuration, version string) Client {
|
||||
var cli Client
|
||||
func NewClient(conf Configuration, version string) (cli Client, err error) {
|
||||
cli.Version = version
|
||||
cli.Conf = conf
|
||||
tr := &http.Transport{
|
||||
|
@ -81,7 +80,23 @@ func NewClient(conf Configuration, version string) Client {
|
|||
},
|
||||
}
|
||||
cli.API = &http.Client{Transport: tr}
|
||||
return cli
|
||||
// if the env variable to the gpg agent socket isn't set, try to
|
||||
// find the socket and set the variable
|
||||
if os.Getenv("GPG_AGENT_INFO") == "" {
|
||||
_, err = os.Stat(conf.GPG.Home + "/S.gpg-agent")
|
||||
if err == nil {
|
||||
// socket was found, set it
|
||||
os.Setenv("GPG_AGENT_INFO", conf.GPG.Home+"/S.gpg-agent")
|
||||
}
|
||||
}
|
||||
// try to make a signed token, just to check that we can access the private key
|
||||
_, err = cli.MakeSignedToken()
|
||||
if err != nil {
|
||||
err = fmt.Errorf("failed to generate a security token using key %s from %s\n",
|
||||
conf.GPG.KeyID, conf.GPG.Home+"/secring.gpg")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ReadConfiguration loads a client configuration from a local configuration file
|
||||
|
@ -116,15 +131,6 @@ func ReadConfiguration(file string) (conf Configuration, err error) {
|
|||
if conf.API.URL[len(conf.API.URL)-1] != '/' {
|
||||
conf.API.URL += "/"
|
||||
}
|
||||
// try to make a signed token, just to check that we can access the private key
|
||||
var cli Client
|
||||
cli.Conf = conf
|
||||
_, err = cli.MakeSignedToken()
|
||||
if err != nil {
|
||||
err = fmt.Errorf("failed to generate a security token using key %s from %s\n",
|
||||
conf.GPG.KeyID, conf.GPG.Home+"/secring.gpg")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -177,7 +177,10 @@ readytolaunch:
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cli = client.NewClient(conf, "cmd-"+version)
|
||||
cli, err = client.NewClient(conf, "cmd-"+version)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// set the validity 60 second in the past to deal with clock skew
|
||||
a.ValidFrom = time.Now().Add(-60 * time.Second).UTC()
|
||||
|
|
|
@ -70,7 +70,10 @@ func main() {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cli := client.NewClient(conf, "console-"+version)
|
||||
cli, err := client.NewClient(conf, "console-"+version)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
// print platform status
|
||||
err = printStatus(cli)
|
||||
if err != nil {
|
||||
|
|
|
@ -65,7 +65,10 @@ func main() {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
cli := client.NewClient(conf, "generator-"+version)
|
||||
cli, err = client.NewClient(conf, "generator-"+version)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// We need a file to load the action from
|
||||
if *file == "/path/to/file" {
|
||||
|
|
Загрузка…
Ссылка в новой задаче