Use a sane umask(2) before unpacking package files.

See https://github.com/voidlinux/void-packages/issues/835
for more information.
This commit is contained in:
Juan RP 2015-01-11 11:01:09 +01:00
parent b23855f692
commit 91b7b2fd5a
2 changed files with 10 additions and 1 deletions

3
NEWS
View File

@ -1,5 +1,8 @@
xbps-0.44 (???): xbps-0.44 (???):
* libxbps: use a sane umask(2) while unpacking package files from
binary packages (see https://github.com/voidlinux/void-packages/issues/835)
* xbps-dgraph(8): the -m/--metadata option (default mode) is now properly * xbps-dgraph(8): the -m/--metadata option (default mode) is now properly
accepted. Regression introduced in 0.42. accepted. Regression introduced in 0.42.

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2008-2014 Juan Romero Pardines. * Copyright (c) 2008-2015 Juan Romero Pardines.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -502,6 +502,7 @@ xbps_unpack_binary_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkg_repod)
const char *pkgver; const char *pkgver;
char *bpkg = NULL; char *bpkg = NULL;
int pkg_fd = -1, rv = 0; int pkg_fd = -1, rv = 0;
mode_t myumask;
assert(xbps_object_type(pkg_repod) == XBPS_TYPE_DICTIONARY); assert(xbps_object_type(pkg_repod) == XBPS_TYPE_DICTIONARY);
@ -529,6 +530,8 @@ xbps_unpack_binary_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkg_repod)
archive_read_support_compression_xz(ar); archive_read_support_compression_xz(ar);
archive_read_support_format_tar(ar); archive_read_support_format_tar(ar);
myumask = umask(022);
pkg_fd = open(bpkg, O_RDONLY|O_CLOEXEC); pkg_fd = open(bpkg, O_RDONLY|O_CLOEXEC);
if (pkg_fd == -1) { if (pkg_fd == -1) {
rv = errno; rv = errno;
@ -594,5 +597,8 @@ out:
if (bpkg) if (bpkg)
free(bpkg); free(bpkg);
/* restore */
umask(myumask);
return rv; return rv;
} }