Attempt to su when run-as gets permissions denied
Summary: pull/push might fail when run-as fails on insufficient permissions. When this happens, try to perform the command as root. Reviewed By: aigoncharov Differential Revision: D40623363 fbshipit-source-id: a4cc71d70f83ce1a390b14c9af9d3a3fa09f1307
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c38fc9c0e4
commit
29938d0c69
@@ -14,6 +14,7 @@ const allowedAppNameRegex = /^[\w.-]+$/;
|
|||||||
const appNotApplicationRegex = /not an application/;
|
const appNotApplicationRegex = /not an application/;
|
||||||
const appNotDebuggableRegex = /debuggable/;
|
const appNotDebuggableRegex = /debuggable/;
|
||||||
const operationNotPermittedRegex = /not permitted/;
|
const operationNotPermittedRegex = /not permitted/;
|
||||||
|
const permissionDeniedRegex = /permission denied/;
|
||||||
const logTag = 'androidContainerUtility';
|
const logTag = 'androidContainerUtility';
|
||||||
|
|
||||||
export type AppName = string;
|
export type AppName = string;
|
||||||
@@ -66,6 +67,7 @@ function validateFileContent(content: string): void {
|
|||||||
enum RunAsErrorCode {
|
enum RunAsErrorCode {
|
||||||
NotAnApp = 1,
|
NotAnApp = 1,
|
||||||
NotDebuggable = 2,
|
NotDebuggable = 2,
|
||||||
|
PermissionDenied = 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
class RunAsError extends Error {
|
class RunAsError extends Error {
|
||||||
@@ -177,6 +179,12 @@ function _executeCommandWithRunner(
|
|||||||
`Your android device (${deviceId}) does not support the adb shell run-as command. We're tracking this at https://github.com/facebook/flipper/issues/92`,
|
`Your android device (${deviceId}) does not support the adb shell run-as command. We're tracking this at https://github.com/facebook/flipper/issues/92`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (output.toLowerCase().match(permissionDeniedRegex)) {
|
||||||
|
throw new RunAsError(
|
||||||
|
RunAsErrorCode.PermissionDenied,
|
||||||
|
`No permission to run-as application. To use it with Flipper, either run adb as root or allow running as app`,
|
||||||
|
);
|
||||||
|
}
|
||||||
return output;
|
return output;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user