Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adb root 功能不支持不带版本号的 apex #33

Open
Kazurin-775 opened this issue Mar 21, 2022 · 2 comments
Open

adb root 功能不支持不带版本号的 apex #33

Kazurin-775 opened this issue Mar 21, 2022 · 2 comments

Comments

@Kazurin-775
Copy link

  • 系统:Android 11 (ArrowOS)
  • 设备:小米 6X (wayne)
  • Magisk: v24.3
  • Sui: 当前 CI 最新版 (f8eee8c) v12.6.1-release

在手机上创建 enable_adb_root 文件并重启后,adb root 仍然提示 adbd cannot run as root in production builds

日志关键部分:

01-08 07:03:35.164   704   704 I Sui     : Setup adb root support: /dev/PwR6B9/.magisk/modules/zygisk-sui
01-08 07:03:35.168   704   704 I Sui     : Use adbd from /apex
01-08 07:03:35.169   704   704 I Sui     : /apex/com.android.adbd/bin/adbd is dynamically linked
01-08 07:03:35.170   704   704 V Sui     : /apex/com.android.adbd/bin/adbd: uid=0, gid=2000, mode=100755, context=u:object_r:adbd_exec:s0
01-08 07:03:35.170   704   704 V Sui     : /apex/com.android.adbd/bin: uid=0, gid=2000, mode=40751, context=u:object_r:system_file:s0
01-08 07:03:35.180   704   704 E Sui     : Cannot find versioned apex
01-08 07:03:35.195   706   706 I Sui     : Exited with 13

完整开机日志:logcat-coldboot.txt

通过 adb 检查 /apex 发现所有项目都不带版本号:

wayne:/ # ls /apex
com.android.adbd           com.android.i18n           com.android.neuralnetworks  com.android.sdkext
com.android.art            com.android.ipsec          com.android.os.statsd       com.android.tethering
com.android.cellbroadcast  com.android.media          com.android.permission      com.android.tzdata
com.android.conscrypt      com.android.media.swcodec  com.android.resolv          com.android.vndk.v30
com.android.extservices    com.android.mediaprovider  com.android.runtime         com.android.wifi
wayne:/ #

检查 /system/apex 发现所有 apex 都是未压缩的「扁平化 apex」,不是 .capex 格式的压缩包:

wayne:/ # ls -l /system/apex
total 80
drwxr-xr-x 6 root root 4096 2009-01-01 08:00 com.android.adbd
drwxr-xr-x 7 root root 4096 2009-01-01 08:00 com.android.art.release
drwxr-xr-x 3 root root 4096 2009-01-01 08:00 com.android.cellbroadcast
...
wayne:/ # ls -la /system/apex/com.android.adbd/
total 32
drwxr-xr-x  6 root root  4096 2009-01-01 08:00 .
drwxr-xr-x 22 root root  4096 2009-01-01 08:00 ..
-rw-r--r--  1 root root   218 2009-01-01 08:00 apex_manifest.pb
-rw-r--r--  1 root root  1032 2009-01-01 08:00 apex_pubkey
drwxr-x--x  2 root shell 4096 2009-01-01 08:00 bin
drwxr-xr-x  2 root root  4096 2009-01-01 08:00 etc
drwxr-xr-x  2 root root  4096 2009-01-01 08:00 lib
drwxr-xr-x  2 root root  4096 2009-01-01 08:00 lib64
@RikkaW
Copy link
Member

RikkaW commented Mar 21, 2022

auto apex = "/apex/"sv;
strncpy(versioned_adbd, apex.data(), apex.length());
bool found = false;
uint64_t version = 0;
auto adbd_prefix = "com.android.adbd@"sv;
while (dirent *entry = dir.ReadEntry()) {
std::string_view d_name{entry->d_name};
if (d_name.length() <= adbd_prefix.length() ||
d_name.substr(0, adbd_prefix.length()) != adbd_prefix)
continue;
const char *version_string = entry->d_name + adbd_prefix.length();
int new_version = atoll(version_string);
if (new_version >= version) {
strncpy(versioned_adbd + apex.length(), d_name.data(), d_name.length());
LOGI("Found versioned apex %s", versioned_adbd);
found = true;
}
}
if (!found) {
LOGE("Cannot find versioned apex");
return ERR_OTHER;
}

不要乱猜理由,就是假定了一定要有带版本号的 apex 文件夹而已(

@Kazurin-775 Kazurin-775 changed the title adb root 功能不支持未压缩的 apex adb root 功能不支持不带版本号的 apex Mar 21, 2022
@Kazurin-775
Copy link
Author

抱歉,看文档看漏了一句话,您说得对

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants