Android Chroot 네트워킹 문제

Android Chroot 네트워킹 문제

Nvidia가 쉴드 개발을 위해 가지고 있는 Ubuntu 16.04 이미지를 루트로 바꾸려고 합니다. /mnt/chroots에 마운트된 sdcard에 배치했는데 실패하지 않고 작동하도록 apt-get 업데이트를 얻을 수 없고 ping도 실패합니다. 도움을 주시면 감사하겠습니다.

cd rootfs
mount -t proc proc proc/
mount -t sysfs sys sys/
mount -o bind /dev dev/
mount -o bind /dev/pts dev/pts/
chroot . /bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH

또한 그룹에 루트를 추가했습니다.

groupadd -g 3001 aid_net_bt_admin
groupadd -g 3002 aid_net_bt
groupadd -g 3003 aid_inet
groupadd -g 3004 aid_inet_raw
groupadd -g 3005 aid_inet_admin

gpasswd -a root aid_net_bt_admin
gpasswd -a root aid_net_bt
gpasswd -a root aid_inet
gpasswd -a root aid_inet_raw
gpasswd -a root aid_inet_admin

/etc/resolv.conf
nameserver 8.8.8.8

/etc/init.d/networking start를 사용하여

root@localhost:/# apt-get update
Err:1 http://ports.ubuntu.com/ubuntu-ports xenial InRelease
Temporary failure resolving 'ports.ubuntu.com'
Err:2 http://ports.ubuntu.com/ubuntu-ports xenial-updates InRelease
Temporary failure resolving 'ports.ubuntu.com'
Err:3 http://ports.ubuntu.com/ubuntu-ports xenial-security InRelease
Temporary failure resolving 'ports.ubuntu.com'
Reading package lists... Done
W: Failed to fetch http://ports.ubuntu.com/ubuntu-ports...nial/InRelease Temporary failure resolving 'ports.ubuntu.com'
W: Failed to fetch http://ports.ubuntu.com/ubuntu-ports...ates/InRelease Temporary failure resolving 'ports.ubuntu.com'
W: Failed to fetch http://ports.ubuntu.com/ubuntu-ports...rity/InRelease Temporary failure resolving 'ports.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

답변1

여기에는 2가지 다른 문제가 있습니다.

  • DNS를 확인하지 못하는 것이 적절합니다.
  • 핑이 작동하지 않아요

-


APT가 DNS를 확인하지 않음:

문제는 APT가 _apt를 권한 없는 사용자로 사용한다는 것입니다. 편집증 네트워크가 있는 Android에서는 3003aid_inet 또는 3004aid_inet_raw 그룹의 사용자만 네트워크 소켓을 열 수 있습니다. apt가 설치되면 사용자 _apt가 생성됩니다.

    # add unprivileged user for the apt methods
     adduser --force-badname --system --home /nonexistent  \
       --no-create-home --quiet _apt || true

사용자는 /etc/passwd에서 다음과 같이 보입니다.

    root@localhost:~
    # grep -E "_apt" /etc/passwd
    _apt:x:103:65534::/nonexistent:/bin/false

비밀번호 형식은

사용자 이름:암호화된 비밀번호:사용자 ID 번호(UID):사용자의 그룹 ID 번호(GID):사용자의 전체 이름(GECOS):사용자 홈 디렉터리:로그인 쉘

_apt 사용자를 보면 GID가 65534로 설정되어 있으며 이는 그룹이 없음을 의미합니다. 일반 Linux 시스템에서는 괜찮습니다. Android에서는 이 GID를 네트워크에 연결할 수 없습니다. GID를 3003으로 변경해야 합니다.

# usermod -g 3003 _apt GID를 변경합니다

    root@localhost:~
    # grep -E "_apt" /etc/passwd
    _apt:x:103:3003::/nonexistent:/bin/false

이제 APT는 Android chroot에서 작동합니다.

핑이 작동하지 않음


저에게는 이 명령 예제를 사용하여 chroot를 수행했을 때 나타났습니다.

# chroot /linux /bin/bash -l

Android 그룹에서는 어느 정도 앱에 사용됩니다. 따라서 루트 호출 bash는 루트 그룹에만 있습니다. 이를 확인할 수 있습니다.

    # groups
     root

사용자 이름 없이 실행되는 그룹은 현재 프로세스 그룹을 출력합니다.

이제 이것을 시도해 보세요

# su - root

su 명령은 사용자 전환입니다

    # groups
    root sdcard-rw aid_bt aid_bt-net aid_inet aid_net-raw aid_net_admin

이제 핑이 작동할 겁니다

나는 지금 사용한다

# chroot /linux /bin/su - root

Android에서 루트가 아닌 Linux에서 루트로 로그인하는 방법

관련 정보