From 72a8b313036092d3133c010257218ab60c1ca808 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 1 Aug 2003 21:09:10 +0000 Subject: Fix the option processing for smbtar. Does no one check this ! Jeremy. (This used to be commit c4af1ec73584656fb9d2b372461da4748e1643f1) --- source3/client/client.c | 24 ++++++++++++++++++++---- source3/client/clitar.c | 17 +++++++++++++++-- 2 files changed, 35 insertions(+), 6 deletions(-) (limited to 'source3') diff --git a/source3/client/client.c b/source3/client/client.c index e17ae82c0a..ec29f44e6e 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -2824,9 +2824,25 @@ static void remember_query_host(const char *arg, max_protocol = interpret_protocol(poptGetOptArg(pc), max_protocol); break; case 'T': - if (!tar_parseargs(argc, argv, poptGetOptArg(pc), optind)) { - poptPrintUsage(pc, stderr, 0); - exit(1); + /* We must use old option processing for this. Find the + * position of the -T option in the raw argv[]. */ + { + int i, optnum; + for (i = 1; i < argc; i++) { + if (strncmp("-T", argv[i],2)==0) + break; + } + i++; + if (!(optnum = tar_parseargs(argc, argv, poptGetOptArg(pc), i))) { + poptPrintUsage(pc, stderr, 0); + exit(1); + } + /* Now we must eat (optnum - i) options - they have + * been processed by tar_parseargs(). + */ + optnum -= i; + for (i = 0; i < optnum; i++) + poptGetOptArg(pc); } break; case 'D': @@ -2851,7 +2867,7 @@ static void remember_query_host(const char *arg, } } - if (poptPeekArg(pc)) { + if (poptPeekArg(pc) && !cmdline_auth_info.got_pass) { cmdline_auth_info.got_pass = True; pstrcpy(cmdline_auth_info.password,poptGetArg(pc)); } diff --git a/source3/client/clitar.c b/source3/client/clitar.c index 5e8414e083..5295de8010 100644 --- a/source3/client/clitar.c +++ b/source3/client/clitar.c @@ -1585,6 +1585,7 @@ Parse tar arguments. Sets tar_type, tar_excl, etc. int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind) { + int newOptind = Optind; char tar_clipfl='\0'; /* Reset back to defaults - could be from interactive version @@ -1612,6 +1613,7 @@ int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind) return 0; } else { Optind++; + newOptind++; } break; case 'g': @@ -1629,6 +1631,7 @@ int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind) newer_than = stbuf.st_mtime; DEBUG(1,("Getting files newer than %s", asctime(LocalTime(&newer_than)))); + newOptind++; Optind++; } else { DEBUG(0,("Error setting newer-than time\n")); @@ -1696,7 +1699,9 @@ int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind) DEBUG(0,("Option F must be followed by exactly one filename.\n")); return 0; } - if (! read_inclusion_file(argv[Optind+1])) { + newOptind++; + Optind++; + if (! read_inclusion_file(argv[Optind])) { return 0; } } else if (Optind+1=argc || !strcmp(argv[Optind], "-")) { @@ -1767,6 +1775,10 @@ int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind) if (tarhandle == 1) { dbf = x_stderr; } + if (!strcmp(argv[Optind], "-")) { + newOptind++; + } + } else { if (tar_type=='c' && (dry_run || strcmp(argv[Optind], "/dev/null")==0)) { if (!dry_run) { @@ -1779,7 +1791,8 @@ int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind) DEBUG(0,("Error opening local file %s - %s\n", argv[Optind], strerror(errno))); return(0); } + newOptind++; } - return 1; + return newOptind; } -- cgit