Merge lp:~axwalk/juju-core/sshstorage-sudo-prompt-1.16 into lp:juju-core/1.16

Proposed by Andrew Wilkins
Status: Merged
Approved by: Andrew Wilkins
Approved revision: no longer in the source branch.
Merged at revision: 1967
Proposed branch: lp:~axwalk/juju-core/sshstorage-sudo-prompt-1.16
Merge into: lp:juju-core/1.16
Diff against target: 30 lines (+6/-3)
2 files modified
environs/sshstorage/storage.go (+5/-2)
environs/sshstorage/storage_test.go (+1/-1)
To merge this branch: bzr merge lp:~axwalk/juju-core/sshstorage-sudo-prompt-1.16
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+190284@code.launchpad.net

Commit message

environs/sshstorage: don't hide sudo prompt

Connect sudo command's stdout to os.Stdout,
and capture stderr in a bytes.Buffer. This
allows sudo prompts to be presented, while
still capturing "install" errors.

Fixes #1235716

https://codereview.appspot.com/14461044/

Description of the change

environs/sshstorage: don't hide sudo prompt

Connect sudo command's stdout to os.Stdout,
and capture stderr in a bytes.Buffer. This
allows sudo prompts to be presented, while
still capturing "install" errors.

Fixes #1235716

https://codereview.appspot.com/14461044/

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'environs/sshstorage/storage.go'
2--- environs/sshstorage/storage.go 2013-10-03 08:34:41 +0000
3+++ environs/sshstorage/storage.go 2013-10-10 01:34:31 +0000
4@@ -84,8 +84,11 @@
5
6 cmd := sshCommand(host, true, fmt.Sprintf("sudo bash -c %s", utils.ShQuote(script)))
7 cmd.Stdin = os.Stdin
8- if out, err := cmd.CombinedOutput(); err != nil {
9- err = fmt.Errorf("failed to create storage dir: %v (%v)", err, strings.TrimSpace(string(out)))
10+ cmd.Stdout = os.Stdout // for sudo prompts/output
11+ var stderr bytes.Buffer
12+ cmd.Stderr = &stderr
13+ if err := cmd.Run(); err != nil {
14+ err = fmt.Errorf("failed to create storage dir: %v (%v)", err, strings.TrimSpace(stderr.String()))
15 return nil, err
16 }
17
18
19=== modified file 'environs/sshstorage/storage_test.go'
20--- environs/sshstorage/storage_test.go 2013-10-03 08:44:30 +0000
21+++ environs/sshstorage/storage_test.go 2013-10-10 01:34:31 +0000
22@@ -162,7 +162,7 @@
23 invocations++
24 switch invocations {
25 case 1, 3:
26- return exec.Command("bash", "-c", "echo alles gut")
27+ return exec.Command("true")
28 case 2:
29 // Note: must close stdin before responding the first time, or
30 // the second command will race with closing stdin, and may

Subscribers

People subscribed via source and target branches

to all changes: