diff --git a/NEWS b/NEWS index ed4845a8..36c5832a 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ xbps-0.47 (???): + * When executing pkg configuration, override the umask with sane defaults. + Otherwise files might be created with undesired permissions. + Fixes #106 (https://github.com/voidlinux/xbps/issues/106) + * libxbps: when resuming a file transfer (.part file exists), check if the requested offset matches the remote file size, and if that's true, just rename the file to finish it. The HTTP server might return a 413 diff --git a/lib/package_configure.c b/lib/package_configure.c index 00bcf06e..be8aeb5c 100644 --- a/lib/package_configure.c +++ b/lib/package_configure.c @@ -92,6 +92,7 @@ xbps_configure_pkg(struct xbps_handle *xhp, char *pkgname; int rv = 0; pkg_state_t state = 0; + mode_t myumask; assert(pkgver != NULL); @@ -131,6 +132,8 @@ xbps_configure_pkg(struct xbps_handle *xhp, } } + myumask = umask(022); + xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE, 0, pkgver, NULL); rv = xbps_pkg_exec_script(xhp, pkgd, "install-script", "post", update); @@ -139,6 +142,7 @@ xbps_configure_pkg(struct xbps_handle *xhp, errno, pkgver, "%s: [configure] INSTALL script failed to execute " "the post ACTION: %s", pkgver, strerror(rv)); + umask(myumask); return rv; } rv = xbps_set_pkg_state_dictionary(pkgd, XBPS_PKG_STATE_INSTALLED); @@ -146,11 +150,13 @@ xbps_configure_pkg(struct xbps_handle *xhp, xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_FAIL, rv, pkgver, "%s: [configure] failed to set state to installed: %s", pkgver, strerror(rv)); + umask(myumask); return rv; } if (rv == 0) xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_DONE, 0, pkgver, NULL); + umask(myumask); /* show install-msg if exists */ return xbps_cb_message(xhp, pkgd, "install-msg"); } diff --git a/tests/xbps/libxbps/shell/Kyuafile b/tests/xbps/libxbps/shell/Kyuafile index cec7361b..d9ea33c0 100644 --- a/tests/xbps/libxbps/shell/Kyuafile +++ b/tests/xbps/libxbps/shell/Kyuafile @@ -15,6 +15,7 @@ atf_test_program{name="scripts_test"} atf_test_program{name="incorrect_deps_test"} atf_test_program{name="vpkg_test"} atf_test_program{name="install_test"} +atf_test_program{name="configure_test"} atf_test_program{name="preserve_files_test"} atf_test_program{name="update_shlibs"} atf_test_program{name="update_hold"} diff --git a/tests/xbps/libxbps/shell/Makefile b/tests/xbps/libxbps/shell/Makefile index f65bb17c..d88daf52 100644 --- a/tests/xbps/libxbps/shell/Makefile +++ b/tests/xbps/libxbps/shell/Makefile @@ -5,7 +5,7 @@ TESTSSUBDIR = xbps/libxbps/shell TESTSHELL = conf_files_test issue6_test issue18_test issue20_test remove_test TESTSHELL+= replace_test installmode_test obsoletefiles_test TESTSHELL+= issue31_test scripts_test incorrect_deps_test -TESTSHELL+= vpkg_test install_test preserve_files_test +TESTSHELL+= vpkg_test install_test preserve_files_test configure_test TESTSHELL+= update_shlibs update_hold update_repolock cyclic_deps EXTRA_FILES = Kyuafile diff --git a/tests/xbps/libxbps/shell/configure_test.sh b/tests/xbps/libxbps/shell/configure_test.sh new file mode 100644 index 00000000..215e53c2 --- /dev/null +++ b/tests/xbps/libxbps/shell/configure_test.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env atf-sh + +atf_test_case filemode + +filemode_head() { + atf_set "descr" "Tests for pkg configuration: sane umask for file mode creation" +} + +filemode_body() { + umask 077 + mkdir -p repo pkg_A + cat >>pkg_A/INSTALL<