Skip to content

Commit

Permalink
Completly reset all flags during operations on files with immutables …
Browse files Browse the repository at this point in the history
…flags
  • Loading branch information
bapt committed Jan 22, 2015
1 parent a31d851 commit 93d1647
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions libpkg/pkg_add.c
Expand Up @@ -262,12 +262,12 @@ do_extract(struct archive *a, struct archive_entry *ae, const char *location,
#ifdef HAVE_CHFLAGS
bool old = false;
if (aest->st_flags & NOCHANGESFLAGS)
chflags(rpath, aest->st_flags & ~NOCHANGESFLAGS);
chflags(rpath, 0);

if (lstat(pathname, &st) != -1) {
old = true;
if (st.st_flags & NOCHANGESFLAGS)
chflags(pathname, aest->st_flags & ~NOCHANGESFLAGS);
chflags(pathname, 0);
}
#endif

Expand Down
7 changes: 3 additions & 4 deletions libpkg/pkg_delete.c
Expand Up @@ -198,13 +198,12 @@ rmdir_p(struct pkgdb *db, struct pkg *pkg, char *dir, const char *prefix_r)
if (fstatat(pkg->rootfd, dir, &st, AT_SYMLINK_NOFOLLOW) != -1) {
if (st.st_flags & NOCHANGESFLAGS)
#ifdef HAVE_CHFLAGSAT
chflagsat(pkg->rootfd, dir,
st.st_flags & ~NOCHANGESFLAGS,
AT_SYMLINK_NOFOLLOW);
/* Disable all flags*/
chflagsat(pkg->rootfd, dir, 0, AT_SYMLINK_NOFOLLOW);
#else
fd = openat(pkg->rootfd, dir, O_NOFOLLOW);
if (fd > 0) {
fchflags(fd, st.st_flags & ~NOCHANGESFLAGS);
fchflags(fd, 0);
close(fd);
}
#endif
Expand Down

0 comments on commit 93d1647

Please sign in to comment.