r5917: First step in using the new cli_credentials structure. This patch
[bbaumbach/samba-autobuild/.git] / source4 / client / client.c
index f17586f994a10ce5ee5724bcfb8bee9dcfab5ba6..fd5be736079f2f222f3ac669a69cd5a154604a79 100644 (file)
 */
 
 #include "includes.h"
+#include "version.h"
 #include "dynconfig.h"
 #include "clilist.h"
 #include "lib/cmdline/popt_common.h"
 #include "librpc/gen_ndr/ndr_srvsvc.h"
+#include "librpc/gen_ndr/ndr_lsa.h"
 #include "libcli/raw/libcliraw.h"
 #include "system/time.h"
 #include "system/dir.h"
@@ -43,9 +45,6 @@ pstring cur_dir = "\\";
 static pstring cd_path = "";
 static pstring service;
 static pstring desthost;
-static pstring username;
-static pstring domain;
-static pstring password;
 static char *cmdstr = NULL;
 
 static int io_bufsize = 64512;
@@ -101,7 +100,7 @@ static double dir_total;
 #define USENMB
 
 /* some forward declarations */
-static struct smbcli_state *do_connect(const char *server, const char *share);
+static struct smbcli_state *do_connect(const char *server, const char *share, struct cli_credentials *cred);
 
 
 /*******************************************************************
@@ -200,7 +199,7 @@ static void send_message(void)
        int total_len = 0;
        int grp_id;
 
-       if (!smbcli_message_start(cli->tree, desthost, username, &grp_id)) {
+       if (!smbcli_message_start(cli->tree, desthost, cli_credentials_get_username(cmdline_credentials), &grp_id)) {
                d_printf("message start: %s\n", smbcli_errstr(cli->tree));
                return;
        }
@@ -214,7 +213,7 @@ static void send_message(void)
                int l=0;
                int c;
 
-               ZERO_ARRAY(msg);
+               ZERO_STRUCT(msg);
 
                for (l=0;l<maxlen && (c=fgetc(stdin))!=EOF;l++) {
                        if (c == '\n')
@@ -927,7 +926,7 @@ static void do_mget(struct clilist_file_info *finfo)
                strlower(discard_const_p(char, finfo->name));
        }
        
-       if (!directory_exist(finfo->name,NULL) && 
+       if (!directory_exist(finfo->name) && 
            mkdir(finfo->name,0777) != 0) {
                d_printf("failed to create directory %s\n",finfo->name);
                pstrcpy(cur_dir,saved_curdir);
@@ -1299,15 +1298,11 @@ static int cmd_put(const char **cmd_ptr)
        
        dos_clean_name(rname);
 
-       {
-               struct stat st;
-               /* allow '-' to represent stdin
-                  jdblair, 24.jun.98 */
-               if (!file_exist(lname,&st) &&
-                   (strcmp(lname,"-"))) {
-                       d_printf("%s does not exist\n",lname);
-                       return 1;
-               }
+       /* allow '-' to represent stdin
+          jdblair, 24.jun.98 */
+       if (!file_exist(lname) && (strcmp(lname,"-"))) {
+               d_printf("%s does not exist\n",lname);
+               return 1;
        }
 
        return do_put(rname, lname, False);
@@ -1745,12 +1740,10 @@ static int cmd_allinfo(const char **cmd_ptr)
        if (NT_STATUS_IS_OK(status)) {
                int i;
                for (i=0;i<finfo.all_eas.out.num_eas;i++) {
-                       d_printf("\tEA[%d] flags=%d %s=%*.*s\n", i,
+                       d_printf("\tEA[%d] flags=%d len=%d '%s'\n", i,
                                 finfo.all_eas.out.eas[i].flags,
-                                finfo.all_eas.out.eas[i].name.s,
-                                finfo.all_eas.out.eas[i].value.length,
                                 finfo.all_eas.out.eas[i].value.length,
-                                finfo.all_eas.out.eas[i].value.data);
+                                finfo.all_eas.out.eas[i].name.s);
                }
        }
 
@@ -1780,13 +1773,65 @@ static int cmd_allinfo(const char **cmd_ptr)
                d_printf("\tcluster_shift   %ld\n", (long)finfo.compression_info.out.cluster_shift);
        }
 
-       talloc_destroy(mem_ctx);
+       talloc_free(mem_ctx);
 
 done:
        return ret;
 }
 
 
+/****************************************************************************
+shows EA contents
+****************************************************************************/
+static int cmd_eainfo(const char **cmd_ptr)
+{
+       pstring fname;
+       fstring buf;
+       int ret = 0;
+       TALLOC_CTX *mem_ctx;
+       union smb_fileinfo finfo;
+       NTSTATUS status;
+       int i;
+
+       pstrcpy(fname,cur_dir);
+       
+       if (!next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
+               d_printf("eainfo <filename>\n");
+               return 1;
+       }
+       pstrcat(fname,buf);
+
+       mem_ctx = talloc_init("%s", fname);
+
+       finfo.generic.in.fname = fname;
+       finfo.generic.level = RAW_FILEINFO_ALL_EAS;
+       status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo);
+       
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("RAW_FILEINFO_ALL_EAS - %s\n", nt_errstr(status));
+               talloc_free(mem_ctx);
+               return 1;
+       }
+
+       d_printf("%s has %d EAs\n", fname, finfo.all_eas.out.num_eas);
+
+       for (i=0;i<finfo.all_eas.out.num_eas;i++) {
+               d_printf("\tEA[%d] flags=%d len=%d '%s'\n", i,
+                        finfo.all_eas.out.eas[i].flags,
+                        finfo.all_eas.out.eas[i].value.length,
+                        finfo.all_eas.out.eas[i].name.s);
+               fflush(stdout);
+               dump_data(0, 
+                         finfo.all_eas.out.eas[i].value.data,
+                         finfo.all_eas.out.eas[i].value.length);
+       }
+
+       talloc_free(mem_ctx);
+
+       return ret;
+}
+
+
 /****************************************************************************
 show any ACL on a file
 ****************************************************************************/
@@ -1808,7 +1853,14 @@ static int cmd_acl(const char **cmd_ptr)
        }
        pstrcat(fname,buf);
 
-       fnum = smbcli_open(cli->tree, fname, O_RDONLY, DENY_NONE);
+       fnum = smbcli_nt_create_full(cli->tree, fname, 0, 
+                                    SEC_STD_READ_CONTROL,
+                                    0,
+                                    NTCREATEX_SHARE_ACCESS_DELETE|
+                                    NTCREATEX_SHARE_ACCESS_READ|
+                                    NTCREATEX_SHARE_ACCESS_WRITE, 
+                                    NTCREATEX_DISP_OPEN,
+                                    0, 0);
        if (fnum == -1) {
                d_printf("%s - %s\n", fname, smbcli_errstr(cli->tree));
                return -1;
@@ -1829,12 +1881,203 @@ static int cmd_acl(const char **cmd_ptr)
 
        NDR_PRINT_DEBUG(security_descriptor, query.query_secdesc.out.sd);
 
-       talloc_destroy(mem_ctx);
+       talloc_free(mem_ctx);
 
 done:
        return ret;
 }
 
+/****************************************************************************
+lookup a name or sid
+****************************************************************************/
+static int cmd_lookup(const char **cmd_ptr)
+{
+       fstring buf;
+       TALLOC_CTX *mem_ctx = talloc_new(NULL);
+       NTSTATUS status;
+       struct dom_sid *sid;
+
+       if (!next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
+               d_printf("lookup <sid|name>\n");
+               talloc_free(mem_ctx);
+               return 1;
+       }
+
+       sid = dom_sid_parse_talloc(mem_ctx, buf);
+       if (sid == NULL) {
+               const char *sidstr;
+               status = smblsa_lookup_name(cli, buf, mem_ctx, &sidstr);
+               if (!NT_STATUS_IS_OK(status)) {
+                       d_printf("lsa_LookupNames - %s\n", nt_errstr(status));
+                       talloc_free(mem_ctx);
+                       return 1;
+               }
+
+               d_printf("%s\n", sidstr);
+       } else {
+               const char *name;
+               status = smblsa_lookup_sid(cli, buf, mem_ctx, &name);
+               if (!NT_STATUS_IS_OK(status)) {
+                       d_printf("lsa_LookupSids - %s\n", nt_errstr(status));
+                       talloc_free(mem_ctx);
+                       return 1;
+               }
+
+               d_printf("%s\n", name);
+       }
+
+       talloc_free(mem_ctx);
+
+       return 0;
+}
+
+/****************************************************************************
+show privileges for a user
+****************************************************************************/
+static int cmd_privileges(const char **cmd_ptr)
+{
+       fstring buf;
+       TALLOC_CTX *mem_ctx = talloc_new(NULL);
+       NTSTATUS status;
+       struct dom_sid *sid;
+       struct lsa_RightSet rights;
+       unsigned i;
+
+       if (!next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
+               d_printf("privileges <sid|name>\n");
+               talloc_free(mem_ctx);
+               return 1;
+       }
+
+       sid = dom_sid_parse_talloc(mem_ctx, buf);
+       if (sid == NULL) {
+               const char *sid_str;
+               status = smblsa_lookup_name(cli, buf, mem_ctx, &sid_str);
+               if (!NT_STATUS_IS_OK(status)) {
+                       d_printf("lsa_LookupNames - %s\n", nt_errstr(status));
+                       talloc_free(mem_ctx);
+                       return 1;
+               }
+               sid = dom_sid_parse_talloc(mem_ctx, sid_str);
+       }
+
+       status = smblsa_sid_privileges(cli, sid, mem_ctx, &rights);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("lsa_EnumAccountRights - %s\n", nt_errstr(status));
+               talloc_free(mem_ctx);
+               return 1;
+       }
+
+       for (i=0;i<rights.count;i++) {
+               d_printf("\t%s\n", rights.names[i].string);
+       }
+
+       talloc_free(mem_ctx);
+
+       return 0;
+}
+
+
+/****************************************************************************
+add privileges for a user
+****************************************************************************/
+static int cmd_addprivileges(const char **cmd_ptr)
+{
+       fstring buf;
+       TALLOC_CTX *mem_ctx = talloc_new(NULL);
+       NTSTATUS status;
+       struct dom_sid *sid;
+       struct lsa_RightSet rights;
+
+       if (!next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
+               d_printf("addprivileges <sid|name> <privilege...>\n");
+               talloc_free(mem_ctx);
+               return 1;
+       }
+
+       sid = dom_sid_parse_talloc(mem_ctx, buf);
+       if (sid == NULL) {
+               const char *sid_str;
+               status = smblsa_lookup_name(cli, buf, mem_ctx, &sid_str);
+               if (!NT_STATUS_IS_OK(status)) {
+                       d_printf("lsa_LookupNames - %s\n", nt_errstr(status));
+                       talloc_free(mem_ctx);
+                       return 1;
+               }
+               sid = dom_sid_parse_talloc(mem_ctx, sid_str);
+       }
+
+       ZERO_STRUCT(rights);
+       while (next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
+               rights.names = talloc_realloc(mem_ctx, rights.names, 
+                                               struct lsa_String, rights.count+1);
+               rights.names[rights.count].string = talloc_strdup(mem_ctx, buf);
+               rights.count++;
+       }
+
+
+       status = smblsa_sid_add_privileges(cli, sid, mem_ctx, &rights);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("lsa_AddAccountRights - %s\n", nt_errstr(status));
+               talloc_free(mem_ctx);
+               return 1;
+       }
+
+       talloc_free(mem_ctx);
+
+       return 0;
+}
+
+/****************************************************************************
+delete privileges for a user
+****************************************************************************/
+static int cmd_delprivileges(const char **cmd_ptr)
+{
+       fstring buf;
+       TALLOC_CTX *mem_ctx = talloc_new(NULL);
+       NTSTATUS status;
+       struct dom_sid *sid;
+       struct lsa_RightSet rights;
+
+       if (!next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
+               d_printf("delprivileges <sid|name> <privilege...>\n");
+               talloc_free(mem_ctx);
+               return 1;
+       }
+
+       sid = dom_sid_parse_talloc(mem_ctx, buf);
+       if (sid == NULL) {
+               const char *sid_str;
+               status = smblsa_lookup_name(cli, buf, mem_ctx, &sid_str);
+               if (!NT_STATUS_IS_OK(status)) {
+                       d_printf("lsa_LookupNames - %s\n", nt_errstr(status));
+                       talloc_free(mem_ctx);
+                       return 1;
+               }
+               sid = dom_sid_parse_talloc(mem_ctx, sid_str);
+       }
+
+       ZERO_STRUCT(rights);
+       while (next_token(cmd_ptr,buf,NULL,sizeof(buf))) {
+               rights.names = talloc_realloc(mem_ctx, rights.names, 
+                                               struct lsa_String, rights.count+1);
+               rights.names[rights.count].string = talloc_strdup(mem_ctx, buf);
+               rights.count++;
+       }
+
+
+       status = smblsa_sid_del_privileges(cli, sid, mem_ctx, &rights);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("lsa_RemoveAccountRights - %s\n", nt_errstr(status));
+               talloc_free(mem_ctx);
+               return 1;
+       }
+
+       talloc_free(mem_ctx);
+
+       return 0;
+}
+
 
 /****************************************************************************
 ****************************************************************************/
@@ -2229,7 +2472,6 @@ static int cmd_reput(const char **cmd_ptr)
        pstring remote_name;
        fstring buf;
        char *p = buf;
-       struct stat st;
        
        pstrcpy(remote_name, cur_dir);
        pstrcat(remote_name, "\\");
@@ -2240,7 +2482,7 @@ static int cmd_reput(const char **cmd_ptr)
        }
        pstrcpy(local_name, p);
   
-       if (!file_exist(local_name, &st)) {
+       if (!file_exist(local_name)) {
                d_printf("%s does not exist\n", local_name);
                return 1;
        }
@@ -2313,12 +2555,14 @@ static BOOL browse_host(const char *query_host)
        status = dcerpc_pipe_connect(&p, binding, 
                                     DCERPC_SRVSVC_UUID, 
                                     DCERPC_SRVSVC_VERSION,
-                                    domain, 
-                                    username, password);
+                                    lp_netbios_name(),
+                                    cli_credentials_get_domain(cmdline_credentials), 
+                                    cli_credentials_get_username(cmdline_credentials), 
+                                        cli_credentials_get_password(cmdline_credentials));
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("Failed to connect to %s - %s\n", 
                         binding, nt_errstr(status));
-               talloc_destroy(mem_ctx);
+               talloc_free(mem_ctx);
                return False;
        }
        talloc_steal(mem_ctx, p);
@@ -2345,7 +2589,7 @@ static BOOL browse_host(const char *query_host)
                }
        } while (NT_STATUS_IS_OK(status) && W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA));
 
-       talloc_destroy(mem_ctx);
+       talloc_free(mem_ctx);
 
        if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) {
                d_printf("Failed NetShareEnumAll %s - %s/%s\n", 
@@ -2385,6 +2629,7 @@ static struct
 } commands[] = 
 {
   {"?",cmd_help,"[command] give help on a command",{COMPL_NONE,COMPL_NONE}},
+  {"addprivileges",cmd_addprivileges,"<sid|name> <privilege...> add privileges for a user",{COMPL_NONE,COMPL_NONE}},
   {"altname",cmd_altname,"<file> show alt name",{COMPL_NONE,COMPL_NONE}},
   {"acl",cmd_acl,"<file> show file ACL",{COMPL_NONE,COMPL_NONE}},
   {"allinfo",cmd_allinfo,"<file> show all possible info about a file",{COMPL_NONE,COMPL_NONE}},
@@ -2394,15 +2639,18 @@ static struct
   {"chmod",cmd_chmod,"<src> <mode> chmod a file using UNIX permission",{COMPL_REMOTE,COMPL_REMOTE}},
   {"chown",cmd_chown,"<src> <uid> <gid> chown a file using UNIX uids and gids",{COMPL_REMOTE,COMPL_REMOTE}},
   {"del",cmd_del,"<mask> delete all matching files",{COMPL_REMOTE,COMPL_NONE}},
+  {"delprivileges",cmd_delprivileges,"<sid|name> <privilege...> remove privileges for a user",{COMPL_NONE,COMPL_NONE}},
   {"deltree",cmd_deltree,"<dir> delete a whole directory tree",{COMPL_REMOTE,COMPL_NONE}},
   {"dir",cmd_dir,"<mask> list the contents of the current directory",{COMPL_REMOTE,COMPL_NONE}},
   {"du",cmd_du,"<mask> computes the total size of the current directory",{COMPL_REMOTE,COMPL_NONE}},
+  {"eainfo",cmd_eainfo,"<file> show EA contents for a file",{COMPL_NONE,COMPL_NONE}},
   {"exit",cmd_quit,"logoff the server",{COMPL_NONE,COMPL_NONE}},
   {"get",cmd_get,"<remote name> [local name] get a file",{COMPL_REMOTE,COMPL_LOCAL}},
   {"help",cmd_help,"[command] give help on a command",{COMPL_NONE,COMPL_NONE}},
   {"history",cmd_history,"displays the command history",{COMPL_NONE,COMPL_NONE}},
   {"lcd",cmd_lcd,"[directory] change/report the local current working directory",{COMPL_LOCAL,COMPL_NONE}},
   {"link",cmd_link,"<src> <dest> create a UNIX hard link",{COMPL_REMOTE,COMPL_REMOTE}},
+  {"lookup",cmd_lookup,"<sid|name> show SID for name or name for SID",{COMPL_NONE,COMPL_NONE}},
   {"lowercase",cmd_lowercase,"toggle lowercasing of filenames for get",{COMPL_NONE,COMPL_NONE}},  
   {"ls",cmd_dir,"<mask> list the contents of the current directory",{COMPL_REMOTE,COMPL_NONE}},
   {"mask",cmd_select,"<mask> mask all filenames against this",{COMPL_REMOTE,COMPL_NONE}},
@@ -2413,6 +2661,7 @@ static struct
   {"mput",cmd_mput,"<mask> put all matching files",{COMPL_REMOTE,COMPL_NONE}},
   {"newer",cmd_newer,"<file> only mget files newer than the specified local file",{COMPL_LOCAL,COMPL_NONE}},
   {"open",cmd_open,"<mask> open a file",{COMPL_REMOTE,COMPL_NONE}},
+  {"privileges",cmd_privileges,"<user> show privileges for a user",{COMPL_NONE,COMPL_NONE}},
   {"print",cmd_print,"<file name> print a file",{COMPL_NONE,COMPL_NONE}},
   {"printmode",cmd_printmode,"<graphics or text> set the print mode",{COMPL_NONE,COMPL_NONE}},
   {"prompt",cmd_prompt,"toggle prompting for filenames for mget and mput",{COMPL_NONE,COMPL_NONE}},  
@@ -2502,7 +2751,7 @@ static int process_command_string(char *cmd)
        /* establish the connection if not already */
        
        if (!cli) {
-               cli = do_connect(desthost, service);
+               cli = do_connect(desthost, service, cmdline_credentials);
                if (!cli)
                        return 0;
        }
@@ -2788,89 +3037,26 @@ static void process_stdin(void)
 /***************************************************** 
 return a connection to a server
 *******************************************************/
-static struct smbcli_state *do_connect(const char *server, const char *share)
+static struct smbcli_state *do_connect(const char *server, const char *share, struct cli_credentials *cred)
 {
        struct smbcli_state *c;
-       struct nmb_name called, calling;
-       const char *server_n;
-       fstring servicename;
-       char *sharename;
        NTSTATUS status;
-       
-       /* make a copy so we don't modify the global string 'service' */
-       fstrcpy(servicename, share);
-       sharename = servicename;
-       if (*sharename == '\\') {
-               server = sharename+2;
-               sharename = strchr_m(server,'\\');
-               if (!sharename) return NULL;
-               *sharename = 0;
-               sharename++;
-       }
-
-       asprintf(&sharename, "\\\\%s\\%s", server, sharename);
-
-       server_n = dest_ip?dest_ip:server;
-       
-       make_nmb_name(&calling, lp_netbios_name(), 0x0);
-       choose_called_name(&called, server, name_type);
-
- again:
-       /* have to open a new connection */
-       if (!(c=smbcli_state_init(NULL)) || !smbcli_socket_connect(c, server_n)) {
-               d_printf("Connection to %s failed\n", server_n);
-               return NULL;
-       }
 
-       if (!smbcli_transport_establish(c, &calling, &called)) {
-               char *p;
-               d_printf("session request to %s failed\n", 
-                        called.name);
-               smbcli_shutdown(c);
-               if ((p=strchr_m(called.name, '.'))) {
-                       *p = 0;
-                       goto again;
-               }
-               if (strcmp(called.name, "*SMBSERVER")) {
-                       make_nmb_name(&called , "*SMBSERVER", 0x20);
-                       goto again;
-               }
-               return NULL;
+       if (strncmp(share, "\\\\", 2) == 0 ||
+           strncmp(share, "//", 2) == 0) {
+               smbcli_parse_unc(share, NULL, &server, &share);
        }
-
-       DEBUG(4,(" session request ok\n"));
-
-       if (NT_STATUS_IS_ERR(smbcli_negprot(c))) {
-               d_printf("protocol negotiation failed\n");
-               smbcli_shutdown(c);
-               return NULL;
-       }
-
-       status = smbcli_session_setup(c, username, password, domain);
-       if (NT_STATUS_IS_ERR(status)) {
-               d_printf("authenticated session setup failed: %s\n", nt_errstr(status));
-               /* if a password was not supplied then try again with a null username */
-               if (password[0] || !username[0]) {
-                       status = smbcli_session_setup(c, "", "", lp_workgroup());
-               }
-               if (NT_STATUS_IS_ERR(status)) {
-                       d_printf("session setup failed: %s\n", nt_errstr(status));
-                       smbcli_shutdown(c);
-                       return NULL;
-               }
-               d_printf("Anonymous login successful\n");
-       }
-
-       DEBUG(4,(" session setup ok\n"));
-
-       if (NT_STATUS_IS_ERR(smbcli_send_tconX(c, sharename, "?????", password))) {
-               d_printf("tree connect failed: %s\n", smbcli_errstr(c->tree));
-               smbcli_shutdown(c);
+       
+       status = smbcli_full_connection(NULL, &c, lp_netbios_name(), server,
+                                       share, NULL, cli_credentials_get_username(cred), 
+                                                                cli_credentials_get_domain(cred), 
+                                                                cli_credentials_get_password(cred));
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("Connection to \\\\%s\\%s failed - %s\n", 
+                        server, share, nt_errstr(status));
                return NULL;
        }
 
-       DEBUG(4,(" tconx ok\n"));
-
        return c;
 }
 
@@ -2882,7 +3068,7 @@ static int process(char *base_directory)
 {
        int rc = 0;
 
-       cli = do_connect(desthost, service);
+       cli = do_connect(desthost, service, cmdline_credentials);
        if (!cli) {
                return 1;
        }
@@ -2915,11 +3101,14 @@ handle a message operation
 ****************************************************************************/
 static int do_message_op(void)
 {
-       struct nmb_name called, calling;
+       struct nbt_name called, calling;
        const char *server_name;
 
-       make_nmb_name(&calling, lp_netbios_name(), 0x0);
-       choose_called_name(&called, desthost, name_type);
+       calling.name = lp_netbios_name();
+       calling.type = NBT_NAME_CLIENT;
+       calling.scope = NULL;
+
+       nbt_choose_called_name(NULL, &called, desthost, name_type);
 
        server_name = dest_ip ? dest_ip : desthost;
 
@@ -3072,7 +3261,7 @@ static void remember_query_host(const char *arg,
        }
 
        if (poptPeekArg(pc)) { 
-               cmdline_set_userpassword(poptGetArg(pc));
+               cli_credentials_set_password(cmdline_credentials, poptGetArg(pc), CRED_SPECIFIED);
        }
 
        /*init_names(); */
@@ -3084,13 +3273,9 @@ static void remember_query_host(const char *arg,
 
        poptFreeContext(pc);
 
-       pstrcpy(username, cmdline_get_username());
-       pstrcpy(domain, cmdline_get_userdomain());
-       pstrcpy(password, cmdline_get_userpassword());
-
        DEBUG( 3, ( "Client started (version %s).\n", SAMBA_VERSION_STRING ) );
 
-       talloc_destroy(mem_ctx);
+       talloc_free(mem_ctx);
 
        if ((p=strchr_m(query_host,'#'))) {
                *p = 0;