diff options
-rw-r--r-- | bin/pax/cpio.1 | 9 | ||||
-rw-r--r-- | bin/pax/extern.h | 4 | ||||
-rw-r--r-- | bin/pax/pax.1 | 9 | ||||
-rw-r--r-- | bin/pax/pax.c | 28 | ||||
-rw-r--r-- | bin/pax/pax.h | 9 | ||||
-rw-r--r-- | bin/pax/tables.c | 35 | ||||
-rw-r--r-- | bin/pax/tar.1 | 12 |
7 files changed, 73 insertions, 33 deletions
diff --git a/bin/pax/cpio.1 b/bin/pax/cpio.1 index f6e30f3d069..0250e9eead0 100644 --- a/bin/pax/cpio.1 +++ b/bin/pax/cpio.1 @@ -27,7 +27,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $OpenBSD: cpio.1,v 1.14 2000/11/10 17:52:02 aaron Exp $ +.\" $OpenBSD: cpio.1,v 1.15 2001/02/07 19:04:13 millert Exp $ .\" .Dd February 16, 1997 .Dt CPIO 1 @@ -276,6 +276,13 @@ or error, .Nm may have only partially created the archive which may violate the specific archive format specification. +.Sh ENVIRONMENT +The following environment variables affect the execution of +.Nm cpio : +.Bl -tag -width Fl +.It Ev TMPDIR +Path in which to store temporary files. +.El .Sh SEE ALSO .Xr pax 1 , .Xr tar 1 diff --git a/bin/pax/extern.h b/bin/pax/extern.h index fba5f842d0a..71802cb5a98 100644 --- a/bin/pax/extern.h +++ b/bin/pax/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.16 2000/06/09 16:37:54 espie Exp $ */ +/* $OpenBSD: extern.h,v 1.17 2001/02/07 19:04:14 millert Exp $ */ /* $NetBSD: extern.h,v 1.5 1996/03/26 23:54:16 mrg Exp $ */ /*- @@ -238,6 +238,8 @@ extern char *dirptr; extern char *ltmfrmt; extern char *argv0; extern FILE *listf; +extern char *tempfile; +extern char *tempbase; int main __P((int, char **)); void sig_cleanup __P((int)); diff --git a/bin/pax/pax.1 b/bin/pax/pax.1 index 9831cb9376b..e6cfe7514dd 100644 --- a/bin/pax/pax.1 +++ b/bin/pax/pax.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: pax.1,v 1.25 2000/11/09 23:58:55 aaron Exp $ +.\" $OpenBSD: pax.1,v 1.26 2001/02/07 19:04:14 millert Exp $ .\" $NetBSD: pax.1,v 1.3 1995/03/21 09:07:37 cgd Exp $ .\" .\" Copyright (c) 1992 Keith Muller. @@ -1142,6 +1142,13 @@ a diagnostic message is written to standard error and when .Nm completes it will exit with a non-zero exit status. +.Sh ENVIRONMENT +The following environment variables affect the execution of +.Nm pax : +.Bl -tag -width Fl +.It Ev TMPDIR +Path in which to store temporary files. +.El .Sh SEE ALSO .Xr cpio 1 , .Xr tar 1 diff --git a/bin/pax/pax.c b/bin/pax/pax.c index f8e614711fe..60d27c6e00f 100644 --- a/bin/pax/pax.c +++ b/bin/pax/pax.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pax.c,v 1.15 2000/06/09 16:37:54 espie Exp $ */ +/* $OpenBSD: pax.c,v 1.16 2001/02/07 19:04:14 millert Exp $ */ /* $NetBSD: pax.c,v 1.5 1996/03/26 23:54:20 mrg Exp $ */ /*- @@ -48,7 +48,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)pax.c 8.2 (Berkeley) 4/18/94"; #else -static char rcsid[] = "$OpenBSD: pax.c,v 1.15 2000/06/09 16:37:54 espie Exp $"; +static char rcsid[] = "$OpenBSD: pax.c,v 1.16 2001/02/07 19:04:14 millert Exp $"; #endif #endif /* not lint */ @@ -65,6 +65,7 @@ static char rcsid[] = "$OpenBSD: pax.c,v 1.15 2000/06/09 16:37:54 espie Exp $"; #include <errno.h> #include <err.h> #include <fcntl.h> +#include <paths.h> #include "pax.h" #include "extern.h" static int gen_init __P((void)); @@ -108,6 +109,8 @@ char *ltmfrmt; /* -v locale time format (if any) */ char *argv0; /* root of argv[0] */ sigset_t s_mask; /* signal mask for cleanup critical sect */ FILE *listf = stderr; /* file pointer to print file list to */ +char *tempfile; /* tempfile to use for mkstemp(3) */ +char *tempbase; /* basename of tempfile to use for mkstemp(3) */ /* * PAX - Portable Archive Interchange @@ -239,6 +242,9 @@ main(argc, argv) char **argv; #endif { + char *tmpdir; + size_t tdlen; + /* * Keep a reference to cwd, so we can always come back home. */ @@ -249,6 +255,24 @@ main(argc, argv) } /* + * Where should we put temporary files? + */ + if ((tmpdir = getenv("TMPDIR")) == NULL || *tmpdir == '\0') + tmpdir = _PATH_TMP; + tdlen = strlen(tmpdir); + while(tdlen > 0 && tmpdir[tdlen - 1] == '/') + tdlen--; + tempfile = malloc(tdlen + 1 + sizeof(_TFILE_BASE)); + if (tempfile == NULL) { + paxwarn(1, "Cannot allocate memory for temp file name."); + return(exit_val); + } + if (tdlen) + memcpy(tempfile, tmpdir, tdlen); + tempbase = tempfile + tdlen; + *tempbase++ = '/'; + + /* * parse options, determine operational mode, general init */ options(argc, argv); diff --git a/bin/pax/pax.h b/bin/pax/pax.h index bdf00a47dab..d049666dd35 100644 --- a/bin/pax/pax.h +++ b/bin/pax/pax.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pax.h,v 1.9 1997/07/23 19:15:58 kstailey Exp $ */ +/* $OpenBSD: pax.h,v 1.10 2001/02/07 19:04:14 millert Exp $ */ /* $NetBSD: pax.h,v 1.3 1995/03/21 09:07:41 cgd Exp $ */ /*- @@ -238,6 +238,7 @@ typedef struct oplist { /* * General Defines */ -#define HEX 16 -#define OCT 8 -#define _PAX_ 1 +#define HEX 16 +#define OCT 8 +#define _PAX_ 1 +#define _TFILE_BASE "paxXXXXXXXXXX" diff --git a/bin/pax/tables.c b/bin/pax/tables.c index 6f9a1d8484b..5656f20bcb8 100644 --- a/bin/pax/tables.c +++ b/bin/pax/tables.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tables.c,v 1.11 1999/04/29 12:59:03 aaron Exp $ */ +/* $OpenBSD: tables.c,v 1.12 2001/02/07 19:04:14 millert Exp $ */ /* $NetBSD: tables.c,v 1.4 1995/03/21 09:07:45 cgd Exp $ */ /*- @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)tables.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$OpenBSD: tables.c,v 1.11 1999/04/29 12:59:03 aaron Exp $"; +static char rcsid[] = "$OpenBSD: tables.c,v 1.12 2001/02/07 19:04:14 millert Exp $"; #endif #endif /* not lint */ @@ -364,7 +364,6 @@ int ftime_start() #endif { - char *pt; if (ftab != NULL) return(0); @@ -377,18 +376,13 @@ ftime_start() * get random name and create temporary scratch file, unlink name * so it will get removed on exit */ - if ((pt = strdup("/tmp/paxXXXXXXXXXX")) == NULL) { - paxwarn(1, "Cannot allocate memory for temporary file name"); - (void)free((char *)ftab); + memcpy(tempbase, _TFILE_BASE, sizeof(_TFILE_BASE)); + if ((ffd = mkstemp(tempfile)) < 0) { + syswarn(1, errno, "Unable to create temporary file: %s", + tempfile); return(-1); } - if ((ffd = mkstemp(pt)) < 0) { - syswarn(1, errno, "Unable to create temporary file: %s", pt); - free(pt); - return(-1); - } - (void)unlink(pt); - free(pt); + (void)unlink(tempfile); return(0); } @@ -1218,7 +1212,6 @@ int dir_start() #endif { - char *pt; if (dirfd != -1) return(0); @@ -1226,17 +1219,13 @@ dir_start() /* * unlink the file so it goes away at termination by itself */ - if ((pt = strdup("/tmp/paxXXXXXXXXXX")) == NULL) { - paxwarn(1, "Cannot allocate memory for temporary filename"); - return(-1); - } - if ((dirfd = mkstemp(pt)) >= 0) { - (void)unlink(pt); - free(pt); + memcpy(tempbase, _TFILE_BASE, sizeof(_TFILE_BASE)); + if ((dirfd = mkstemp(tempfile)) >= 0) { + (void)unlink(tempfile); return(0); } - paxwarn(1, "Unable to create temporary file for directory times: %s", pt); - free(pt); + paxwarn(1, "Unable to create temporary file for directory times: %s", + tempfile); return(-1); } diff --git a/bin/pax/tar.1 b/bin/pax/tar.1 index 8714ebcf3df..87cd8dd29d2 100644 --- a/bin/pax/tar.1 +++ b/bin/pax/tar.1 @@ -27,7 +27,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $OpenBSD: tar.1,v 1.29 2001/02/05 00:29:46 deraadt Exp $ +.\" $OpenBSD: tar.1,v 1.30 2001/02/07 19:04:15 millert Exp $ .\" .Dd June 11, 1996 .Dt TAR 1 @@ -262,6 +262,16 @@ specific archive format specification. .It Pa /dev/rst0 default archive name .El +.Sh ENVIRONMENT +The following environment variables affect the execution of +.Nm tar : +.Bl -tag -width Fl +.It Ev TMPDIR +Path in which to store temporary files. +.It Ev TAPE +Default tape device to use instead of +.Pa /dev/rst0 . +.El .Sh SEE ALSO .Xr cpio 1 , .Xr pax 1 |