Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPM 4.20.0 --root /PATH/TO/FAKEROOT Reports "Unable to change root directory: Operation not permitted" #3441

Open
changyp6 opened this issue Nov 12, 2024 · 2 comments

Comments

@changyp6
Copy link

Describe the bug
I need to use command rpm --root /path/to/image/fakeroot -ivh xxx.rpm xxx.rpm as normal user to install RPM packages into my fakeroot for my embedded system.
When running with RPM 4.19.1.1, the above command runs perfectly.
However, after I upgrade my Fedora 40 to Fedora 41, RPM is also upgraded to versoin 4.20.0, the above command reports error: Unable to change root directory: Operation not permitted

To Reproduce
Steps to reproduce the behavior:
run rpm --root $(mktemp -d) -ivh your_rpm_name.rpm
as normal user

Expected behavior
rpm install the RPM package into the path specified by --root

Output
rpm reports:
error: Unable to change root directory: Operation not permitted

Environment

  • OS / Distribution: [Fedora 41]
  • Version [rpm-4.20.0]
@changyp6
Copy link
Author

After digging into rpm's git log, I found following commit:

commit 9c96c5d4ca376b998be9919e70f74d0995c4df2e
Author: Panu Matilainen <[email protected]>
Date:   Fri Sep 15 14:38:35 2023 +0300

    Axe the experimental non-privileged chroot support from b4c832ca
    
    While the chroot call itself works nicely for a regular user with this,
    user/group mapping does not and cannot be made to work, because that
    requires a fork and we cannot very well fork the process from deep down
    here.
    
    Better to put the irrepairable thing out of its misery, users are far
    better of wrapping rpm with the unshare command instead.

The log shows that I can achieve the same goal by wrapping rpm command with unshare
After experimenting, I found solution:
Use following command:
unshare --mount --user --map-root-user rpm --root $(mktemp -d) -ivh your_rpm_name.rpm

You may also want to add --noplugins when running rpm in unshare environment.

@pmatilai pmatilai added this to RPM Nov 13, 2024
@github-project-automation github-project-automation bot moved this to Backlog in RPM Nov 13, 2024
@pmatilai
Copy link
Member

We could indeed better document the unshare usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

2 participants