mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-12-18 05:53:36 +01:00
install: print directory name instead of file name if mkstemp fails
Printing the file name doesn't make sense since mkstemp failing means that the file wasn't created. Also add a test case for this. Co-authored-by: Jose Luis Duran <jlduran@gmail.com> Reviewed by: imp,jhb Pull Request: https://github.com/freebsd/freebsd-src/pull/1383
This commit is contained in:
parent
d4f9e32639
commit
e8d027be6b
@ -32,6 +32,15 @@ copy_to_empty_body() {
|
||||
install testf ""
|
||||
}
|
||||
|
||||
atf_test_case copy_to_nonexistent_dir
|
||||
copy_to_nonexistent_dir_body() {
|
||||
local dir="/nonexistent"
|
||||
|
||||
printf 'test\n123\r456\r\n789\0z' >testf
|
||||
atf_check -s not-exit:0 -e match:$dir": No such file or directory" \
|
||||
install testf $dir/testf
|
||||
}
|
||||
|
||||
copy_to_nonexistent_with_opts() {
|
||||
printf 'test\n123\r456\r\n789\0z' >testf
|
||||
atf_check install "$@" testf copyf
|
||||
@ -506,6 +515,7 @@ set_optional_exec_body()
|
||||
atf_init_test_cases() {
|
||||
atf_add_test_case copy_to_empty
|
||||
atf_add_test_case copy_to_nonexistent
|
||||
atf_add_test_case copy_to_nonexistent_dir
|
||||
atf_add_test_case copy_to_nonexistent_safe
|
||||
atf_add_test_case copy_to_nonexistent_comparing
|
||||
atf_add_test_case copy_to_nonexistent_safe_comparing
|
||||
|
@ -869,7 +869,7 @@ install(const char *from_name, const char *to_name, u_long fset, u_int flags)
|
||||
to_fd = create_tempfile(to_name, tempfile,
|
||||
sizeof(tempfile));
|
||||
if (to_fd < 0)
|
||||
err(EX_OSERR, "%s", tempfile);
|
||||
err(EX_OSERR, "%s", dirname(tempfile));
|
||||
if (!devnull) {
|
||||
if (dostrip) {
|
||||
stripped = strip(tempfile, to_fd, from_name,
|
||||
|
Loading…
Reference in New Issue
Block a user