Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions src/libpriv/rpmostree-passwd-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1191,23 +1191,13 @@ rootfs_has_usrlib_passwd (int rootfs_dfd,
return TRUE;
}

/* We actually want RPM to inject to /usr/lib/passwd - we
* accomplish this by temporarily renaming /usr/lib/passwd -> /usr/etc/passwd
* (Which appears as /etc/passwd via our compatibility symlink in the bubblewrap
* script runner). We also copy the merge deployment's /etc/passwd to
* /usr/lib/passwd, so that %pre scripts are aware of newly added system users
* not in the tree's /usr/lib/passwd (through nss-altfiles in the container).
/* This may be leftover in the tree from an older version of rpm-ostree that
* didn't clean them up at compose time, and having them exist will mean
* rofiles-fuse will prevent useradd from opening it for write.
*/
gboolean
rpmostree_passwd_prepare_rpm_layering (int rootfs_dfd,
const char *merge_passwd_dir,
gboolean *out_have_passwd,
GCancellable *cancellable,
GError **error)
rpmostree_passwd_cleanup (int rootfs_dfd, GCancellable *cancellable, GError **error)
{
/* This may be leftover in the tree, and having it exist will mean
* rofiles-fuse will prevent useradd from opening it for write.
*/
for (guint i = 0; i < G_N_ELEMENTS (pwgrp_lock_and_backup_files); i++)
{
const char *file = pwgrp_lock_and_backup_files[i];
Expand All @@ -1223,6 +1213,26 @@ rpmostree_passwd_prepare_rpm_layering (int rootfs_dfd,
}
}

return TRUE;
}

/* We actually want RPM to inject to /usr/lib/passwd - we
* accomplish this by temporarily renaming /usr/lib/passwd -> /usr/etc/passwd
* (Which appears as /etc/passwd via our compatibility symlink in the bubblewrap
* script runner). We also copy the merge deployment's /etc/passwd to
* /usr/lib/passwd, so that %pre scripts are aware of newly added system users
* not in the tree's /usr/lib/passwd (through nss-altfiles in the container).
*/
gboolean
rpmostree_passwd_prepare_rpm_layering (int rootfs_dfd,
const char *merge_passwd_dir,
gboolean *out_have_passwd,
GCancellable *cancellable,
GError **error)
{
if (!rpmostree_passwd_cleanup (rootfs_dfd, cancellable, error))
return FALSE;

if (!rootfs_has_usrlib_passwd (rootfs_dfd, out_have_passwd, error))
return FALSE;
if (!*out_have_passwd)
Expand Down
4 changes: 4 additions & 0 deletions src/libpriv/rpmostree-passwd-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ rpmostree_generate_passwd_from_previous (OstreeRepo *repo,
GCancellable *cancellable,
GError **error);


gboolean
rpmostree_passwd_cleanup (int rootfs_dfd, GCancellable *cancellable, GError **error);

gboolean
rpmostree_passwd_prepare_rpm_layering (int rootfs_dfd,
const char *merge_passwd_dir,
Expand Down
4 changes: 4 additions & 0 deletions src/libpriv/rpmostree-postprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,7 @@ rpmostree_rootfs_prepare_links (int rootfs_fd,
*
* - Move /etc to /usr/etc
* - Clean up RPM db leftovers
* - Clean /usr/etc/passwd- backup files and such
*/
gboolean
rpmostree_rootfs_postprocess_common (int rootfs_fd,
Expand Down Expand Up @@ -1236,6 +1237,9 @@ rpmostree_rootfs_postprocess_common (int rootfs_fd,
}
}

if (!rpmostree_passwd_cleanup (rootfs_fd, cancellable, error))
goto out;

ret = TRUE;
out:
return ret;
Expand Down
3 changes: 3 additions & 0 deletions tests/compose-tests/test-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ cat > metadata.json <<EOF
EOF
runcompose --add-metadata-from-json metadata.json
ostree --repo=${repobuild} ls -R ${treeref} /usr/lib/ostree-boot > bootls.txt
if ostree --repo=${repobuild} ls -R ${treeref} /usr/etc/passwd-; then
assert_not_reached "Found /usr/etc/passwd- backup file in tree"
fi
echo "ok compose"

ostree --repo=${repobuild} show --print-metadata-key exampleos.gitrepo ${treeref} > meta.txt
Expand Down