From 0fd83d47b7f4bddd1a42a88fe65b55d617590cb1 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 12 Sep 2016 16:34:55 -0400 Subject: [PATCH] passwd: Also clone subuid/subgid files These were added to shadow-utils in recent times (Fedora 25 e.g.) and like the other passwd files, shadow-utils opens them with `O_TRUNC`. (At some point we should patch it to do create-new-then-replace internally) Closes: https://github.com/projectatomic/rpm-ostree/issues/458 Closes: #459 Approved by: jlebon --- src/libpriv/rpmostree-passwd-util.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/libpriv/rpmostree-passwd-util.c b/src/libpriv/rpmostree-passwd-util.c index 8aebb63d..15855e72 100644 --- a/src/libpriv/rpmostree-passwd-util.c +++ b/src/libpriv/rpmostree-passwd-util.c @@ -1158,8 +1158,10 @@ rpmostree_generate_passwd_from_previous (OstreeRepo *repo, static const char *usrlib_pwgrp_files[] = { "passwd", "group" }; /* Lock/backup files that should not be in the base commit (TODO fix) */ static const char *pwgrp_lock_and_backup_files[] = { ".pwd.lock", "passwd-", "group-", - "shadow-", "gshadow-" }; -static const char *pwgrp_shadow_files[] = { "shadow", "gshadow" }; + "shadow-", "gshadow-", + "subuid-", "subgid-" }; +static const char *pwgrp_shadow_files[] = { "shadow", "gshadow", + "subuid", "subgid"}; static gboolean rootfs_has_usrlib_passwd (int rootfs_dfd, @@ -1245,9 +1247,21 @@ rpmostree_passwd_prepare_rpm_layering (int rootfs_dfd, */ for (guint i = 0; i < G_N_ELEMENTS (pwgrp_shadow_files); i++) { + struct stat stbuf; const char *file = pwgrp_shadow_files[i]; const char *src = glnx_strjoina ("usr/etc/", file); const char *tmp = glnx_strjoina ("usr/etc/", file, ".tmp"); + + if (fstatat (rootfs_dfd, src, &stbuf, AT_SYMLINK_NOFOLLOW) < 0) + { + if (errno != ENOENT) + { + glnx_set_error_from_errno (error); + return FALSE; + } + continue; + } + if (!glnx_file_copy_at (rootfs_dfd, src, NULL, rootfs_dfd, tmp, GLNX_FILE_COPY_OVERWRITE, cancellable, error))