From 44778867df2dd48bf420937489b00afeb92c0a81 Mon Sep 17 00:00:00 2001 From: Duncaen Date: Mon, 27 Feb 2017 18:24:46 +0100 Subject: [PATCH] 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);