summaryrefslogtreecommitdiff
path: root/bin/pax
diff options
context:
space:
mode:
Diffstat (limited to 'bin/pax')
-rw-r--r--bin/pax/Makefile3
-rw-r--r--bin/pax/ar_io.c8
-rw-r--r--bin/pax/extern.h3
-rw-r--r--bin/pax/file_subs.c10
-rw-r--r--bin/pax/options.c5
-rw-r--r--bin/pax/pax.c3
6 files changed, 19 insertions, 13 deletions
diff --git a/bin/pax/Makefile b/bin/pax/Makefile
index 0db098ba861..472c7d0887e 100644
--- a/bin/pax/Makefile
+++ b/bin/pax/Makefile
@@ -1,5 +1,6 @@
-# $OpenBSD: Makefile,v 1.11 2014/01/08 04:58:36 guenther Exp $
+# $OpenBSD: Makefile,v 1.12 2016/08/23 06:00:28 guenther Exp $
+WARNINGS=Yes
PROG= pax
SRCS= ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c\
gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c tables.c\
diff --git a/bin/pax/ar_io.c b/bin/pax/ar_io.c
index 9b8fe86eb05..5a579be0406 100644
--- a/bin/pax/ar_io.c
+++ b/bin/pax/ar_io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar_io.c,v 1.57 2016/08/14 18:30:33 guenther Exp $ */
+/* $OpenBSD: ar_io.c,v 1.58 2016/08/23 06:00:28 guenther Exp $ */
/* $NetBSD: ar_io.c,v 1.5 1996/03/26 23:54:13 mrg Exp $ */
/*-
@@ -390,12 +390,12 @@ ar_close(int in_sig)
return;
}
- if (strcmp(NM_PAX, argv0) == 0)
+ if (op_mode == OP_PAX)
(void)dprintf(listfd, "%s: %s vol %d, %lu files,"
" %llu bytes read, %llu bytes written.\n",
argv0, frmt->name, arvol-1, flcnt, rdcnt, wrcnt);
#ifndef NOCPIO
- else if (strcmp(NM_CPIO, argv0) == 0)
+ else if (op_mode == OP_CPIO)
(void)dprintf(listfd, "%llu blocks\n",
(rdcnt ? rdcnt : wrcnt) / 5120);
#endif /* !NOCPIO */
@@ -1112,7 +1112,7 @@ ar_next(void)
if (sigprocmask(SIG_SETMASK, &o_mask, NULL) < 0)
syswarn(0, errno, "Unable to restore signal mask");
- if (done || !wr_trail || force_one_volume || strcmp(NM_TAR, argv0) == 0)
+ if (done || !wr_trail || force_one_volume || op_mode == OP_TAR)
return(-1);
tty_prnt("\nATTENTION! %s archive volume change required.\n", argv0);
diff --git a/bin/pax/extern.h b/bin/pax/extern.h
index 80c7dc7be8a..774487b900d 100644
--- a/bin/pax/extern.h
+++ b/bin/pax/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.55 2016/08/14 04:47:52 guenther Exp $ */
+/* $OpenBSD: extern.h,v 1.56 2016/08/23 06:00:28 guenther Exp $ */
/* $NetBSD: extern.h,v 1.5 1996/03/26 23:54:16 mrg Exp $ */
/*-
@@ -240,6 +240,7 @@ extern int exit_val;
extern int docrc;
extern char *dirptr;
extern char *argv0;
+extern enum op_mode { OP_PAX, OP_TAR, OP_CPIO } op_mode;
extern FILE *listf;
extern int listfd;
extern char *tempfile;
diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c
index 8d96763331a..6f6a7833833 100644
--- a/bin/pax/file_subs.c
+++ b/bin/pax/file_subs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file_subs.c,v 1.50 2016/08/23 03:31:44 guenther Exp $ */
+/* $OpenBSD: file_subs.c,v 1.51 2016/08/23 06:00:28 guenther Exp $ */
/* $NetBSD: file_subs.c,v 1.4 1995/03/21 09:07:18 cgd Exp $ */
/*-
@@ -371,7 +371,7 @@ node_creat(ARCHD *arcn)
* potential symlink chain before trying to create the
* directory.
*/
- if (strcmp(NM_TAR, argv0) == 0 && Lflag) {
+ if (op_mode == OP_TAR && Lflag) {
while (lstat(nm, &sb) == 0 &&
S_ISLNK(sb.st_mode)) {
len = readlink(nm, target,
@@ -484,7 +484,7 @@ badlink:
if (pmode && !defer_pmode)
set_pmode(nm, arcn->sb.st_mode);
- if (arcn->type == PAX_DIR && strcmp(NM_CPIO, argv0) != 0) {
+ if (arcn->type == PAX_DIR && op_mode != OP_CPIO) {
/*
* Dirs must be processed again at end of extract to set times
* and modes to agree with those stored in the archive. However
@@ -758,7 +758,7 @@ set_ids(char *fnm, uid_t uid, gid_t gid)
* ignore EPERM unless in verbose mode or being run by root.
* if running as pax, POSIX requires a warning.
*/
- if (strcmp(NM_PAX, argv0) == 0 || errno != EPERM || vflag ||
+ if (op_mode == OP_PAX || errno != EPERM || vflag ||
geteuid() == 0)
syswarn(1, errno, "Unable to set file uid/gid of %s",
fnm);
@@ -775,7 +775,7 @@ fset_ids(char *fnm, int fd, uid_t uid, gid_t gid)
* ignore EPERM unless in verbose mode or being run by root.
* if running as pax, POSIX requires a warning.
*/
- if (strcmp(NM_PAX, argv0) == 0 || errno != EPERM || vflag ||
+ if (op_mode == OP_PAX || errno != EPERM || vflag ||
geteuid() == 0)
syswarn(1, errno, "Unable to set file uid/gid of %s",
fnm);
diff --git a/bin/pax/options.c b/bin/pax/options.c
index 2ee50db71b7..bb0b9fcdf7e 100644
--- a/bin/pax/options.c
+++ b/bin/pax/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.94 2016/08/14 04:47:52 guenther Exp $ */
+/* $OpenBSD: options.c,v 1.95 2016/08/23 06:00:28 guenther Exp $ */
/* $NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $ */
/*-
@@ -186,11 +186,13 @@ options(int argc, char **argv)
argv0 = __progname;
if (strcmp(NM_TAR, argv0) == 0) {
+ op_mode = OP_TAR;
tar_options(argc, argv);
return;
}
#ifndef NOCPIO
else if (strcmp(NM_CPIO, argv0) == 0) {
+ op_mode = OP_CPIO;
cpio_options(argc, argv);
return;
}
@@ -199,6 +201,7 @@ options(int argc, char **argv)
* assume pax as the default
*/
argv0 = NM_PAX;
+ op_mode = OP_PAX;
pax_options(argc, argv);
}
diff --git a/bin/pax/pax.c b/bin/pax/pax.c
index 1b17b8c16f4..a8e365a8900 100644
--- a/bin/pax/pax.c
+++ b/bin/pax/pax.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pax.c,v 1.45 2016/06/23 06:37:36 semarie Exp $ */
+/* $OpenBSD: pax.c,v 1.46 2016/08/23 06:00:28 guenther Exp $ */
/* $NetBSD: pax.c,v 1.5 1996/03/26 23:54:20 mrg Exp $ */
/*-
@@ -90,6 +90,7 @@ int exit_val; /* exit value */
int docrc; /* check/create file crc */
char *dirptr; /* destination dir in a copy */
char *argv0; /* root of argv[0] */
+enum op_mode op_mode; /* what program are we acting as? */
sigset_t s_mask; /* signal mask for cleanup critical sect */
FILE *listf = stderr; /* file pointer to print file list to */
int listfd = STDERR_FILENO; /* fd matching listf, for sighandler output */