diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2016-11-11 13:51:23 -0800 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2016-11-11 13:51:23 -0800 |
| commit | e3653a25edc60c2096d0573c2ab891e4ea6fde81 (patch) | |
| tree | e7aa335bbf4166def361094568c750c0ce019e4c | |
| parent | 9041744a6004ea2ca30a04b81b1df28f8612adcd (diff) | |
vm/adb: switch adb to root
Userdebug builds have adb under 'shell' user by default.
Switch to root user before starting fuzzing.
| -rw-r--r-- | vm/adb/adb.go | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/vm/adb/adb.go b/vm/adb/adb.go index 65cf60d08..5a75d07a5 100644 --- a/vm/adb/adb.go +++ b/vm/adb/adb.go @@ -158,14 +158,8 @@ func (inst *instance) adb(args ...string) ([]byte, error) { func (inst *instance) repair() error { // Assume that the device is in a bad state initially and reboot it. - for i := 0; i < 300; i++ { - if _, err := inst.adb("shell", "pwd"); err == nil { - break - } - if !vm.SleepInterruptible(time.Second) { - return fmt.Errorf("shutdown in progress") - } - } + // Ignore errors, maybe we will manage to reboot it anyway. + inst.waitForSsh() // adb reboot episodically hangs, so we use a more reliable way. // Ignore errors because all other adb commands hang as well // and the binary can already be on the device. @@ -177,6 +171,18 @@ func (inst *instance) repair() error { if !vm.SleepInterruptible(10 * time.Second) { return fmt.Errorf("shutdown in progress") } + if err := inst.waitForSsh(); err != nil { + return err + } + // Switch to root for userdebug builds. + inst.adb("root") + if err := inst.waitForSsh(); err != nil { + return err + } + return nil +} + +func (inst *instance) waitForSsh() error { var err error for i := 0; i < 300; i++ { if !vm.SleepInterruptible(time.Second) { |
