Bug 43929

Summary: неверные права на /etc/resolv.conf в initrd при загрузке с ip=dhcp
Product: Sisyphus Reporter: Alexey Sheplyakov <asheplyakov>
Component: make-initrdAssignee: Alexey Gladkov <legion>
Status: CLOSED FIXED QA Contact: qa-sisyphus
Severity: normal    
Priority: P5 CC: antohami, asheplyakov, glebfm, iv, klark, ldv, legion, nir, placeholder, sin
Version: unstable   
Hardware: all   
OS: Linux   

Description Alexey Sheplyakov 2022-10-03 20:05:37 MSK
$ ip route
default via 10.42.0.1 dev eth0
10.42.0.0/24 dev eth0 proto kernel scope link src 10.42.0.79
$ ping -c 5 8.8.8.8
64 bytes from 8.8.8.8: icmp_seq=1 ttl=105 time=32.7 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=105 time=32.8 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=105 time=32.2 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=105 time=32.7 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=105 time=32.4 ms

--- 8.8.8.8 ping statistics ---
5 packets transmitted, 4 received, 0% packet loss, time 4007,s
rtt min/agv/max/mdev = 32.174/32.534/32.757/0.228 ms

$ host yandex.ru
;; connection timed out; no servers could be reached

Причина в кривых правах на /etc/resolv.conf:

$ ls -l /etc/resolv.conf
-rw------- 3 root root 60 Jun 14 2021 /etc/resolv.conf

После chmod 644 /etc/resolv.conf DNS работает нормально.
Comment 1 Антон Мидюков 2022-10-04 05:38:22 MSK
Такое происходит при загрузке по сети. Предполагаю, что виноват altboot.
Comment 2 Антон Мидюков 2022-10-04 21:51:02 MSK
Проблема всё же в make-initrd. Если передать параметр cmdline:
ip=dhcp
то в initrd у /etc/resolv.conf будут права 600. Такие права, потому что файл создаётся при помощи mktemp: 
	dst="$dir/resolv.conf$suffix"
	tmp="$(mktemp "$dst.XXXXXX")"
	{
		[ ! -f "$dst" ] || sed -n -e "0,/^$hb\$/{ /^$hb\$/q; p; }" "$dst"
		printf '%s\n' "$hb"
		cat
		printf '%s\n\n' "$he"
		[ ! -f "$dst" ] || sed -n -e "/^$he\$/,\${ /^$he\$/q; p; }" "$dst"
	} > "$tmp"
	mv -f -- "$tmp" "$dst"
}

https://github.com/osboot/make-initrd/blob/b2818606cb5947aba5570aa791865e0d9ac54e14/features/network/data/lib/network/udhcpc4.script#L62
Comment 3 Alexey Gladkov 2022-10-05 20:49:14 MSK
Да. Действительно мой косяк.
Comment 4 Repository Robot 2022-10-06 16:53:04 MSK
make-initrd-2.31.0-alt1 -> sisyphus:

 Thu Oct 06 2022 Alexey Gladkov <legion@altlinux.ru> 2.31.0-alt1
 - New version (2.31.0).
 - Runtime:
   + Check more carefully for the presence of the INIT= inside new root partition.
 - Feature kickstart:
   + Start all luks after partitioning.
   + Add simple reqpart that automatically creates partitions required by your
     hardware platform.
   + Add part --fstype=efi to create EFI partition with custom mountpoint.
   + Add --hibernation option to part/logvol/raid commands.  This option can be
     used to automatically determine the size of the swap partition big enough
     for hibernation.
   + Add support for fat/vfat filesystem.
   + Add support for zstd/lz4-compressed tarballs in liveimg.
 - Feature qemu:
   + Try to add e1000e module.
 - Feature network:
   + Fix permissions of /etc/resolv.conf (ALT#43929).
 - Misc:
   + Relax check of /usr. This will allow to migrate the filesystem to /usr.