diff options
| author | Mark Salyzyn <salyzyn@google.com> | 2016-10-28 15:51:03 -0700 |
|---|---|---|
| committer | Mark Salyzyn <salyzyn@google.com> | 2016-11-03 13:34:27 -0700 |
| commit | 107e29ac1b1c297a0d4ee35c4978e79f47013e2c (patch) | |
| tree | 188cebcf7aa1b9ae75191a212d63a7f48fef194f /logd | |
| parent | c377843258d08d31a2eb7df1a577740e588d2761 (diff) | |
| download | system_core-107e29ac1b1c297a0d4ee35c4978e79f47013e2c.tar.gz system_core-107e29ac1b1c297a0d4ee35c4978e79f47013e2c.tar.bz2 system_core-107e29ac1b1c297a0d4ee35c4978e79f47013e2c.zip | |
logd: if eng build, be a bit more permissive about failures
Allows us some leaway to investigate logd issues on eng builds
Test: gTests logd-unit-tests, liblog-unit-tests and logcat-unit-tests
Manual on eng builds, bad logd.rc to fake permission issues
Bug: 32450474
Change-Id: I432016e29e5601d67c502076ead941cecdcbebe7
Diffstat (limited to 'logd')
| -rw-r--r-- | logd/main.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/logd/main.cpp b/logd/main.cpp index 99ad08023..d698976d0 100644 --- a/logd/main.cpp +++ b/logd/main.cpp @@ -90,29 +90,36 @@ // static int drop_privs(bool klogd, bool auditd) { + // Tricky, if ro.build.type is "eng" then this is true because of the + // side effect that ro.debuggable == 1 as well, else it is false. + bool eng = __android_logger_property_get_bool("ro.build.type", BOOL_DEFAULT_FALSE); + struct sched_param param; memset(¶m, 0, sizeof(param)); if (set_sched_policy(0, SP_BACKGROUND) < 0) { - return -1; + android::prdebug("failed to set background scheduling policy"); + if (!eng) return -1; } if (sched_setscheduler((pid_t) 0, SCHED_BATCH, ¶m) < 0) { - return -1; + android::prdebug("failed to set batch scheduler"); + if (!eng) return -1; } if (setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_BACKGROUND) < 0) { - return -1; + android::prdebug("failed to set background cgroup"); + if (!eng) return -1; } - if (prctl(PR_SET_DUMPABLE, 0) < 0) { + if (!eng && (prctl(PR_SET_DUMPABLE, 0) < 0)) { android::prdebug("failed to clear PR_SET_DUMPABLE"); return -1; } if (prctl(PR_SET_KEEPCAPS, 1) < 0) { android::prdebug("failed to set PR_SET_KEEPCAPS"); - return -1; + if (!eng) return -1; } std::unique_ptr<struct _cap_struct, int(*)(void *)> caps(cap_init(), cap_free); @@ -130,31 +137,31 @@ static int drop_privs(bool klogd, bool auditd) { CAP_SET) < 0) return -1; if (cap_set_proc(caps.get()) < 0) { android::prdebug("failed to set CAP_SETGID, CAP_SYSLOG or CAP_AUDIT_CONTROL (%d)", errno); - return -1; + if (!eng) return -1; } gid_t groups[] = { AID_READPROC }; if (setgroups(arraysize(groups), groups) == -1) { android::prdebug("failed to set AID_READPROC groups"); - return -1; + if (!eng) return -1; } if (setgid(AID_LOGD) != 0) { android::prdebug("failed to set AID_LOGD gid"); - return -1; + if (!eng) return -1; } if (setuid(AID_LOGD) != 0) { android::prdebug("failed to set AID_LOGD uid"); - return -1; + if (!eng) return -1; } if (cap_set_flag(caps.get(), CAP_PERMITTED, 1, cap_value, CAP_CLEAR) < 0) return -1; if (cap_set_flag(caps.get(), CAP_EFFECTIVE, 1, cap_value, CAP_CLEAR) < 0) return -1; if (cap_set_proc(caps.get()) < 0) { android::prdebug("failed to clear CAP_SETGID (%d)", errno); - return -1; + if (!eng) return -1; } return 0; |
