summaryrefslogtreecommitdiff
path: root/source3/client
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2007-03-28 14:16:34 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:18:59 -0500
commit73c8eee9b2f65dc4d97b7aef379f7a087f043d21 (patch)
tree8e1b5a03a69b96bc37934ddbd025a285c390aefe /source3/client
parent56ba44766854ed7cda265bdaf85913f2a1008282 (diff)
downloadsamba-73c8eee9b2f65dc4d97b7aef379f7a087f043d21.tar.gz
samba-73c8eee9b2f65dc4d97b7aef379f7a087f043d21.tar.bz2
samba-73c8eee9b2f65dc4d97b7aef379f7a087f043d21.zip
r22002: Fix bug #3974, there are still open issues with -N behavior (doc fix next)
and -T argument parsing behavior (which is just insane but a separate bug) (This used to be commit 1a3980f1fcb6431aa6bce83f7c34338436b4e962)
Diffstat (limited to 'source3/client')
-rw-r--r--source3/client/client.c89
1 files changed, 63 insertions, 26 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index b32e5baae6..49c94eb56b 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -3891,6 +3891,8 @@ static int do_message_op(void)
char *p;
int rc = 0;
fstring new_workgroup;
+ BOOL tar_opt = False;
+ BOOL service_opt = False;
struct poptOption long_options[] = {
POPT_AUTOHELP
@@ -3937,13 +3939,43 @@ static int do_message_op(void)
x_setbuf( dbf, NULL );
}
- pc = poptGetContext("smbclient", argc, (const char **) argv, long_options,
- POPT_CONTEXT_KEEP_FIRST);
+ /* skip argv(0) */
+ pc = poptGetContext("smbclient", argc, (const char **) argv, long_options, 0);
poptSetOtherOptionHelp(pc, "service <password>");
in_client = True; /* Make sure that we tell lp_load we are */
while ((opt = poptGetNextOpt(pc)) != -1) {
+
+ /* if the tar option has been called previouslt, now we need to eat out the leftovers */
+ /* I see no other way to keep things sane --SSS */
+ if (tar_opt == True) {
+ while (poptPeekArg(pc)) {
+ poptGetArg(pc);
+ }
+ tar_opt = False;
+ }
+
+ /* if the service has not yet been specified lets see if it is available in the popt stack */
+ if (!service_opt && poptPeekArg(pc)) {
+ pstrcpy(service, poptGetArg(pc));
+ /* Convert any '/' characters in the service name to '\' characters */
+ string_replace(service, '/','\\');
+
+ if (count_chars(service,'\\') < 3) {
+ d_printf("\n%s: Not enough '\\' characters in service\n",service);
+ poptPrintUsage(pc, stderr, 0);
+ exit(1);
+ }
+ service_opt = True;
+ }
+
+ /* if the service has already been retrieved then check if we have also a password */
+ if (service_opt && (!cmdline_auth_info.got_pass) && poptPeekArg(pc)) {
+ pstrcpy(cmdline_auth_info.password, poptGetArg(pc));
+ cmdline_auth_info.got_pass = True;
+ }
+
switch (opt) {
case 'M':
/* Messages are sent to NetBIOS name type 0x3
@@ -3998,13 +4030,9 @@ static int do_message_op(void)
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);
}
+ /* this must be the last option, mark we have parsed it so that we know we have */
+ tar_opt = True;
break;
case 'D':
pstrcpy(base_directory,poptGetOptArg(pc));
@@ -4015,8 +4043,34 @@ static int do_message_op(void)
}
}
- poptGetArg(pc);
+ /* We may still have some leftovers after the last popt option has been called */
+ if (tar_opt == True) {
+ while (poptPeekArg(pc)) {
+ poptGetArg(pc);
+ }
+ tar_opt = False;
+ }
+
+ /* if the service has not yet been specified lets see if it is available in the popt stack */
+ if (!service_opt && poptPeekArg(pc)) {
+ pstrcpy(service, poptGetArg(pc));
+ /* Convert any '/' characters in the service name to '\' characters */
+ string_replace(service, '/','\\');
+
+ if (count_chars(service,'\\') < 3) {
+ d_printf("\n%s: Not enough '\\' characters in service\n",service);
+ poptPrintUsage(pc, stderr, 0);
+ exit(1);
+ }
+ service_opt = True;
+ }
+ /* if the service has already been retrieved then check if we have also a password */
+ if (service_opt && (!cmdline_auth_info.got_pass) && poptPeekArg(pc)) {
+ pstrcpy(cmdline_auth_info.password, poptGetArg(pc));
+ cmdline_auth_info.got_pass = True;
+ }
+
/* check for the -P option */
if ( port != 0 )
@@ -4055,23 +4109,6 @@ static int do_message_op(void)
else
pstrcpy( calling_name, global_myname() );
- if(poptPeekArg(pc)) {
- pstrcpy(service,poptGetArg(pc));
- /* Convert any '/' characters in the service name to '\' characters */
- string_replace(service, '/','\\');
-
- if (count_chars(service,'\\') < 3) {
- d_printf("\n%s: Not enough '\\' characters in service\n",service);
- poptPrintUsage(pc, stderr, 0);
- exit(1);
- }
- }
-
- if (poptPeekArg(pc) && !cmdline_auth_info.got_pass) {
- cmdline_auth_info.got_pass = True;
- pstrcpy(cmdline_auth_info.password,poptGetArg(pc));
- }
-
init_names();
if(new_name_resolve_order)