NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/59293: install(1) leaves temp files if interrupted
>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);
Home |
Main Index |
Thread Index |
Old Index