summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJin Qian2017-02-22 19:17:49 -0600
committerJin Qian2017-02-27 14:52:04 -0600
commitf97e6e7dd452798e3016f4efca1113b34306af5b (patch)
treec19163a24222779dcdd3245eae467dac25f712af /storaged
parent9f27c6985df2e2848d9b7a738321cb817685d1e2 (diff)
downloadplatform-system-core-f97e6e7dd452798e3016f4efca1113b34306af5b.tar.gz
platform-system-core-f97e6e7dd452798e3016f4efca1113b34306af5b.tar.xz
platform-system-core-f97e6e7dd452798e3016f4efca1113b34306af5b.zip
storaged: reduce storaged privilege
Remove storaged from system group. Let init set priority based on rc file. Test: adb shell dumpsys storaged --force Bug: 35323867 Change-Id: I9d893ec69d9cc34a9e24f47166384efd7ef4d9d2
Diffstat (limited to 'storaged')
-rw-r--r--storaged/main.cpp18
-rw-r--r--storaged/storaged.rc3
2 files changed, 2 insertions, 19 deletions
diff --git a/storaged/main.cpp b/storaged/main.cpp
index f5a8f3901..672f453b3 100644
--- a/storaged/main.cpp
+++ b/storaged/main.cpp
@@ -44,20 +44,6 @@
44 44
45storaged_t storaged; 45storaged_t storaged;
46 46
47static int drop_privs() {
48 // privilege setting
49 struct sched_param param;
50 memset(&param, 0, sizeof(param));
51
52 if (set_sched_policy(0, SP_BACKGROUND) < 0) return -1;
53
54 if (sched_setscheduler((pid_t) 0, SCHED_BATCH, &param) < 0) return -1;
55
56 if (setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_BACKGROUND) < 0) return -1;
57
58 return 0;
59}
60
61// Function of storaged's main thread 47// Function of storaged's main thread
62void* storaged_main(void* s) { 48void* storaged_main(void* s) {
63 storaged_t* storaged = (storaged_t*)s; 49 storaged_t* storaged = (storaged_t*)s;
@@ -133,10 +119,6 @@ int main(int argc, char** argv) {
133 if (fd_emmc < 0) 119 if (fd_emmc < 0)
134 fd_emmc = TEMP_FAILURE_RETRY(open(mmc0_ext_csd, O_RDONLY)); 120 fd_emmc = TEMP_FAILURE_RETRY(open(mmc0_ext_csd, O_RDONLY));
135 121
136 if (drop_privs() != 0) {
137 return -1;
138 }
139
140 storaged.set_privileged_fds(fd_emmc); 122 storaged.set_privileged_fds(fd_emmc);
141 123
142 // Start the main thread of storaged 124 // Start the main thread of storaged
diff --git a/storaged/storaged.rc b/storaged/storaged.rc
index bb7c623fd..a24c7fba8 100644
--- a/storaged/storaged.rc
+++ b/storaged/storaged.rc
@@ -1,6 +1,7 @@
1service storaged /system/bin/storaged 1service storaged /system/bin/storaged
2 class main 2 class main
3 priority 10
3 file /d/mmc0/mmc0:0001/ext_csd r 4 file /d/mmc0/mmc0:0001/ext_csd r
4 writepid /dev/cpuset/system-background/tasks 5 writepid /dev/cpuset/system-background/tasks
5 user root 6 user root
6 group system package_info \ No newline at end of file 7 group package_info \ No newline at end of file