summaryrefslogtreecommitdiffstats
path: root/usr.bin/tar/bsdtar.c
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2005-08-02 03:02:55 +0000
committerkientzle <kientzle@FreeBSD.org>2005-08-02 03:02:55 +0000
commit5aa08bac53ff84f5f154d9a58d670d05d7150e83 (patch)
treebc85b9ba567baf68ffe0f6d67125a88bd9fae652 /usr.bin/tar/bsdtar.c
parente3316aaa7d4e0c0f0cb1e5df6b475ced30502acd (diff)
downloadFreeBSD-src-5aa08bac53ff84f5f154d9a58d670d05d7150e83.zip
FreeBSD-src-5aa08bac53ff84f5f154d9a58d670d05d7150e83.tar.gz
The bsdtar_warnc() reporting function requires the program name to be
set up before it is called, so move the progname initialization before the first possible call to bsdtar_warnc(). Thanks to: Stanislav Sedov PR: bin/83366 MFC after: 7 days
Diffstat (limited to 'usr.bin/tar/bsdtar.c')
-rw-r--r--usr.bin/tar/bsdtar.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/usr.bin/tar/bsdtar.c b/usr.bin/tar/bsdtar.c
index 87ac5f1..59d3ace 100644
--- a/usr.bin/tar/bsdtar.c
+++ b/usr.bin/tar/bsdtar.c
@@ -206,6 +206,17 @@ main(int argc, char **argv)
bsdtar->fd = -1; /* Mark as "unused" */
option_o = 0;
+ /* Need bsdtar->progname before calling bsdtar_warnc. */
+ if (*argv == NULL)
+ bsdtar->progname = "bsdtar";
+ else {
+ bsdtar->progname = strrchr(*argv, '/');
+ if (bsdtar->progname != NULL)
+ bsdtar->progname++;
+ else
+ bsdtar->progname = *argv;
+ }
+
if (setlocale(LC_ALL, "") == NULL)
bsdtar_warnc(bsdtar, 0, "Failed to set default locale");
#if defined(HAVE_NL_LANGINFO) && defined(HAVE_D_MD_ORDER)
@@ -224,19 +235,10 @@ main(int argc, char **argv)
/* Default: preserve mod time on extract */
bsdtar->extract_flags = ARCHIVE_EXTRACT_TIME;
+ /* Default for root user: preserve ownership on extract. */
if (bsdtar->user_uid == 0)
bsdtar->extract_flags |= ARCHIVE_EXTRACT_OWNER;
- if (*argv == NULL)
- bsdtar->progname = "bsdtar";
- else {
- bsdtar->progname = strrchr(*argv, '/');
- if (bsdtar->progname != NULL)
- bsdtar->progname++;
- else
- bsdtar->progname = *argv;
- }
-
/* Rewrite traditional-style tar arguments, if used. */
argv = rewrite_argv(bsdtar, &argc, argv, tar_opts);
OpenPOWER on IntegriCloud