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
(cherry picked from commit e8d027be6b)
This commit is contained in:
parent
2ce4f02182
commit
c0e07c93e8
2 changed files with 11 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -881,7 +881,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…
Add table
Reference in a new issue