Override and use a sane umask when performing pkg configuration.

Close #106
This commit is contained in:
Juan RP 2015-06-28 05:14:02 +02:00
parent dd5f57dfca
commit 22ffc14026
5 changed files with 48 additions and 1 deletions

4
NEWS
View File

@ -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

View File

@ -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");
}

View File

@ -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"}

View File

@ -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

View File

@ -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<<EOF
#!/bin/sh
export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
case "\$1" in
post)
touch file
;;
esac
EOF
chmod 755 pkg_A/INSTALL
cd repo
xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
cd ..
xbps-install -C empty.conf -r root --repository=$PWD/repo -yd A
atf_check_equal $? 0
perms=$(stat --format=%a root/file)
atf_check_equal $perms 644
}
atf_init_test_cases() {
atf_add_test_case filemode
}