Ubuntu delta causes `can't open /dev/null: No such file or directory` errors in minimal environments (chroot/unshare)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
adduser (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned | ||
Noble |
Confirmed
|
Undecided
|
Unassigned | ||
shadow (Ubuntu) |
Confirmed
|
High
|
Unassigned | ||
Noble |
Confirmed
|
High
|
Unassigned |
Bug Description
Hi,
I was digging into fixing `autopkgtest`'s `unshare` testsuite, and the rabbit hole led me here.
Here is a very quick reproducer, first:
Start a fresh Ubuntu VM. Here is a quick path, but other ways should do fine:
```
$ cd /tmp
$ autopkgtest-
$ kvm -m 1G -snapshot -hda autopkgtest-
```
Now in the VM:
```
$ sudo apt install -y mmdebstrap
$ mmdebstrap noble /tmp/rootfs
[...]
$ sudo useradd --create-home --root /tmp/rootfs user1
can't open /dev/null: No such file or directory
```
The line `can't open /dev/null: No such file or directory` is printed on `stderr`, and that's unexpected by the part of the code I was debugging in the first place.
Digging a bit led me to that line that does the printing: https:/
There seem to me that there are multiple issues with that patch:
* Why try to call `zsysctl` in every case without first checking that it would be relevant: ZFS is not even installed on the VM we just created, less alone it has any ZFS volume/
* Obviously, when creating a user in a `chroot`, `/dev/null` won't exist unless mapped, and `useradd` is perfectly aware of that, because it even does the `chroot` call itself! But why even try to mess with ZFS in the `chroot` case in the first place?
From what history @brian-murray told me, this patch was part of some ZFS experimentation in the past. Maybe that experimentation is now finished, and that patch could be dropped? At the very least it needs improvements, imho.
EDIT: Just for context on why this issue appears only now: I was trying to fix the `unshare` testsuite in `autopkgtest`, which is pretty recent (2022) (https:/
description: | updated |
tags: |
added: foundations-todo removed: rls-nn-incoming |
Changed in shadow (Ubuntu Noble): | |
status: | New → Confirmed |
importance: | Undecided → High |
This also affects src:adduser, which has this delta:
+ if ($action eq "adduser") { zsysctl' , 'userdata', 'create', $new_name, $home_dir,));
+ # Mute the command
+ system('sh' => ( '-c' => '"$@" >/dev/null 2>&1', '--', '/usr/sbin/
+ }
causing it to fail in minimal environments where /dev is non populated.
In practice we are hitting this with autopkgtest- virt-unshare( 1), which tries to create a user in the chroot, but fails because of that.