sysusers: Move sync_rights and rename_and_apply_smack to basic
This commit is contained in:
@@ -1187,3 +1187,25 @@ int warn_file_is_world_accessible(const char *filename, struct stat *st, const c
|
||||
filename, st->st_mode & 07777);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sync_rights(FILE *from, const char *to) {
|
||||
struct stat st;
|
||||
|
||||
if (fstat(fileno(from), &st) < 0)
|
||||
return -errno;
|
||||
|
||||
return chmod_and_chown_unsafe(to, st.st_mode & 07777, st.st_uid, st.st_gid);
|
||||
}
|
||||
|
||||
int rename_and_apply_smack(const char *from, const char *to) {
|
||||
int r = 0;
|
||||
if (rename(from, to) < 0)
|
||||
return -errno;
|
||||
|
||||
#ifdef SMACK_RUN_LABEL
|
||||
r = mac_smack_apply(to, SMACK_ATTR_ACCESS, SMACK_FLOOR_LABEL);
|
||||
if (r < 0)
|
||||
return r;
|
||||
#endif
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -106,3 +106,7 @@ static inline int read_nul_string(FILE *f, size_t limit, char **ret) {
|
||||
int safe_fgetc(FILE *f, char *ret);
|
||||
|
||||
int warn_file_is_world_accessible(const char *filename, struct stat *st, const char *unit, unsigned line);
|
||||
|
||||
int sync_rights(FILE *from, const char *to);
|
||||
|
||||
int rename_and_apply_smack(const char *temp_path, const char *dest_path);
|
||||
|
||||
Reference in New Issue
Block a user