-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatform_system_core.patch
More file actions
65 lines (57 loc) · 2.07 KB
/
platform_system_core.patch
File metadata and controls
65 lines (57 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From 6c6cdbafc58925f2bef26c49088ca332c4d74584 Mon Sep 17 00:00:00 2001
From: Daniel Zhang <danielzhang130@gmail.com>
Date: Wed, 3 Jan 2024 16:23:50 -0500
Subject: [PATCH] add force option in run-as
Change-Id: I9f929e85fed6414e474cc312b09ad709c20ab105
Signed-off-by: Daniel Zhang <danielzhang130@gmail.com>
---
run-as/run-as.cpp | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/run-as/run-as.cpp b/run-as/run-as.cpp
index 32057b4..6a80653 100644
--- a/run-as/run-as.cpp
+++ b/run-as/run-as.cpp
@@ -181,10 +181,18 @@ int main(int argc, char* argv[]) {
// Get user_id from command line if provided.
int userId = 0;
- if ((argc >= 4) && !strcmp(argv[2], "--user")) {
- userId = atoi(argv[3]);
- if (userId < 0) error(1, 0, "negative user id: %d", userId);
- cmd_argv_offset += 2;
+ bool force = false;
+ for (int arg = 2; arg < argc; ++arg) {
+ if (arg + 1 < argc && !strcmp(argv[arg], "--user")) {
+ userId = atoi(argv[++arg]);
+ if (userId < 0) error(1, 0, "negative user id: %d", userId);
+ cmd_argv_offset += 2;
+ } else if (!strcmp(argv[arg], "-f")) {
+ force = true;
+ ++cmd_argv_offset;
+ } else {
+ break;
+ }
}
// Retrieve package information from system, switching egid so we can read the file.
@@ -208,14 +216,16 @@ int main(int argc, char* argv[]) {
// Calculate user app ID.
uid_t userAppId = (AID_USER_OFFSET * userId) + info.uid;
- // Reject system packages.
- if (userAppId < AID_APP) {
- error(1, 0, "package not an application: %s", pkgname);
- }
+ if (!force) {
+ // Reject system packages.
+ if (userAppId < AID_APP) {
+ error(1, 0, "package not an application: %s", pkgname);
+ }
- // Reject any non-debuggable package.
- if (!info.debuggable) {
- error(1, 0, "package not debuggable: %s", pkgname);
+ // Reject any non-debuggable package.
+ if (!info.debuggable) {
+ error(1, 0, "package not debuggable: %s", pkgname);
+ }
}
// Ensure we have the right data path for the specific user.
--
2.34.1