summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2015-02-25 15:48:06 -0800
committerNick Kralevich <nnk@google.com>2015-02-25 16:27:31 -0800
commit268eb4f3846d551c73eb4fc5a505f9a70d47b638 (patch)
treeb50ad9f45154bfd9568fe599fcfcdbd5f9ccea20
parent7bb72b73b0291636721d83a45adad175163361ec (diff)
downloadsystem_core-268eb4f3846d551c73eb4fc5a505f9a70d47b638.zip
system_core-268eb4f3846d551c73eb4fc5a505f9a70d47b638.tar.gz
system_core-268eb4f3846d551c73eb4fc5a505f9a70d47b638.tar.bz2
check if uid=0 before attempting remount
If "adb remount" is done without having done "adb root" first, scary looking SELinux denials are emitted before the operation eventually fails. Avoid the scary looking messages by refusing remount attempts if we're not running with privileges. Change-Id: I298621251a10e38345ef77875003a97c8b5a0270
-rw-r--r--adb/remount_service.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/adb/remount_service.c b/adb/remount_service.c
index 2fe05c3..414b316 100644
--- a/adb/remount_service.c
+++ b/adb/remount_service.c
@@ -113,6 +113,12 @@ void remount_service(int fd, void *cookie)
char buffer[200];
char prop_buf[PROPERTY_VALUE_MAX];
+ if (getuid() != 0) {
+ WriteStringFully(fd, "Not running as root. Try \"adb root\" first.\n");
+ adb_close(fd);
+ return;
+ }
+
bool system_verified = false, vendor_verified = false;
property_get("partition.system.verified", prop_buf, "0");
if (!strcmp(prop_buf, "1")) {