From 5d596ecb2545f46c0182803a80e5394a2ea1501b Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Tue, 2 Aug 2005 03:02:55 +0000 Subject: 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 --- usr.bin/tar/bsdtar.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'usr.bin/tar') diff --git a/usr.bin/tar/bsdtar.c b/usr.bin/tar/bsdtar.c index 87ac5f18d62c..59d3aced1049 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); -- cgit v1.2.3