Skip to contentSkip to conversation

'.bashrc': Unknown file type; file ignored

DISCUSSION Enrico Scholz 2 participants 4 messages Mar 15, 2024 – Mar 18, 2024 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hello,

with ubuntu-20.04 based builders I get problems like

| DEBUG: Executing shell function do_image_tar
| tar: ./home/.../.bashrc: Unknown file type; file ignored
| tar: Exiting with failure status due to previous errors
| WARNING: exit code 1 from a shell command.
| NOTE: recipe ...-image-core-1.0-r0: task do_image_tar: Failed

or

| Creating journal (8192 blocks): done
| Copying files into the device: __populate_fs: ignoring entry ".bashrc"
| .bashrc: File not found by ext2_lookup while looking up ".bashrc"
| mkfs.ext4: File not found by ext2_lookup while populating file system
| 
| + bb_sh_exit_handler
| + ret=1
| + [ 1 != 0 ]
| + echo WARNING: exit code 1 from a shell command.
| + exit 1
| WARNING: exit code 1 from a shell command.
| NOTE: recipe ...-image-1.0-r0: task do_image_wic: Failed

Build works fine under fedora-39 based builders.

I see related discussions at 2024-01-18 ("shadow: link executables statically for -native variant") but not after.

Seen on scarthgap bc793fa9d1fe24c102d91e97b7002b6e637cbfa5 and it seems to be very reproducible (both the failure on ubuntu-20.04 and the success on fedora-39).

Enrico

#1 lore raw
Quoted 3 lines · Enrico Scholz

Seen on scarthgap bc793fa9d1fe24c102d91e97b7002b6e637cbfa5 and it seems to be very reproducible (both the failure on ubuntu-20.04 and the success on fedora-39).

Can be reproduced manually by setting the PSEUDO environment and invoking

| pseudo useradd -R pwd/rootfs bar1
| pseudo ls -la rootfs/home/bar1

Problem is somewhere in the interpretation of the fstatat() result in

4.14.2/shadow-4.14.2/lib/copydir.c

| 443		if (fstatat(dst->dirfd, dst->name, &sb, AT_SYMLINK_NOFOLLOW) != -1) {
| 			return 0;
| 		}
| 
| +		printf("fstatat(%d, %s) -> dev=%d, ino=%d, mode=%o\n",
| +		       dst->dirfd, dst->name, (int)sb.st_dev, (int)sb.st_ino, sb.st_mode);

Shows here (content is from /etc/skel)

| fstatat(5, .profile) -> dev=64514, ino=1787061952, mode=15241063300 | fstatat(5, .bashrc) -> dev=64514, ino=1787061952, mode=15241063300

While

| $ stat rootfs/etc/skel/. 
|   File: rootfs/etc/skel/.bashrc
|   Size: 410             Blocks: 8          IO Block: 4096   regular file
| Device: 252,2   Inode: 19552578    Links: 1

is expected.

Pseudo log shows for this call

1914825: wrapper called: __fxstatat
1914825: __fxstatat - signals blocked, obtaining lock
1914825: paes: newpath .../rootfs/etc/skel, element list <.bashrc>
1914825: element to add: '.bashrc'
1914825: pae: '.../rootfs/etc/skel', + '.bashrc', is_dir 1
1914825: paes: append_element gave us '.../rootfs/etc/skel/.bashrc', current '' 1914825: .../rootfs/etc/skel + .bashrc => <.../rootfs/etc/skel/.bashrc>
1914825: base_path[nofollow]: .../rootfs/etc/skel</>.bashrc => .../rootfs/etc/skel/.bashrc 1914825: root_path [__fxstatat, 235]: '.../rootfs/etc/skel/.bashrc' from '.bashrc' 1914825: statat .../rootfs/etc/skel/.bashrc (+buf) (0100755): processing request [ino 19552578] 1914825: sending request [ino 19552578]
1914825: sending a message: ino 19552578
1914825: msg type 3 (stat), external path .../rootfs/etc/skel/.bashrc, mode 0100755 1914825: wrote 182 bytes
1914825: sent!

Enrico

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 5 lines · Enrico Scholz

4.14.2/shadow-4.14.2/lib/copydir.c

| 443		if (fstatat(dst->dirfd, dst->name, &sb, AT_SYMLINK_NOFOLLOW) != -1) {
| 			return 0;
| 		}

Bug in shadow-utils; when fstatat() fails, content of 'sb' will still be used.

https://github.com/shadow-maint/shadow/blob/f4293f9fbc2b855878f549d9124bdd638fb08c60/lib/copydir.c#L439-L447

pseudo might trigger it because it calls the __fxstatat64() with an uninitialized 64 bit buffer and copies its content to the 32 bit buffer.

Enrico

#4 lore raw
Quoted 9 lines · Enrico Scholz via lists.openembedded.org
Quoted 5 lines · Enrico Scholz

4.14.2/shadow-4.14.2/lib/copydir.c

| 443         if (fstatat(dst->dirfd, dst->name, &sb, AT_SYMLINK_NOFOLLOW) != -1) {
|                     return 0;
|             }
Quoted 7 lines

Bug in shadow-utils; when fstatat() fails, content of 'sb' will still be used.

https://github.com/shadow-maint/shadow/blob/f4293f9fbc2b855878f549d9124bdd638fb08c60/lib/copydir.c#L439-L447

pseudo might trigger it because it calls the __fxstatat64() with an uninitialized 64 bit buffer and copies its content to the 32 bit buffer.

Thanks for digging, this makes sense as the code and the issue only appear from 4.14 onwards. We had erroneously ascribed the problem to static linking.

Alex