Misc QoL changes

- su: Preserve correct capacity to avoid vector reallocation
- su: Properly format code
- daemon: Remove useless `if`
- docs: Remove outdated info
This commit is contained in:
canyie
2022-04-29 23:44:02 +08:00
committed by John Wu
parent e88eed9a8d
commit 4f1a1879e5
6 changed files with 11 additions and 15 deletions

View File

@@ -283,10 +283,7 @@ static void switch_cgroup(const char *cgroup, int pid) {
if (fd == -1)
return;
snprintf(buf, sizeof(buf), "%d\n", pid);
if (xwrite(fd, buf, strlen(buf)) == -1) {
close(fd);
return;
}
xwrite(fd, buf, strlen(buf));
close(fd);
}

View File

@@ -29,7 +29,7 @@ static void patch_init_rc(const char *src, const char *dest, const char *tmp_dir
fprintf(rc, "service flash_recovery /system/bin/xxxxx\n");
return true;
}
// Samsung's persist.sys.zygote.early will start zygotes before actual post-fs-data phase
// Samsung's persist.sys.zygote.early will cause Zygote to start before post-fs-data
if (str_starts(line, "on property:persist.sys.zygote.early=")) {
LOGD("Invalidate persist.sys.zygote.early\n");
fprintf(rc, "on property:persist.sys.zygote.early.xxxxx=true\n");

View File

@@ -189,7 +189,7 @@ void app_log(const su_context &ctx) {
void app_notify(const su_context &ctx) {
if (fork_dont_care() == 0) {
vector<Extra> extras;
extras.reserve(2);
extras.reserve(3);
extras.emplace_back("from.uid", ctx.info->uid);
extras.emplace_back("pid", ctx.pid);
extras.emplace_back("policy", ctx.info->access.policy);
@@ -210,7 +210,7 @@ int app_request(const su_context &ctx) {
// Send request
vector<Extra> extras;
extras.reserve(2);
extras.reserve(3);
extras.emplace_back("fifo", fifo);
extras.emplace_back("uid", ctx.info->eval_uid);
extras.emplace_back("pid", ctx.pid);

View File

@@ -220,7 +220,9 @@ void su_daemon_handler(int client, const sock_cred *cred) {
};
// Read su_request
if (xxread(client, &ctx.req, sizeof(su_req_base)) < 0 || !read_string(client, ctx.req.shell) || !read_string(client, ctx.req.command)) {
if (xxread(client, &ctx.req, sizeof(su_req_base)) < 0
|| !read_string(client, ctx.req.shell)
|| !read_string(client, ctx.req.command)) {
LOGW("su: remote process probably died, abort\n");
ctx.info.reset();
write_int(client, DENY);