Add an option --chroot to tar. Causes it to chroot(".") before doing
an extract. With -h this will cause existing absolute symlinks to be treated as relative to the current directory. Helps sysinst handle existing symlinks in the target system. Remove 'L' from the usage (got spilt into 'h' and 'H' many moons ago) Add 'S' to usage, and put into correct place in options list.
This commit is contained in:
parent
ccd16ca6dc
commit
8317fe1276
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ar_subs.c,v 1.32 2004/10/10 22:03:08 christos Exp $ */
|
||||
/* $NetBSD: ar_subs.c,v 1.33 2004/10/17 18:49:55 dsl Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992 Keith Muller.
|
||||
@ -42,7 +42,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)ar_subs.c 8.2 (Berkeley) 4/18/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: ar_subs.c,v 1.32 2004/10/10 22:03:08 christos Exp $");
|
||||
__RCSID("$NetBSD: ar_subs.c,v 1.33 2004/10/17 18:49:55 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -198,6 +198,10 @@ extract(void)
|
||||
return;
|
||||
|
||||
now = time((time_t *)NULL);
|
||||
if (do_chroot && fchroot(cwdfd) != 0) {
|
||||
syswarn(1, errno, "Can't fchroot to \".\"");
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* When we are doing interactive rename, we store the mapping of names
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.h,v 1.45 2004/09/22 15:03:18 christos Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.46 2004/10/17 18:49:55 dsl Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992 Keith Muller.
|
||||
@ -203,6 +203,7 @@ int opt_add(const char *);
|
||||
int bad_opt(void);
|
||||
int mkpath(char *);
|
||||
char *chdname;
|
||||
int do_chroot;
|
||||
|
||||
/*
|
||||
* pat_rep.c
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: options.c,v 1.79 2004/10/10 22:05:26 christos Exp $ */
|
||||
/* $NetBSD: options.c,v 1.80 2004/10/17 18:49:55 dsl Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992 Keith Muller.
|
||||
@ -42,7 +42,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: options.c,v 1.79 2004/10/10 22:05:26 christos Exp $");
|
||||
__RCSID("$NetBSD: options.c,v 1.80 2004/10/17 18:49:55 dsl Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -123,6 +123,7 @@ static int getline_error;
|
||||
#define OPT_INSECURE 14
|
||||
#define OPT_STRICT 15
|
||||
#define OPT_SPARSE 16
|
||||
#define OPT_CHROOT 17
|
||||
|
||||
/*
|
||||
* Format specific routine table - MUST BE IN SORTED ORDER BY NAME
|
||||
@ -724,6 +725,7 @@ struct option tar_longopts[] = {
|
||||
{ "directory", required_argument, 0, 'C' },
|
||||
{ "to-stdout", no_argument, 0, 'O' },
|
||||
{ "absolute-paths", no_argument, 0, 'P' },
|
||||
{ "sparse", no_argument, 0, 'S' },
|
||||
{ "files-from", required_argument, 0, 'T' },
|
||||
{ "exclude-from", required_argument, 0, 'X' },
|
||||
{ "compress", no_argument, 0, 'Z' },
|
||||
@ -742,7 +744,8 @@ struct option tar_longopts[] = {
|
||||
OPT_INSECURE },
|
||||
{ "exclude", required_argument, 0,
|
||||
OPT_EXCLUDE },
|
||||
{ "sparse", no_argument, 0, 'S' },
|
||||
{ "chroot", no_argument, 0,
|
||||
OPT_CHROOT },
|
||||
#if 0 /* Not implemented */
|
||||
{ "catenate", no_argument, 0, 'A' }, /* F */
|
||||
{ "concatenate", no_argument, 0, 'A' }, /* F */
|
||||
@ -1064,6 +1067,9 @@ tar_options(int argc, char **argv)
|
||||
if (tar_gnutar_minus_minus_exclude(optarg) != 0)
|
||||
tar_usage();
|
||||
break;
|
||||
case OPT_CHROOT:
|
||||
do_chroot = 1;
|
||||
break;
|
||||
default:
|
||||
tar_usage();
|
||||
break;
|
||||
@ -2003,7 +2009,7 @@ pax_usage(void)
|
||||
void
|
||||
tar_usage(void)
|
||||
{
|
||||
(void)fputs("usage: tar [-]{crtux}[-befhjlmopqvwzHLOPXZ014578] [archive] "
|
||||
(void)fputs("usage: tar [-]{crtux}[-befhjlmopqvwzHOPSXZ014578] [archive] "
|
||||
"[blocksize]\n"
|
||||
" [-C directory] [-T file] [-s replstr] "
|
||||
"[file ...]\n", stderr);
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: tar.1,v 1.17 2004/09/27 07:41:54 wiz Exp $
|
||||
.\" $NetBSD: tar.1,v 1.18 2004/10/17 18:49:55 dsl Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 1996 SigmaSoft, Th. Lockert
|
||||
.\" All rights reserved.
|
||||
@ -34,7 +34,7 @@
|
||||
.Sh SYNOPSIS
|
||||
.Nm tar
|
||||
.Sm off
|
||||
.Oo \&- Oc {crtux} Op Fl befhjklmopqvwzHLOPSXZ014578
|
||||
.Oo \&- Oc {crtux} Op Fl befhjklmopqvwzHOPSXZ014578
|
||||
.Sm on
|
||||
.Op Ar archive
|
||||
.Op Ar blocksize
|
||||
@ -235,6 +235,14 @@ Compress archive using compress.
|
||||
Do not enable GNU tar extensions such as long filenames and long link names.
|
||||
.It Fl -atime-preserve
|
||||
Preserve file access times.
|
||||
.It Fl -chroot
|
||||
.Fn chroot
|
||||
to the current directory before extracting files.
|
||||
Use with
|
||||
.Fl x
|
||||
and
|
||||
.Fl h
|
||||
to make absolute symlinks be relative to the current directory.
|
||||
.It Fl -unlink
|
||||
Ignored, only accepted for compatibility with other
|
||||
.Nm
|
||||
|
Loading…
Reference in New Issue
Block a user