original = fopen(passwd_path, "re");
if (original) {
- r = copy_rights(fileno(original), fileno(passwd));
+ /* Allow fallback path for when /proc is not mounted. On any normal system /proc will be
+ * mounted, but e.g. when 'dnf --installroot' is used, it might not be. There is no security
+ * relevance here, since the environment is ultimately trusted, and not requiring /proc makes
+ * it easier to depend on sysusers in packaging scripts and suchlike. */
+ r = copy_rights_with_fallback(fileno(original), fileno(passwd), passwd_tmp);
if (r < 0)
return log_debug_errno(r, "Failed to copy permissions from %s to %s: %m",
passwd_path, passwd_tmp);
original = fopen(shadow_path, "re");
if (original) {
- r = copy_rights(fileno(original), fileno(shadow));
+ r = copy_rights_with_fallback(fileno(original), fileno(shadow), shadow_tmp);
if (r < 0)
return log_debug_errno(r, "Failed to copy permissions from %s to %s: %m",
shadow_path, shadow_tmp);
original = fopen(group_path, "re");
if (original) {
- r = copy_rights(fileno(original), fileno(group));
+ r = copy_rights_with_fallback(fileno(original), fileno(group), group_tmp);
if (r < 0)
return log_debug_errno(r, "Failed to copy permissions from %s to %s: %m",
group_path, group_tmp);
if (original) {
struct sgrp *sg;
- r = copy_rights(fileno(original), fileno(gshadow));
+ r = copy_rights_with_fallback(fileno(original), fileno(gshadow), gshadow_tmp);
if (r < 0)
return log_debug_errno(r, "Failed to copy permissions from %s to %s: %m",
gshadow_path, gshadow_tmp);