From 747f250202497813970d71fbc41104ba22af25c6 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 30 Oct 2013 12:02:16 +0100 Subject: [PATCH] unpack: apply correctly file permissions to existent files. Will be backported to the 0.26.x branch. --- NEWS | 5 +++++ lib/package_unpack.c | 42 +++++++++++++++++++++--------------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/NEWS b/NEWS index efd0f2c1..acf84e10 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,11 @@ xbps-0.27 (???): Starting from now on all remote repositories must be signed and verified. Local repos do not need to be signed and they will work as before. +xbps-0.26.2 (2013-10-30): + + * unpack: apply correctly permissions and mode to existent files if the those files + in the archive are modified compared to what it's currently on disk. + xbps-0.26.1 (2013-10-25): * xbps-uhelper: added new action "real-version" that only prints the version diff --git a/lib/package_unpack.c b/lib/package_unpack.c index caaf5f4e..e9b28b33 100644 --- a/lib/package_unpack.c +++ b/lib/package_unpack.c @@ -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) { /*