Commit 1ca9ec38 authored by topjohnwu's avatar topjohnwu

Fix typo in cloning attribute

parent 9522255e
...@@ -369,14 +369,12 @@ int rm_rf(const char *target) { ...@@ -369,14 +369,12 @@ int rm_rf(const char *target) {
} }
void clone_attr(const char *source, const char *target) { void clone_attr(const char *source, const char *target) {
struct stat buf; int sourcefd, targetfd;
xstat(source, &buf); sourcefd = xopen(source, O_RDONLY);
chmod(target, buf.st_mode & 0777); targetfd = xopen(target, O_RDONLY);
chown(target, buf.st_uid, buf.st_gid); fclone_attr(sourcefd, targetfd);
char *con; close(sourcefd);
lgetfilecon(source, &con); close(targetfd);
lsetfilecon(target, con);
free(con);
} }
void fclone_attr(const int sourcefd, const int targetfd) { void fclone_attr(const int sourcefd, const int targetfd) {
...@@ -386,7 +384,7 @@ void fclone_attr(const int sourcefd, const int targetfd) { ...@@ -386,7 +384,7 @@ void fclone_attr(const int sourcefd, const int targetfd) {
fchown(targetfd, buf.st_uid, buf.st_gid); fchown(targetfd, buf.st_uid, buf.st_gid);
char *con; char *con;
fgetfilecon(sourcefd, &con); fgetfilecon(sourcefd, &con);
fsetfilecon(sourcefd, con); fsetfilecon(targetfd, con);
free(con); free(con);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment