summaryrefslogtreecommitdiff
path: root/source3/client
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-07-15 10:35:28 +0000
committerAndrew Tridgell <tridge@samba.org>2002-07-15 10:35:28 +0000
commite90b65284812aaa5ff9e9935ce9bbad7791cbbcd (patch)
tree9e744d1dc2f93934a4b49166a37383d3cb2b2139 /source3/client
parentec167dc9cc0ec2ee461837c25a371d2981744208 (diff)
downloadsamba-e90b65284812aaa5ff9e9935ce9bbad7791cbbcd.tar.gz
samba-e90b65284812aaa5ff9e9935ce9bbad7791cbbcd.tar.bz2
samba-e90b65284812aaa5ff9e9935ce9bbad7791cbbcd.zip
updated the 3.0 branch from the head branch - ready for alpha18
(This used to be commit 03ac082dcb375b6f3ca3d810a6a6367542bc23ce)
Diffstat (limited to 'source3/client')
-rw-r--r--source3/client/.cvsignore1
-rw-r--r--source3/client/client.c58
-rw-r--r--source3/client/clitar.c25
-rw-r--r--source3/client/smbmnt.c4
-rw-r--r--source3/client/smbspool.c68
5 files changed, 62 insertions, 94 deletions
diff --git a/source3/client/.cvsignore b/source3/client/.cvsignore
index e69de29bb2..49a52f7616 100644
--- a/source3/client/.cvsignore
+++ b/source3/client/.cvsignore
@@ -0,0 +1 @@
+client_proto.h \ No newline at end of file
diff --git a/source3/client/client.c b/source3/client/client.c
index 1daba28b98..a421f36d80 100644
--- a/source3/client/client.c
+++ b/source3/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/source3/client/clitar.c b/source3/client/clitar.c
index 9fa3750b0c..43b0ef44bc 100644
--- a/source3/client/clitar.c
+++ b/source3/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/source3/client/smbmnt.c b/source3/client/smbmnt.c
index 36248987b1..ba2b1e9435 100644
--- a/source3/client/smbmnt.c
+++ b/source3/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/source3/client/smbspool.c b/source3/client/smbspool.c
index 2a2d5cbaf5..b78d9d22a8 100644
--- a/source3/client/smbspool.c
+++ b/source3/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...