git: e8d027be6b84 - main - install: print directory name instead of file name if mkstemp fails
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 29 Nov 2024 21:39:30 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=e8d027be6b84ac976eacd46283c286b934dd6f1f commit e8d027be6b84ac976eacd46283c286b934dd6f1f Author: Ahmad Khalifa <ahmadkhalifa570@gmail.com> AuthorDate: 2024-08-14 14:26:04 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-11-29 21:38:36 +0000 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 --- usr.bin/xinstall/tests/install_test.sh | 10 ++++++++++ usr.bin/xinstall/xinstall.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/usr.bin/xinstall/tests/install_test.sh b/usr.bin/xinstall/tests/install_test.sh index b35706521ec3..0f1f93ab4c63 100755 --- a/usr.bin/xinstall/tests/install_test.sh +++ b/usr.bin/xinstall/tests/install_test.sh @@ -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 diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index 2823a9040b7a..d0fcda340034 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -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,