Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 879091 - sys-apps/merge-usr: broken in podman/docker containers
Summary: sys-apps/merge-usr: broken in podman/docker containers
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Mike Gilbert
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-02 03:48 UTC by John Helmert III
Modified: 2022-11-02 20:11 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
mv.strace (mv.strace,168.49 KB, text/plain)
2022-11-02 16:45 UTC, John Helmert III
Details
/proc/self/mountinfo (mountinfo,3.88 KB, text/plain)
2022-11-02 16:47 UTC, John Helmert III
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-11-02 03:48:13 UTC
After installing merge-usr in a fresh container (tested in both podman/docker containers), trying to run it results in a stack trace:

# merge-usr
INFO: Migrating files from '/bin' to '/usr/bin'
WARNING: Skipping symlink '/bin/awk'
INFO: Replacing '/bin' with a symlink to 'usr/bin'
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.10/merge-usr", line 282, in <module>
    sys.exit(main())
  File "/usr/lib/python-exec/python3.10/merge-usr", line 277, in main
    if not mu.run():
  File "/usr/lib/python-exec/python3.10/merge-usr", line 236, in run
    os.rename(src, tmp)
OSError: [Errno 18] Invalid cross-device link: '/bin' -> '/tmp2k2_7hc0'

An environment to reproduce should be as simple as `docker run --volume /var/db/repos:/var/db/repos -it gentoo/stage3` and emerging merge-usr.

A perfect fix would be to simply use a container that already has the proper layout, but merge-usr should probably support this case anyway in the meantime. Can't generate merged-usr images without such stages everywhere anyway.
Comment 1 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-11-02 15:22:10 UTC
This seems to be due to the directories existing on differing overlayfs layers. I guess a simple:

# mv /bin /tmpbin
# mv /tmpbin /bin

Will get them into the same layer, and then merge-usr is able to continue.
Comment 2 Mike Gilbert gentoo-dev 2022-11-02 15:58:20 UTC
merge-usr is calling rename("/bin", "/tmp2k2_7hc0") there.

Have you tested that "mv" command? If it actually works, please strace it so we can see what system calls mv is making.

I suspect it is doing a recursive copy, followed by a recursive delete.
Comment 3 Mike Gilbert gentoo-dev 2022-11-02 16:15:17 UTC
Also, please provide the contents of /proc/self/mountinfo from a process running in the container.
Comment 4 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-11-02 16:45:41 UTC
Created attachment 826729 [details]
mv.strace

Requested strace output
Comment 5 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-11-02 16:47:10 UTC
Created attachment 826731 [details]
/proc/self/mountinfo
Comment 7 Mike Gilbert gentoo-dev 2022-11-02 18:18:31 UTC
Could you please test the bug879091-dir-rename branch?

https://github.com/floppym/merge-usr/tree/bug879091-dir-rename
Comment 8 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2022-11-02 19:45:40 UTC
That works for me, thank you!
Comment 9 Larry the Git Cow gentoo-dev 2022-11-02 20:11:28 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=29e8109a12a05e6fa7020c3778adf549444c94c8

commit 29e8109a12a05e6fa7020c3778adf549444c94c8
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2022-11-02 20:10:55 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2022-11-02 20:10:55 +0000

    sys-apps/merge-usr: add 4, drop 3
    
    Closes: https://bugs.gentoo.org/879091
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 sys-apps/merge-usr/Manifest                                   | 2 +-
 sys-apps/merge-usr/{merge-usr-3.ebuild => merge-usr-4.ebuild} | 0
 2 files changed, 1 insertion(+), 1 deletion(-)