NetBSD Problem Report #59293

From www@netbsd.org  Sun Apr 13 22:36:00 2025
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 73E3B1A9239
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 13 Apr 2025 22:36:00 +0000 (UTC)
Message-Id: <20250413223559.14A0B1A923D@mollari.NetBSD.org>
Date: Sun, 13 Apr 2025 22:35:59 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: install(1) leaves temp files if interrupted
X-Send-Pr-Version: www-1.0

>Number:         59293
>Category:       bin
>Synopsis:       install(1) leaves temp files if interrupted
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 13 22:40:00 +0000 2025
>Originator:     Taylor R Campbell
>Release:        current, 10, 9, ...
>Organization:
The NetBSD Installati^C
>Environment:
>Description:
If install(1) is interrupted, it doesn't do anything to clean up its temp files, which can lead to checkflist failures in builds later:

=======  1 extra files in DESTDIR  =========
Files in DESTDIR but missing from flist.
File is obsolete or flist is out of date ?
------------------------------------------
./usr/include/evrpc.h.inst.UBsDVi
=========  end of 1 extra files  ===========

>How-To-Repeat:
1. install a bunch of files
2. ^C
3. check for *.inst.* temp files
>Fix:
Something like this:

static const char *cleanuppath;
static void
onsignal(int signo)
{
	int errno_save = errno;

	if (cleanuppath != NULL)
		(void)unlink(cleanuppath);

	errno = errno_save;
}

...
+	sigset_t mask, omask;
+
 	(void)snprintf(tmpl, sizeof(tmpl), "%s.inst.XXXXXX", to_name);
+	sigemptyset(&mask);
+	sigaddset(&mask, SIGHUP);
+	sigaddset(&mask, SIGINT);
+	sigaddset(&mask, SIGTERM);
+	sigprocmask(SIG_BLOCK, &mask, &omask);
	if (mktemp(tmpl) == NLL)
		err(EXIT_FAILURE, "%s: mktemp", tmpl);
+	cleanuppath = tmpl;
+	sigprocmask(SIG_SETMASK, &omask, NULL);
	ret = link(from_name, tmpl);
	...
+	sigprocmask(SIG_BLOCK, &mask, &omask);
+	cleanuppath = NULL;
+	sigprocmask(SIG_SETMASK, &omask, NULL);

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.