unpack: apply correctly file permissions to existent files.

Will be backported to the 0.26.x branch.
This commit is contained in:
Juan RP
2013-10-30 12:02:16 +01:00
parent 0247b49f86
commit 747f250202
2 changed files with 26 additions and 21 deletions

View File

@ -459,27 +459,6 @@ unpack_archive(struct xbps_handle *xhp,
free(p2);
}
}
/*
* Check if current file mode differs from file mode
* in binpkg and apply perms if true.
*/
if (!force && file_exists && skip_extract &&
(archive_entry_mode(entry) != st.st_mode)) {
if (chmod(entry_pname,
archive_entry_mode(entry)) != 0) {
xbps_dbg_printf(xhp,
"%s: failed "
"to set perms %s to %s: %s\n",
pkgver, archive_entry_strmode(entry),
entry_pname,
strerror(errno));
rv = EINVAL;
goto out;
}
xbps_dbg_printf(xhp, "%s: entry %s changed file "
"mode to %s.\n", pkgver, entry_pname,
archive_entry_strmode(entry));
}
/*
* Check if current uid/gid differs from file in binpkg,
* and change permissions if true.
@ -503,6 +482,27 @@ unpack_archive(struct xbps_handle *xhp,
archive_entry_gid(entry));
}
}
/*
* Check if current file mode differs from file mode
* in binpkg and apply perms if true.
*/
if (!force && file_exists && skip_extract &&
(archive_entry_mode(entry) != st.st_mode)) {
if (chmod(entry_pname,
archive_entry_mode(entry)) != 0) {
xbps_dbg_printf(xhp,
"%s: failed "
"to set perms %s to %s: %s\n",
pkgver, archive_entry_strmode(entry),
entry_pname,
strerror(errno));
rv = EINVAL;
goto out;
}
xbps_dbg_printf(xhp, "%s: entry %s changed file "
"mode to %s.\n", pkgver, entry_pname,
archive_entry_strmode(entry));
}
if (!update && conf_file && file_exists && !skip_extract) {
/*