Subject: bin/9249: rdist doesn't remove temporary file
To: None <gnats-bugs@gnats.netbsd.org>
From: Michael Eriksson T/K 2 <Michael.Eriksson@era-t.ericsson.se>
List: netbsd-bugs
Date: 01/19/2000 15:54:49
>Number: 9249
>Category: bin
>Synopsis: rdist doesn't remove temporary file
>Confidential: no
>Severity: serious
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Jan 19 15:54:01 2000
>Last-Modified:
>Originator: Michael Eriksson
>Organization:
Ericsson Radio Systems AB
>Release: -current of today
>Environment:
System: NetBSD abro 1.4P NetBSD 1.4P (SS5) #0: Wed Jan 12 03:46:30 MET 2000 eramore@abro:/usr/src/sys/arch/sparc/compile/SS5 sparc
>Description:
rdist leaves a temporary file in /tmp if it doesn't need to update any
files.
>How-To-Repeat:
Do an rdist to an already up-to-date directory.
>Fix:
The problem is from when mktemp() was changed into mkstemp(). The
latter creates the temp file, even if it isn't needed.
Patches:
Index: docmd.c
===================================================================
RCS file: /cvsroot/basesrc/usr.bin/rdist/docmd.c,v
retrieving revision 1.19
diff -u -r1.19 docmd.c
--- docmd.c 1999/04/20 07:53:02 1.19
+++ docmd.c 2000/01/19 23:31:12
@@ -203,7 +203,6 @@
if (sc->sc_type == NOTIFY)
notify(tempfile, rhost, sc->sc_args, 0);
if (!nflag) {
- (void) unlink(tempfile);
for (; ihead != NULL; ihead = ihead->nextp) {
free(ihead);
if ((opts & IGNLNKS) || ihead->count == 0)
@@ -439,8 +438,6 @@
for (sc = cmds; sc != NULL; sc = sc->sc_next)
if (sc->sc_type == NOTIFY)
notify(tempfile, NULL, sc->sc_args, lastmod);
- if (!nflag && !(options & VERIFY))
- (void) unlink(tempfile);
}
/*
Index: main.c
===================================================================
RCS file: /cvsroot/basesrc/usr.bin/rdist/main.c,v
retrieving revision 1.10
diff -u -r1.10 main.c
--- main.c 1999/04/20 07:53:02 1.10
+++ main.c 2000/01/19 23:31:13
@@ -212,6 +212,7 @@
if (iamremote) {
server();
+ unlink(tempfile);
exit(nerrs != 0);
}
@@ -226,6 +227,7 @@
fin = fopen(distfile, "r");
if(fin == NULL) {
perror(distfile ? distfile : "distfile");
+ unlink(tempfile);
exit(1);
}
}
@@ -234,6 +236,7 @@
docmds(dhosts, argc, argv);
}
+ unlink(tempfile);
exit(nerrs != 0);
}
@@ -282,7 +285,7 @@
tnl.n_name = cp;
hosts = expand(&tnl, E_ALL);
if (nerrs)
- exit(1);
+ return;
if (dest == NULL || *dest == '\0')
cmds = NULL;
>Audit-Trail:
>Unformatted: