From nobody Fri Nov 29 21:39:30 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Y0RQp6HCpz5flHH; Fri, 29 Nov 2024 21:39:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Y0RQp4rb4z44Vw; Fri, 29 Nov 2024 21:39:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732916370; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qNMuVXja8udZsBNvGVlMglbjDhL78hQbgZxWps8b2ms=; b=Ghr+orVD+nrp+kPiCNtUFNMJmH663kDFrf5kSgG2eQpzoYoH1YWlVWZ6tyzQLLePqu1l8d ioxF307HHc7eYFKANKKj5JFhxl68aqOaHl85jPgyWBOFxFYcfb/KGx0mIZhHQpDxEPicRZ Dw5D3yvXE9fLHoXJV5mmocrkIGnEit4FvzjJmKEdnz/6oAJdxaQXs0K7uiAF9YtRDZ9yEI obFa4l7qW8tqbK93qx7Fd5hSsvoQjMRgQn1Tn2pV3wwXivXY9wXTojWih6pQjI7Dnua17h +b60Lo5MgOYzL2vzi+2UfMEjePBmHtymxdEPW9/oZAtuasPoUothsnwFb6+vgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732916370; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=qNMuVXja8udZsBNvGVlMglbjDhL78hQbgZxWps8b2ms=; b=KGYNbkUrkf/jsYDdR7+EpqfYWwTmLaJICjIQ2eZDk3gYgPNPMLJ49t6BkZDtJKnj1ITOfA WxuL40Xhb4ZxfCE5JO9HgbNxOtsN2BkfoZSDUxf76aXvQV3IVe+C76Qj9/TNjvcZG9PGsy ZmHsxIXy5Xha0sdHLPUv2mj+XDDVGPcruHClVnBMHG5nPz7n5Dsj+KblwKZOA/ZW3F0+qb y8kDe7c2Yv6E7JtxPWQFblyGLbp0VYqvbLaY/U2NdJXo3c4LJ2E7CjV8f5zricV8m+6UiB lt+mYy+O8cqbINtewEz+KTXSXieHiBWm9Z2CsVlYnB16aaobxeO2+nyQvV6kdg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732916370; a=rsa-sha256; cv=none; b=qQr+VR/dX0Rxg8BI0dS+sJ9JsmV7M0e0js9GTINwMqx8fJUZ8tMKU30rAUv+7KRHVP43Fo ab0kGLT/GbLYnGQaDk0t6S2xXyQz8u1SkPSVv8VipaDO3DIagPOwrgbfoQGskYwgywirPq VWOR4NlA6vLXHgX8JGokp5uGSCecureSxED06PgmHqiELxZ1xm8GQPCZxIq/0ZFKfo4v+a sZP9X2svA7xxHZ258yJXy5o8MfL1aAyQpSlgk6UV70TFwc8pUHkrI5DkzizKTh1WdWmelO qhx6u+kB7McctS+H17Mk8emcrWBfUIzNBXsSxfkCTVRTl5Isu1+ZnRgT6F30Zg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Y0RQp4QJ0zfZG; Fri, 29 Nov 2024 21:39:30 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4ATLdUm3094215; Fri, 29 Nov 2024 21:39:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4ATLdULQ094212; Fri, 29 Nov 2024 21:39:30 GMT (envelope-from git) Date: Fri, 29 Nov 2024 21:39:30 GMT Message-Id: <202411292139.4ATLdULQ094212@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: e8d027be6b84 - main - install: print directory name instead of file name if mkstemp fails List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e8d027be6b84ac976eacd46283c286b934dd6f1f Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=e8d027be6b84ac976eacd46283c286b934dd6f1f commit e8d027be6b84ac976eacd46283c286b934dd6f1f Author: Ahmad Khalifa AuthorDate: 2024-08-14 14:26:04 +0000 Commit: Warner Losh 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 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,