assert(fdf >= 0);
assert(fdt >= 0);
+ /* Copies just the access mode (and not the ownership) from fdf to fdt */
+
if (fstat(fdf, &st) < 0)
return -errno;
return 0;
}
+int copy_rights(int fdf, int fdt) {
+ struct stat st;
+
+ assert(fdf >= 0);
+ assert(fdt >= 0);
+
+ /* Copies both access mode and ownership from fdf to fdt */
+
+ if (fstat(fdf, &st) < 0)
+ return -errno;
+
+ return fchmod_and_chown(fdt, st.st_mode & 07777, st.st_uid, st.st_gid);
+}
+
int copy_xattr(int fdf, int fdt) {
_cleanup_free_ char *names = NULL;
int ret = 0, r;
int copy_times(int fdf, int fdt, CopyFlags flags);
int copy_access(int fdf, int fdt);
+int copy_rights(int fdf, int fdt);
int copy_xattr(int fdf, int fdt);
return 0;
}
-int sync_rights(int from, int to) {
- struct stat st;
-
- if (fstat(from, &st) < 0)
- return -errno;
-
- return fchmod_and_chown(to, st.st_mode & 07777, st.st_uid, st.st_gid);
-}
-
int rename_and_apply_smack_floor_label(const char *from, const char *to) {
int r = 0;
if (rename(from, to) < 0)
int warn_file_is_world_accessible(const char *filename, struct stat *st, const char *unit, unsigned line);
-int sync_rights(int from, int to);
-
int rename_and_apply_smack_floor_label(const char *temp_path, const char *dest_path);
if (original) {
struct passwd *i;
- r = sync_rights(fileno(original), fileno(passwd));
+ r = copy_rights(fileno(original), fileno(passwd));
if (r < 0)
return r;
if (original) {
struct spwd *i;
- r = sync_rights(fileno(original), fileno(shadow));
+ r = copy_rights(fileno(original), fileno(shadow));
if (r < 0)
return r;
original = fopen(passwd_path, "re");
if (original) {
- r = sync_rights(fileno(original), fileno(passwd));
+ r = copy_rights(fileno(original), fileno(passwd));
if (r < 0)
return r;
original = fopen(shadow_path, "re");
if (original) {
- r = sync_rights(fileno(original), fileno(shadow));
+ r = copy_rights(fileno(original), fileno(shadow));
if (r < 0)
return r;
original = fopen(group_path, "re");
if (original) {
- r = sync_rights(fileno(original), fileno(group));
+ r = copy_rights(fileno(original), fileno(group));
if (r < 0)
return r;
if (original) {
struct sgrp *sg;
- r = sync_rights(fileno(original), fileno(gshadow));
+ r = copy_rights(fileno(original), fileno(gshadow));
if (r < 0)
return r;