Merge pull request #234 from Duncaen/umask
Fix pkgdb and files plist permissions with restictive umask.
This commit is contained in:
commit
eae215e2a0
@ -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);
|
||||
}
|
||||
/*
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user