From c3f6f485a3deb23991d17d67a7104a6325ac4303 Mon Sep 17 00:00:00 2001 From: Duncaen Date: Fri, 14 Jun 2019 21:07:48 +0200 Subject: [PATCH 1/2] lib/repo_sync.c: set umask before creating repo cache directories --- lib/repo_sync.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/repo_sync.c b/lib/repo_sync.c index 49767691..dc161239 100644 --- a/lib/repo_sync.c +++ b/lib/repo_sync.c @@ -103,12 +103,14 @@ xbps_repo_sync(struct xbps_handle *xhp, const char *uri) /* * Create repodir in metadir. */ + prev_umask = umask(022); if ((rv = xbps_mkpath(lrepodir, 0755)) == -1) { if (errno != EEXIST) { xbps_set_cb_state(xhp, XBPS_STATE_REPOSYNC_FAIL, errno, NULL, "[reposync] failed " "to create repodir `%s': %s", lrepodir, strerror(errno)); + umask(prev_umask); free(lrepodir); return rv; } @@ -117,6 +119,7 @@ xbps_repo_sync(struct xbps_handle *xhp, const char *uri) xbps_set_cb_state(xhp, XBPS_STATE_REPOSYNC_FAIL, errno, NULL, "[reposync] failed to change dir to repodir `%s': %s", lrepodir, strerror(errno)); + umask(prev_umask); free(lrepodir); return -1; } @@ -131,7 +134,6 @@ 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(); From 008e1ed9010d5e66afeb6f5898e771374d905dd2 Mon Sep 17 00:00:00 2001 From: Duncaen Date: Fri, 14 Jun 2019 21:08:36 +0200 Subject: [PATCH 2/2] lib/external/fexec.c: run child with 022 umask --- lib/external/fexec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/external/fexec.c b/lib/external/fexec.c index 00eff213..340e703a 100644 --- a/lib/external/fexec.c +++ b/lib/external/fexec.c @@ -69,6 +69,7 @@ pfcexec(struct xbps_handle *xhp, const char *file, const char **argv) } } } + umask(022); (void)execv(file, __UNCONST(argv)); _exit(errno); /* NOTREACHED */