diff options
author | 2010-12-02 04:08:27 +0000 | |
---|---|---|
committer | 2010-12-02 04:08:27 +0000 | |
commit | 5e460854830892cd08cf23335ed22f23e17df3d6 (patch) | |
tree | f2f5f817cddc697461bac5af200499066046e20b | |
parent | Bring lang/ruby module documentation up to date. (diff) | |
download | wireguard-openbsd-5e460854830892cd08cf23335ed22f23e17df3d6.tar.xz wireguard-openbsd-5e460854830892cd08cf23335ed22f23e17df3d6.zip |
a -N option for tar that uses numeric only IDs, useful for cross system
tar file manipulation. with advice from guenther and jmc.
-rw-r--r-- | bin/pax/extern.h | 3 | ||||
-rw-r--r-- | bin/pax/options.c | 12 | ||||
-rw-r--r-- | bin/pax/pax.c | 3 | ||||
-rw-r--r-- | bin/pax/tar.1 | 11 | ||||
-rw-r--r-- | bin/pax/tar.c | 15 |
5 files changed, 29 insertions, 15 deletions
diff --git a/bin/pax/extern.h b/bin/pax/extern.h index acdfafca2d2..bf990b50397 100644 --- a/bin/pax/extern.h +++ b/bin/pax/extern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: extern.h,v 1.33 2008/05/06 06:54:28 henning Exp $ */ +/* $OpenBSD: extern.h,v 1.34 2010/12/02 04:08:27 tedu Exp $ */ /* $NetBSD: extern.h,v 1.5 1996/03/26 23:54:16 mrg Exp $ */ /*- @@ -225,6 +225,7 @@ extern int vflag; extern int Dflag; extern int Hflag; extern int Lflag; +extern int Nflag; extern int Xflag; extern int Yflag; extern int Zflag; diff --git a/bin/pax/options.c b/bin/pax/options.c index df51ed57d02..28ace9b827d 100644 --- a/bin/pax/options.c +++ b/bin/pax/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.73 2009/11/13 17:22:13 deraadt Exp $ */ +/* $OpenBSD: options.c,v 1.74 2010/12/02 04:08:27 tedu Exp $ */ /* $NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $ */ /*- @@ -620,7 +620,7 @@ tar_options(int argc, char **argv) * process option flags */ while ((c = getoldopt(argc, argv, - "b:cef:hjmopqruts:vwxzBC:HI:LOPXZ014578")) != -1) { + "b:cef:hjmopqruts:vwxzBC:HI:LNOPXZ014578")) != -1) { switch (c) { case 'b': /* @@ -785,6 +785,10 @@ tar_options(int argc, char **argv) */ Lflag = 1; break; + case 'N': + /* numeric uid and gid only */ + Nflag = 1; + break; case 'P': /* * do not remove leading '/' from pathnames @@ -1577,10 +1581,10 @@ void tar_usage(void) { (void)fputs( - "usage: tar {crtux}[014578befHhjLmOoPpqsvwXZz]\n" + "usage: tar {crtux}[014578befHhjLmNOoPpqsvwXZz]\n" " [blocking-factor | archive | replstr] [-C directory] [-I file]\n" " [file ...]\n" - " tar {-crtux} [-014578eHhjLmOoPpqvwXZz] [-b blocking-factor]\n" + " tar {-crtux} [-014578eHhjLmNOoPpqvwXZz] [-b blocking-factor]\n" " [-C directory] [-f archive] [-I file] [-s replstr] [file ...]\n", stderr); exit(1); diff --git a/bin/pax/pax.c b/bin/pax/pax.c index 5bbf6cc70e2..ab6dbc6955d 100644 --- a/bin/pax/pax.c +++ b/bin/pax/pax.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pax.c,v 1.30 2009/10/28 20:30:41 guenther Exp $ */ +/* $OpenBSD: pax.c,v 1.31 2010/12/02 04:08:27 tedu Exp $ */ /* $NetBSD: pax.c,v 1.5 1996/03/26 23:54:20 mrg Exp $ */ /*- @@ -74,6 +74,7 @@ int vflag; /* produce verbose output */ int Dflag; /* same as uflag except inode change time */ int Hflag; /* follow command line symlinks (write only) */ int Lflag; /* follow symlinks when writing */ +int Nflag; /* only use numeric uid and gid */ int Xflag; /* archive files with same device id only */ int Yflag; /* same as Dflag except after name mode */ int Zflag; /* same as uflag except after name mode */ diff --git a/bin/pax/tar.1 b/bin/pax/tar.1 index 629b4789e1c..ef7246fbc37 100644 --- a/bin/pax/tar.1 +++ b/bin/pax/tar.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tar.1,v 1.54 2010/11/03 15:11:01 jsg Exp $ +.\" $OpenBSD: tar.1,v 1.55 2010/12/02 04:08:27 tedu Exp $ .\" .\" Copyright (c) 1996 SigmaSoft, Th. Lockert .\" All rights reserved. @@ -23,7 +23,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. .\" -.Dd $Mdocdate: November 3 2010 $ +.Dd $Mdocdate: December 2 2010 $ .Dt TAR 1 .Os .Sh NAME @@ -32,7 +32,7 @@ .Sh SYNOPSIS .Nm tar .Sm off -.No { Cm crtux No } Op Cm 014578befHhjLmOoPpqsvwXZz +.No { Cm crtux No } Op Cm 014578befHhjLmNOoPpqsvwXZz .Sm on .Bk -words .Op Ar blocking-factor | archive | replstr @@ -43,7 +43,7 @@ .Nm tar .No { Ns Fl crtux Ns } .Bk -words -.Op Fl 014578eHhjLmOoPpqvwXZz +.Op Fl 014578eHhjLmNOoPpqvwXZz .Op Fl b Ar blocking-factor .Op Fl C Ar directory .Op Fl f Ar archive @@ -166,6 +166,9 @@ Synonym for the option. .It Fl m Do not preserve modification time. +.It Fl N +Use only the numeric UID and GID values when creating or extracting an +archive. .It Fl O Write old-style (non-POSIX) archives. .It Fl o diff --git a/bin/pax/tar.c b/bin/pax/tar.c index 234c4368b70..313b542e219 100644 --- a/bin/pax/tar.c +++ b/bin/pax/tar.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tar.c,v 1.42 2009/10/27 23:59:22 deraadt Exp $ */ +/* $OpenBSD: tar.c,v 1.43 2010/12/02 04:08:27 tedu Exp $ */ /* $NetBSD: tar.c,v 1.5 1995/03/21 09:07:49 cgd Exp $ */ /*- @@ -795,10 +795,10 @@ ustar_rd(ARCHD *arcn, char *buf) * the posix spec wants). */ hd->gname[sizeof(hd->gname) - 1] = '\0'; - if (gid_name(hd->gname, &(arcn->sb.st_gid)) < 0) + if (Nflag || gid_name(hd->gname, &(arcn->sb.st_gid)) < 0) arcn->sb.st_gid = (gid_t)asc_ul(hd->gid, sizeof(hd->gid), OCT); hd->uname[sizeof(hd->uname) - 1] = '\0'; - if (uid_name(hd->uname, &(arcn->sb.st_uid)) < 0) + if (Nflag || uid_name(hd->uname, &(arcn->sb.st_uid)) < 0) arcn->sb.st_uid = (uid_t)asc_ul(hd->uid, sizeof(hd->uid), OCT); /* @@ -1061,8 +1061,13 @@ ustar_wr(ARCHD *arcn) if (ul_oct((u_long)arcn->sb.st_mode, hd->mode, sizeof(hd->mode), 3) || ul_oct((u_long)(u_int)arcn->sb.st_mtime,hd->mtime,sizeof(hd->mtime),3)) goto out; - strncpy(hd->uname, name_uid(arcn->sb.st_uid, 0), sizeof(hd->uname)); - strncpy(hd->gname, name_gid(arcn->sb.st_gid, 0), sizeof(hd->gname)); + if (!Nflag) { + strncpy(hd->uname, name_uid(arcn->sb.st_uid, 0), sizeof(hd->uname)); + strncpy(hd->gname, name_gid(arcn->sb.st_gid, 0), sizeof(hd->gname)); + } else { + strncpy(hd->uname, "", sizeof(hd->uname)); + strncpy(hd->gname, "", sizeof(hd->gname)); + } /* * calculate and store the checksum write the header to the archive |