Skip to content

id usermod useradd escaping root and reading /etc/passwd etc of host #112

@mangodan2003

Description

@mangodan2003

I'm not sure where the fault is here, but since Ubuntu 22.04 (previous known working was 20.04) id, usermod etc escape fakeroot filesystem and read hosts files as shown by:

dan@melon:~$ fakechroot fakeroot -i tmp/fakeroot.save -s tmp/fakeroot.save chroot tmp/root/ /bin/bash
root@melon:/# grep  'messagebus\|dan' /etc/group
messagebus:x:102:
root@melon:/# usermod -G  messagebus messagebus
usermod: group 'messagebus' does not exist
root@melon:/# usermod -G dan dan
root@melon:/# exit
exit
dan@melon:~$ grep  'messagebus\|dan' /etc/group
dan:x:1000:

Specifying a relative prefix for usermod makes it work, but doesnt realy help as the problem I'm facing originate in postinst files whilst running apt:

root@melon:/# usermod -G  messagebus messagebus
usermod: group 'messagebus' does not exist
root@melon:/# usermod -G  messagebus messagebus -P ../../
root@melon:/# usermod -G  messagebus messagebus -P /     
usermod: group 'messagebus' does not exist

Why is it that grep sees /etc/passwd of the fakeroot filetree, yet id sees that of the host? They seem to both be linked against the same fakechroot and libc libraries, but i do notice id is linked with sellinux.

root@melon:/# /bin/grep dan /etc/passwd
root@melon:/# id -u dan
1000
root@melon:/# ldd /bin/grep
        linux-vdso.so.1 (0x0000000000000000)
        libfakeroot-sysv.so => /usr/lib/x86_64-linux-gnu/libfakeroot/libfakeroot-sysv.so (0x0000000000000000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x0000000000000000)
        /lib64/ld-linux-x86-64.so.2 (0x0000000000000000)
        libfakechroot.so => /usr/lib/x86_64-linux-gnu/fakechroot/libfakechroot.so (0x0000000000000000)
        libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x0000000000000000)
root@melon:/# ldd /usr/bin/id 
        linux-vdso.so.1 (0x0000000000000000)
        libfakeroot-sysv.so => /usr/lib/x86_64-linux-gnu/libfakeroot/libfakeroot-sysv.so (0x0000000000000000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x0000000000000000)
        /lib64/ld-linux-x86-64.so.2 (0x0000000000000000)
        libfakechroot.so => /usr/lib/x86_64-linux-gnu/fakechroot/libfakechroot.so (0x0000000000000000)
        libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x0000000000000000)
        libpcre2-8.so.0 => /usr/lib/x86_64-linux-gnu/libpcre2-8.so.0 (0x0000000000000000)

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