git: c0e07c93e858 - stable/14 - install: print directory name instead of file name if mkstemp fails
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 26 Mar 2025 01:29:06 UTC
The branch stable/14 has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=c0e07c93e858136c6b10d26810e9405e79ad2fb5
commit c0e07c93e858136c6b10d26810e9405e79ad2fb5
Author: Ahmad Khalifa <ahmadkhalifa570@gmail.com>
AuthorDate: 2024-08-14 14:26:04 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-03-26 01:28:39 +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
(cherry picked from commit e8d027be6b84ac976eacd46283c286b934dd6f1f)
---
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 4d771186781b..4942d57b1f9c 100644
--- a/usr.bin/xinstall/xinstall.c
+++ b/usr.bin/xinstall/xinstall.c
@@ -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,