From 44778867df2dd48bf420937489b00afeb92c0a81 Mon Sep 17 00:00:00 2001 From: Duncaen Date: Mon, 27 Feb 2017 18:24:46 +0100 Subject: [PATCH 1/3] lib/pkgdb.c: set a sane umask for pkgdb plist --- lib/pkgdb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/pkgdb.c b/lib/pkgdb.c index db974c0a..db487d81 100644 --- a/lib/pkgdb.c +++ b/lib/pkgdb.c @@ -216,6 +216,7 @@ int xbps_pkgdb_update(struct xbps_handle *xhp, bool flush, bool update) { xbps_dictionary_t pkgdb_storage; + mode_t prev_umask; static int cached_rv; int rv = 0; @@ -227,8 +228,12 @@ xbps_pkgdb_update(struct xbps_handle *xhp, bool flush, bool update) if (pkgdb_storage == NULL || !xbps_dictionary_equals(xhp->pkgdb, pkgdb_storage)) { /* flush dictionary to storage */ - if (!xbps_dictionary_externalize_to_file(xhp->pkgdb, xhp->pkgdb_plist)) + prev_umask = umask(022); + if (!xbps_dictionary_externalize_to_file(xhp->pkgdb, xhp->pkgdb_plist)) { + umask(prev_umask); return errno; + } + umask(prev_umask); } if (pkgdb_storage) xbps_object_release(pkgdb_storage); From 332fbc195a2600e74a294511e093f03d2271175a Mon Sep 17 00:00:00 2001 From: Duncaen Date: Mon, 27 Feb 2017 18:05:27 +0100 Subject: [PATCH 2/3] lib/package_unpack.c: set a sane umask for pkg files plists --- lib/package_unpack.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/package_unpack.c b/lib/package_unpack.c index 23d48fb3..b1674053 100644 --- a/lib/package_unpack.c +++ b/lib/package_unpack.c @@ -461,15 +461,19 @@ unpack_archive(struct xbps_handle *xhp, * Externalize binpkg files.plist to disk, if not empty. */ if (xbps_dictionary_count(binpkg_filesd)) { + mode_t prev_umask; + prev_umask = umask(022); buf = xbps_xasprintf("%s/.%s-files.plist", xhp->metadir, pkgname); if (!xbps_dictionary_externalize_to_file(binpkg_filesd, buf)) { rv = errno; + umask(prev_umask); free(buf); xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL, rv, pkgver, "%s: [unpack] failed to externalize pkg " "pkg metadata files: %s", pkgver, strerror(rv)); goto out; } + umask(prev_umask); free(buf); } /* From e797936c4083e0efa7a730c842621b325eaa4610 Mon Sep 17 00:00:00 2001 From: Duncaen Date: Mon, 27 Feb 2017 18:50:19 +0100 Subject: [PATCH 3/3] lib/repo_sync.c: sane umask for repodata files --- lib/repo_sync.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/repo_sync.c b/lib/repo_sync.c index bf303dd3..49767691 100644 --- a/lib/repo_sync.c +++ b/lib/repo_sync.c @@ -74,6 +74,7 @@ xbps_get_remote_repo_string(const char *uri) int HIDDEN xbps_repo_sync(struct xbps_handle *xhp, const char *uri) { + mode_t prev_umask; const char *arch, *fetchstr = NULL; char *repodata, *lrepodir, *uri_fixedp; int rv = 0; @@ -130,6 +131,7 @@ xbps_repo_sync(struct xbps_handle *xhp, const char *uri) /* * Download plist index file from repository. */ + prev_umask = umask(022); if ((rv = xbps_fetch_file(xhp, repodata, NULL)) == -1) { /* reposync error cb */ fetchstr = xbps_fetch_error_string(); @@ -139,6 +141,7 @@ xbps_repo_sync(struct xbps_handle *xhp, const char *uri) repodata, fetchstr ? fetchstr : strerror(errno)); } else if (rv == 1) rv = 0; + umask(prev_umask); free(repodata);