Skip to content

Not all packages are installing. #7

Closed

Description

@ani1nonly

Log file is attached

Terminal.log

Activity

  1. Woffluon commented on Oct 6, 2026

    @Woffluon
    Contributor

    Thanks for sharing Terminal.log. I traced the log from start to finish and found three distinct root causes in libcortex-hook.so (app/src/main/cpp/cortex-hook.c) that caused apt install gradle (and dependent packages) to fail:

    1. dbus-system-bus-common and dbus failing during dpkg --configure (exit status 1):
      dbus-system-bus-common.postinst runs adduser --system --quiet --home /nonexistent --no-create-home --disabled-password --group messagebus. In cortex-hook.c, the NSS hooks (getpwnam, getpwnam_r, getpwuid, getpwuid_r, getgrnam, getgrnam_r, getgrgid, getgrgid_r) synthesized a fake uid = 0 (root) entry for every username, group, and UID not found in /etc/passwd or /etc/group instead of returning NULL. Because egetpwnam("messagebus") returned uid = 0 (< 100), adduser concluded that messagebus already existed as a non-system user and exited with status 1. In addition, first_avail_uid(100, 999) saw every UID in 100..999 as already taken because getpwuid never returned NULL.

      • Fix: I restricted the NSS fallback synthesis strictly to "root" and the current process's real UID/GID (0 or real_uid()/real_gid()). Lookups for non-existent service accounts and free UIDs (100..999) now return NULL as expected by adduser/useradd.
    2. ca-certificates-java trigger failing with Unable to execute Java and gradle/java failing with libjli.so: cannot open shared object file:
      On Ubuntu, /usr/bin/java is a symlink chain (/usr/bin/java -> /etc/alternatives/java -> /usr/lib/jvm/java-21-openjdk-arm64/bin/java). In cortex-hook.c, execve and posix_spawn passed the unresolved symlink path $CORTEX_ROOT/usr/bin/java as the target binary argument to ld-linux-aarch64.so.1 and to CORTEX_REAL_EXE (/proc/self/exe). When glibc's ld.so is invoked explicitly with a filename argument, _dl_new_object computes $ORIGIN from that argument's directory ($CORTEX_ROOT/usr/bin) without resolving symlinks. As a result, OpenJDK's DT_RUNPATH ($ORIGIN/../lib) searched /usr/lib/libjli.so instead of /usr/lib/jvm/java-21-openjdk-arm64/lib/libjli.so, and /proc/self/exe pointed to /usr/bin/java instead of the JRE installation directory.

      • Fix: execve and posix_spawn now resolve symlinks (resolve_symlinks) before wrapping dynamically linked ELF binaries with ld-linux, pass the resolved ELF path to both ld-linux and CORTEX_REAL_EXE, preserve the original argv[0] via --argv0, and prepend any caller LD_LIBRARY_PATH entries into --library-path.
    3. useradd/groupadd NETLINK_AUDIT and dbus.postinst setuid chmod errors:
      socket(AF_NETLINK, ..., NETLINK_AUDIT) now returns -1 with errno = EPROTONOSUPPORT so libaudit disables kernel audit logging cleanly instead of aborting on Android SELinux EACCES/EPERM. In chmod, fchmod, and fchmodat, if setting setuid/setgid bits (mode & 06000, such as 04754 on dbus-daemon-launch-helper) fails on Android's nosuid /data mount, the hook retries with mode & 01777.

    I have opened #9 with these fixes and regression tests.

  2. Woffluon commented on Oct 6, 2026

    @Woffluon
    Contributor

    Update: I have pushed additional post-merge hardening commits to #9 addressing the CodeRabbit review findings:

    • Added 2-byte instruction aligned Thumb-2 syscall patching (movw r7, #imm + svc #0 and mov.w r12, #imm + bl __libc_do_syscall) for 32-bit ARM/ARMHF environments.
    • Corrected NSS _r functions (getpwnam_r, getpwuid_r, getgrnam_r, getgrgid_r) to propagate real libc errors (such as ERANGE) rather than masking them.
    • Fixed D-Bus /var/lib/dbus/machine-id zero-byte file issue by symlinking to /etc/machine-id during bootstrap and runtime initialization.
    • Broadened SIGSYS handler to cover Linux 5.1+ syscalls (424..511) with -ENOSYS.

    All 38 unit tests, 91 native C assertions, and 32 shell regression tests are passing cleanly.

  3. added a commit that references this issue on Oct 7, 2026
  4. ani1nonly commented on Oct 7, 2026

    @ani1nonly
    Author

    Where is the apk

  5. Woffluon commented on Oct 8, 2026

    @Woffluon
    Contributor

    The fix has been merged into the main branch via PR #9.

    Official APKs are published under Releases whenever the repository maintainer (@ssfuisu) cuts a new release tag (the next release will likely be v1.25.25).

    If you'd like to test the fix immediately before the next official release is tagged, you can build an APK directly from main:

    git clone https://github.com/ssfuisu/cortex.git
    cd cortex
    ./gradlew assembleDebug

    The built APK will be located under app/build/outputs/apk/debug/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions