browse_fn: FIXME: If the remote machine returns non-ascii characters
[ira/wip.git] / source3 / client / client.c
index 2b0867cf7b40e0d006a40a13f1d59065ae251f7e..61a123b9e54fbd98010640995a2c4134815af125 100644 (file)
@@ -32,6 +32,7 @@ const char prog_name[] = "smbclient";
 
 struct cli_state *cli;
 extern BOOL in_client;
+extern BOOL AllowDebugChange;
 static int port = 0;
 pstring cur_dir = "\\";
 pstring cd_path = "";
@@ -63,8 +64,6 @@ static int cmd_help(void);
 time_t newer_than = 0;
 int archive_level = 0;
 
-extern pstring debugf;
-
 BOOL translation = False;
 
 static BOOL have_ip;
@@ -1752,6 +1751,9 @@ static void browse_fn(const char *name, uint32 m,
           case STYPE_IPC:
             fstrcpy(typestr,"IPC"); break;
         }
+       /* FIXME: If the remote machine returns non-ascii characters
+          in any of these fields, they can corrupt the output.  We
+          should remove them. */
        d_printf("\t%-15.15s%-10.10s%s\n",
                name,typestr,comment);
 }
@@ -2124,7 +2126,6 @@ struct cli_state *do_connect(const char *server, const char *share)
                d_printf("session request to %s failed (%s)\n", 
                         called.name, cli_errstr(c));
                cli_shutdown(c);
-               SAFE_FREE(c);
                if ((p=strchr_m(called.name, '.'))) {
                        *p = 0;
                        goto again;
@@ -2141,7 +2142,6 @@ struct cli_state *do_connect(const char *server, const char *share)
        if (!cli_negprot(c)) {
                d_printf("protocol negotiation failed\n");
                cli_shutdown(c);
-               SAFE_FREE(c);
                return NULL;
        }
 
@@ -2161,23 +2161,17 @@ struct cli_state *do_connect(const char *server, const char *share)
                    !cli_session_setup(c, "", "", 0, "", 0, workgroup)) { 
                        d_printf("session setup failed: %s\n", cli_errstr(c));
                        cli_shutdown(c);
-                       SAFE_FREE(c);
                        return NULL;
                }
                d_printf("Anonymous login successful\n");
        }
 
-       /*
-        * These next two lines are needed to emulate
-        * old client behaviour for people who have
-        * scripts based on client output.
-        * QUESTION ? Do we want to have a 'client compatibility
-        * mode to turn these on/off ? JRA.
-        */
-
-       if (*c->server_domain || *c->server_os || *c->server_type){
+       if (*c->server_domain) {
                DEBUG(1,("Domain=[%s] OS=[%s] Server=[%s]\n",
                        c->server_domain,c->server_os,c->server_type));
+       } else if (*c->server_os || *c->server_type){
+               DEBUG(1,("OS=[%s] Server=[%s]\n",
+                        c->server_os,c->server_type));
        }               
        
        DEBUG(4,(" session setup ok\n"));
@@ -2186,7 +2180,6 @@ struct cli_state *do_connect(const char *server, const char *share)
                            password, strlen(password)+1)) {
                d_printf("tree connect failed: %s\n", cli_errstr(c));
                cli_shutdown(c);
-               SAFE_FREE(c);
                return NULL;
        }
 
@@ -2406,6 +2399,7 @@ static int do_message_op(void)
        extern char tar_type;
        pstring term_code;
        pstring new_name_resolve_order;
+       pstring logfile;
        char *p;
        int rc = 0;
 
@@ -2421,6 +2415,7 @@ static int do_message_op(void)
        *new_name_resolve_order = 0;
 
        DEBUGLEVEL = 2;
+       AllowDebugChange = False;
  
        setup_logging(pname,True);
 
@@ -2507,7 +2502,13 @@ static int do_message_op(void)
                usage(pname);
                exit(1);
        }
-  
+
+       /* FIXME: At the moment, if the user should happen to give the
+        * options ahead of the service name (in standard Unix
+        * fashion) then smbclient just spits out the usage message
+        * with no explanation of what in particular was wrong.  Is
+        * there any reason we can't just parse out the service name
+        * and password after running getopt?? -- mbp */
        if (*argv[1] != '-') {
                pstrcpy(service,argv[1]);  
                /* Convert any '/' characters in the service name to '\' characters */
@@ -2573,7 +2574,8 @@ static int do_message_op(void)
                        port = atoi(optarg);
                        break;
                case 'l':
-                       slprintf(debugf,sizeof(debugf)-1, "%s.client",optarg);
+                       slprintf(logfile,sizeof(logfile)-1, "%s.client",optarg);
+                       lp_set_logfile(logfile);
                        break;
                case 'h':
                        usage(pname);
@@ -2652,7 +2654,8 @@ static int do_message_op(void)
                                        }
                                        else if (strwicmp("username", param) == 0)
                                                pstrcpy(username, val);
-                                               
+                                       else if (strwicmp("domain", param) == 0)
+                                               pstrcpy(workgroup,val);
                                        memset(buf, 0, sizeof(buf));
                                }
                                x_fclose(auth);
@@ -2690,7 +2693,7 @@ static int do_message_op(void)
                        io_bufsize = MAX(1, atoi(optarg));
                        break;
                case 'k':
-#if HAVE_KRB5
+#ifdef HAVE_KRB5
                        use_kerberos = True;
                        got_pass = True;
 #else