diff options
author | Andrew Tridgell <tridge@samba.org> | 2002-07-15 10:35:28 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2002-07-15 10:35:28 +0000 |
commit | 03ac082dcb375b6f3ca3d810a6a6367542bc23ce (patch) | |
tree | f13f085fad5de50ebe4b066eb7e2629d55032a2d /source/client | |
parent | b8d39651fb90ef170055735412417239a63afc5d (diff) | |
download | samba-03ac082dcb375b6f3ca3d810a6a6367542bc23ce.tar.gz samba-03ac082dcb375b6f3ca3d810a6a6367542bc23ce.tar.xz samba-03ac082dcb375b6f3ca3d810a6a6367542bc23ce.zip |
updated the 3.0 branch from the head branch - ready for alpha18
Diffstat (limited to 'source/client')
-rw-r--r-- | source/client/.cvsignore | 1 | ||||
-rw-r--r-- | source/client/client.c | 58 | ||||
-rw-r--r-- | source/client/clitar.c | 25 | ||||
-rw-r--r-- | source/client/smbmnt.c | 4 | ||||
-rw-r--r-- | source/client/smbspool.c | 68 |
5 files changed, 62 insertions, 94 deletions
diff --git a/source/client/.cvsignore b/source/client/.cvsignore index e69de29bb2d..49a52f7616d 100644 --- a/source/client/.cvsignore +++ b/source/client/.cvsignore @@ -0,0 +1 @@ +client_proto.h
\ No newline at end of file diff --git a/source/client/client.c b/source/client/client.c index 1daba28b98e..a421f36d809 100644 --- a/source/client/client.c +++ b/source/client/client.c @@ -22,7 +22,7 @@ #define NO_SYSLOG #include "includes.h" - +#include "../client/client_proto.h" #ifndef REGISTER #define REGISTER 0 #endif @@ -34,7 +34,7 @@ extern BOOL in_client; extern BOOL AllowDebugChange; static int port = 0; pstring cur_dir = "\\"; -pstring cd_path = ""; +static pstring cd_path = ""; static pstring service; static pstring desthost; extern pstring global_myname; @@ -61,9 +61,9 @@ static int cmd_help(void); #define FID_UNUSED (0xFFFF) time_t newer_than = 0; -int archive_level = 0; +static int archive_level = 0; -BOOL translation = False; +static BOOL translation = False; static BOOL have_ip; @@ -74,36 +74,39 @@ extern BOOL tar_reset; /* clitar bits end */ -mode_t myumask = 0755; +static mode_t myumask = 0755; -BOOL prompt = True; +static BOOL prompt = True; -int printmode = 1; +static int printmode = 1; static BOOL recurse = False; BOOL lowercase = False; -struct in_addr dest_ip; +static struct in_addr dest_ip; #define SEPARATORS " \t\n\r" -BOOL abort_mget = True; +static BOOL abort_mget = True; -pstring fileselection = ""; +static pstring fileselection = ""; extern file_info def_finfo; /* timing globals */ int get_total_size = 0; int get_total_time_ms = 0; -int put_total_size = 0; -int put_total_time_ms = 0; +static int put_total_size = 0; +static int put_total_time_ms = 0; /* totals globals */ static double dir_total; #define USENMB +/* some forward declarations */ +static struct cli_state *do_connect(const char *server, const char *share); + /**************************************************************************** write to a local file with CR/LF->LF translation if appropriate. return the number taken from the buffer. This may not equal the number written. @@ -1120,7 +1123,10 @@ static int do_put(char *rname,char *lname) } - x_fclose(f); + if (f != x_stdin) { + x_fclose(f); + } + SAFE_FREE(buf); { @@ -1958,7 +1964,7 @@ static BOOL list_servers(char *wk_grp) * field is NULL, and NULL in that field is used in process_tok() * (below) to indicate the end of the list. crh */ -struct +static struct { char *name; int (*fn)(void); @@ -2080,6 +2086,14 @@ static int process_command_string(char *cmd) char *ptr; int rc = 0; + /* establish the connection if not already */ + + if (!cli) { + cli = do_connect(desthost, service); + if (!cli) + return 0; + } + while (cmd[0] != '\0') { char *p; fstring tok; @@ -2230,7 +2244,7 @@ static void process_stdin(void) /***************************************************** return a connection to a server *******************************************************/ -struct cli_state *do_connect(const char *server, const char *share) +static struct cli_state *do_connect(const char *server, const char *share) { struct cli_state *c; struct nmb_name called, calling; @@ -2484,9 +2498,13 @@ handle a tar operation static int do_tar_op(char *base_directory) { int ret; - cli = do_connect(desthost, service); - if (!cli) - return 1; + + /* do we already have a connection? */ + if (!cli) { + cli = do_connect(desthost, service); + if (!cli) + return 1; + } recurse=True; @@ -2623,10 +2641,6 @@ static void remember_query_host(const char *arg, } DEBUGLEVEL = old_debug; -#ifdef WITH_SSL - sslutil_init(0); -#endif - pstrcpy(workgroup,lp_workgroup()); load_interfaces(); diff --git a/source/client/clitar.c b/source/client/clitar.c index 9fa3750b0c2..43b0ef44bc7 100644 --- a/source/client/clitar.c +++ b/source/client/clitar.c @@ -37,6 +37,7 @@ #include "includes.h" #include "clitar.h" +#include "../client/client_proto.h" static int clipfind(char **aret, int ret, char *tok); @@ -65,8 +66,6 @@ typedef struct } stack; -stack dir_stack = {NULL, 0}; /* Want an empty stack */ - #define SEPARATORS " \t\n\r" extern struct cli_state *cli; @@ -85,25 +84,25 @@ static char *tarbuf, *buffer_p; static int tp, ntarf, tbufsiz; static double ttarf; /* Incremental mode */ -BOOL tar_inc=False; +static BOOL tar_inc=False; /* Reset archive bit */ -BOOL tar_reset=False; +static BOOL tar_reset=False; /* Include / exclude mode (true=include, false=exclude) */ -BOOL tar_excl=True; +static BOOL tar_excl=True; /* use regular expressions for search on file names */ -BOOL tar_re_search=False; +static BOOL tar_re_search=False; #ifdef HAVE_REGEX_H regex_t *preg; #endif /* Do not dump anything, just calculate sizes */ -BOOL dry_run=False; +static BOOL dry_run=False; /* Dump files with System attribute */ -BOOL tar_system=True; +static BOOL tar_system=True; /* Dump files with Hidden attribute */ -BOOL tar_hidden=True; +static BOOL tar_hidden=True; /* Be noisy - make a catalogue */ -BOOL tar_noisy=True; -BOOL tar_real_noisy=False; /* Don't want to be really noisy by default */ +static BOOL tar_noisy=True; +static BOOL tar_real_noisy=False; /* Don't want to be really noisy by default */ char tar_type='\0'; static char **cliplist=NULL; @@ -119,8 +118,8 @@ extern pstring cur_dir; extern int get_total_time_ms; extern int get_total_size; -int blocksize=20; -int tarhandle; +static int blocksize=20; +static int tarhandle; static void writetarheader(int f, char *aname, int size, time_t mtime, char *amode, unsigned char ftype); diff --git a/source/client/smbmnt.c b/source/client/smbmnt.c index 36248987b1e..ba2b1e9435d 100644 --- a/source/client/smbmnt.c +++ b/source/client/smbmnt.c @@ -111,13 +111,13 @@ fullpath(const char *p) OK then we change into that directory - this prevents race conditions */ static int mount_ok(char *mount_point) { - SMB_STRUCT_STAT st; + struct stat st; if (chdir(mount_point) != 0) { return -1; } - if (sys_stat(".", &st) != 0) { + if (stat(".", &st) != 0) { return -1; } diff --git a/source/client/smbspool.c b/source/client/smbspool.c index 2a2d5cbaf59..b78d9d22a80 100644 --- a/source/client/smbspool.c +++ b/source/client/smbspool.c @@ -3,6 +3,7 @@ SMB backend for the Common UNIX Printing System ("CUPS") Copyright 1999 by Easy Software Products Copyright Andrew Tridgell 1994-1998 + Copyright Andrew Bartlett 2002 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -271,72 +272,25 @@ smb_connect(char *workgroup, /* I - Workgroup */ char *password) /* I - Password */ { struct cli_state *c; /* New connection */ - struct nmb_name called, /* NMB name of server */ - calling; /* NMB name of client */ - struct in_addr ip; /* IP address of server */ pstring myname; /* Client name */ - + NTSTATUS nt_status; /* * Get the names and addresses of the client and server... */ get_myname(myname); - - zero_ip(&ip); - - make_nmb_name(&calling, myname, 0x0); - make_nmb_name(&called, server, 0x20); - - /* - * Open a new connection to the SMB server... - */ - - if ((c = cli_initialise(NULL)) == NULL) - { - fputs("ERROR: cli_initialize() failed...\n", stderr); - return (NULL); - } - - if (!cli_connect(c, server, &ip)) - { - fputs("ERROR: cli_connect() failed...\n", stderr); - return (NULL); + + nt_status = cli_full_connection(&c, myname, server, NULL, 0, share, "?????", + username, lp_workgroup(), password, 0); + + if (NT_STATUS_IS_OK(nt_status)) { + return c; + } else { + fprintf(stderr, "ERROR: Connection failed with error %s\n", nt_errstr(nt_status)); + return NULL; } - if (!cli_session_request(c, &calling, &called)) - { - fputs("ERROR: cli_session_request() failed...\n", stderr); - return (NULL); - } - - if (!cli_negprot(c)) - { - fputs("ERROR: SMB protocol negotiation failed\n", stderr); - cli_shutdown(c); - return (NULL); - } - - /* - * Do password stuff... - */ - - if (!cli_session_setup(c, username, - password, strlen(password), - password, strlen(password), - workgroup)) - { - fprintf(stderr, "ERROR: SMB session setup failed: %s\n", cli_errstr(c)); - return (NULL); - } - - if (!cli_send_tconX(c, share, "?????", - password, strlen(password)+1)) - { - fprintf(stderr, "ERROR: SMB tree connect failed: %s\n", cli_errstr(c)); - cli_shutdown(c); - return (NULL); - } /* * Return the new connection... |