diff options
author | Jeremy Allison <jra@samba.org> | 2003-08-01 21:09:10 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2003-08-01 21:09:10 +0000 |
commit | 72a8b313036092d3133c010257218ab60c1ca808 (patch) | |
tree | 47879b746536c5e9eae3e5a2702fab391b5e3fa1 | |
parent | bfb312800fe3bb60cacb11c96f8b6c96c66fee0a (diff) | |
download | samba-72a8b313036092d3133c010257218ab60c1ca808.tar.gz |
Fix the option processing for smbtar. Does no one check this !
Jeremy.
(This used to be commit c4af1ec73584656fb9d2b372461da4748e1643f1)
-rw-r--r-- | source3/client/client.c | 24 | ||||
-rw-r--r-- | source3/client/clitar.c | 17 |
2 files changed, 35 insertions, 6 deletions
diff --git a/source3/client/client.c b/source3/client/client.c index e17ae82c0a1..ec29f44e6e0 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 5e8414e0837..5295de8010b 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 && !tar_re_search) { /* For backwards compatibility */ @@ -1731,6 +1736,8 @@ int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind) cliplist = tmplist; must_free_cliplist = True; + + newOptind += clipn; } if (Optind+1<argc && tar_re_search) { /* Doing regular expression seaches */ @@ -1755,6 +1762,7 @@ int tar_parseargs(int argc, char *argv[], char *Optarg, int Optind) clipn=argc-Optind-1; cliplist=argv+Optind+1; + newOptind += clipn; } if (Optind>=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; } |