Fix clone_attr

This commit is contained in:
topjohnwu 2017-08-26 23:19:56 +08:00
parent a1e33c4d2f
commit ecfa4aafc1

View File

@ -379,12 +379,14 @@ int cp_afc(const char *source, const char *target) {
} }
void clone_attr(const char *source, const char *target) { void clone_attr(const char *source, const char *target) {
int sourcefd, targetfd; struct stat buf;
sourcefd = xopen(source, O_RDONLY); lstat(target, &buf);
targetfd = xopen(target, O_RDONLY); chmod(target, buf.st_mode & 0777);
fclone_attr(sourcefd, targetfd); chown(target, buf.st_uid, buf.st_gid);
close(sourcefd); char *con;
close(targetfd); lgetfilecon(source, &con);
lsetfilecon(target, con);
free(con);
} }
void fclone_attr(const int sourcefd, const int targetfd) { void fclone_attr(const int sourcefd, const int targetfd) {