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

mock: allow pre-creating users in chroot #1103

Merged
merged 3 commits into from
Jul 24, 2023

Commits on Jul 19, 2023

  1. mock: use shadow-utils on host, not in chroot

    The trick is that the {user,group}{add,del} commands can be executed
    on host with `--prefix <chroot>` nowadays.
    
    This commit removes one unnecessary dependency from the minimal
    buildroot, so the 'shadow-utils' are removed from all the configs.
    The good thing is also that we don't need a hacks around the potentially
    obsolescent '/sbin/useradd' utility (the `config_opts['useradd']`
    option) because since Mock v3 we support only RHEL 8 hosts and newer.
    
    The `_make_build_user()` was renamed to `_make_users()`, but the
    unnecessary side-effect of homedir cleanup was cut-out as a separate
    method `_cleanup_homedir` that needs to be called only before build, not
    for normal `mock --init` or `mock --shell`.  But we can otherwise
    re-create the users in-chroot for every single mock run to assure the
    UID/GID match the requirements.
    
    The `chown_home_dir` used to be called in some unclear conditions, but
    that call can not cause any harm and gives us guarantees that homedir is
    readable by `mockbuilder`.  We newly call it everytime.
    
    The `_setup_build_dirs()` is called a bit later for the `prebuild ==
    True` case to align with `not self.chroot_was_initialized`.  But this
    shouldn't have any real consequence (we call `chown_home_dir()` anyway).
    
    There's one different thing.  We we don't do `userdel -r` anymore for
    mockbuilder.  This shouldn't be needed, because when user is really
    re-created (prebuild == True), we already did `_cleanup_homedir()`.
    The other thing is that before we `useradd`, we already have `/builddir`
    pre-created -> so useradd doesn't create `.bashrc`, etc.  We can iterate
    on this, but it doesn't seem to be Mock's responsibility.
    
    Fixes: rpm-software-management#1102
    Closes: rpm-software-management#1103
    praiskup committed Jul 19, 2023
    Configuration menu
    Copy the full SHA
    8641d07 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    511f65e View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f8588fb View commit details
    Browse the repository at this point in the history