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.
+ 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.
****************************************************************************/
+
static int writefile(int f, char *b, int n)
{
int i;
}
/****************************************************************************
- read from a file with LF->CR/LF translation if appropriate. return the
- number read. read approx n bytes.
+ Read from a file with LF->CR/LF translation if appropriate. Return the
+ number read. read approx n bytes.
****************************************************************************/
+
static int readfile(char *b, int n, XFILE *f)
{
int i;
return(i);
}
-
/****************************************************************************
-send a message
+ Send a message.
****************************************************************************/
+
static void send_message(void)
{
int total_len = 0;
}
}
-
-
/****************************************************************************
-check the space on a device
+ Check the space on a device.
****************************************************************************/
+
static int do_dskattr(void)
{
int total, bsize, avail;
}
/****************************************************************************
-show cd/pwd
+ Show cd/pwd.
****************************************************************************/
+
static int cmd_pwd(void)
{
d_printf("Current directory is %s",service);
return 0;
}
-
/****************************************************************************
-change directory - inner section
+ Change directory - inner section.
****************************************************************************/
+
static int do_cd(char *newdir)
{
char *p = newdir;
}
/****************************************************************************
-change directory
+ Change directory.
****************************************************************************/
+
static int cmd_cd(void)
{
fstring buf;
return rc;
}
-
/*******************************************************************
- decide if a file should be operated on
- ********************************************************************/
+ Decide if a file should be operated on.
+********************************************************************/
+
static BOOL do_this_one(file_info *finfo)
{
- if (finfo->mode & aDIR) return(True);
+ if (finfo->mode & aDIR)
+ return(True);
if (*fileselection &&
!mask_match(finfo->name,fileselection,False)) {
}
/****************************************************************************
- display info about a file
- ****************************************************************************/
+ Display info about a file.
+****************************************************************************/
+
static void display_finfo(file_info *finfo)
{
if (do_this_one(finfo)) {
}
}
-
/****************************************************************************
- accumulate size of a file
- ****************************************************************************/
+ Accumulate size of a file.
+****************************************************************************/
+
static void do_du(file_info *finfo)
{
if (do_this_one(finfo)) {
static void (*do_list_fn)(file_info *);
/****************************************************************************
-functions for do_list_queue
- ****************************************************************************/
+ Functions for do_list_queue.
+****************************************************************************/
/*
* The do_list_queue is a NUL-separated list of strings stored in a
* Functions check to ensure that do_list_queue is non-NULL before
* accessing it.
*/
+
static void reset_do_list_queue(void)
{
SAFE_FREE(do_list_queue);
* If the starting point of the queue is more than half way through,
* move everything toward the beginning.
*/
- if (do_list_queue && (do_list_queue_start == do_list_queue_end))
- {
+ if (do_list_queue && (do_list_queue_start == do_list_queue_end)) {
DEBUG(4,("do_list_queue is empty\n"));
do_list_queue_start = do_list_queue_end = 0;
*do_list_queue = '\0';
- }
- else if (do_list_queue_start > (do_list_queue_size / 2))
- {
+ } else if (do_list_queue_start > (do_list_queue_size / 2)) {
DEBUG(4,("sliding do_list_queue backward\n"));
memmove(do_list_queue,
do_list_queue + do_list_queue_start,
do_list_queue_end -= do_list_queue_start;
do_list_queue_start = 0;
}
-
}
static void add_to_do_list_queue(const char* entry)
{
char *dlq;
long new_end = do_list_queue_end + ((long)strlen(entry)) + 1;
- while (new_end > do_list_queue_size)
- {
+ while (new_end > do_list_queue_size) {
do_list_queue_size *= 2;
DEBUG(4,("enlarging do_list_queue to %d\n",
(int)do_list_queue_size));
d_printf("failure enlarging do_list_queue to %d bytes\n",
(int)do_list_queue_size);
reset_do_list_queue();
- }
- else
- {
+ } else {
do_list_queue = dlq;
memset(do_list_queue + do_list_queue_size / 2,
0, do_list_queue_size / 2);
}
}
- if (do_list_queue)
- {
- pstrcpy(do_list_queue + do_list_queue_end, entry);
+ if (do_list_queue) {
+ safe_strcpy_base(do_list_queue + do_list_queue_end,
+ entry, do_list_queue, do_list_queue_size);
do_list_queue_end = new_end;
DEBUG(4,("added %s to do_list_queue (start=%d, end=%d)\n",
entry, (int)do_list_queue_start, (int)do_list_queue_end));
static void remove_do_list_queue_head(void)
{
- if (do_list_queue_end > do_list_queue_start)
- {
+ if (do_list_queue_end > do_list_queue_start) {
do_list_queue_start += strlen(do_list_queue_head()) + 1;
adjust_do_list_queue();
DEBUG(4,("removed head of do_list_queue (start=%d, end=%d)\n",
}
/****************************************************************************
-a helper for do_list
- ****************************************************************************/
+ A helper for do_list.
+****************************************************************************/
+
static void do_list_helper(file_info *f, const char *mask, void *state)
{
if (f->mode & aDIR) {
pstring mask2;
char *p;
+ if (!f->name[0]) {
+ d_printf("Empty dir name returned. Possible server misconfiguration.\n");
+ return;
+ }
+
pstrcpy(mask2, mask);
p = strrchr_m(mask2,'\\');
- if (!p) return;
+ if (!p)
+ return;
p[1] = 0;
pstrcat(mask2, f->name);
pstrcat(mask2,"\\*");
}
}
-
/****************************************************************************
-a wrapper around cli_list that adds recursion
- ****************************************************************************/
+ A wrapper around cli_list that adds recursion.
+****************************************************************************/
+
void do_list(const char *mask,uint16 attribute,void (*fn)(file_info *),BOOL rec, BOOL dirs)
{
static int in_do_list = 0;
- if (in_do_list && rec)
- {
+ if (in_do_list && rec) {
fprintf(stderr, "INTERNAL ERROR: do_list called recursively when the recursive flag is true\n");
exit(1);
}
do_list_dirs = dirs;
do_list_fn = fn;
- if (rec)
- {
+ if (rec) {
init_do_list_queue();
add_to_do_list_queue(mask);
- while (! do_list_queue_empty())
- {
+ while (! do_list_queue_empty()) {
/*
* Need to copy head so that it doesn't become
* invalid inside the call to cli_list. This
pstrcpy(head, do_list_queue_head());
cli_list(cli, head, attribute, do_list_helper, NULL);
remove_do_list_queue_head();
- if ((! do_list_queue_empty()) && (fn == display_finfo))
- {
+ if ((! do_list_queue_empty()) && (fn == display_finfo)) {
char* next_file = do_list_queue_head();
char* save_ch = 0;
if ((strlen(next_file) >= 2) &&
(next_file[strlen(next_file) - 1] == '*') &&
- (next_file[strlen(next_file) - 2] == '\\'))
- {
+ (next_file[strlen(next_file) - 2] == '\\')) {
save_ch = next_file +
strlen(next_file) - 2;
*save_ch = '\0';
}
d_printf("\n%s\n",next_file);
- if (save_ch)
- {
+ if (save_ch) {
*save_ch = '\\';
}
}
}
- }
- else
- {
- if (cli_list(cli, mask, attribute, do_list_helper, NULL) == -1)
- {
+ } else {
+ if (cli_list(cli, mask, attribute, do_list_helper, NULL) == -1) {
d_printf("%s listing %s\n", cli_errstr(cli), mask);
}
}
}
/****************************************************************************
- get a directory listing
- ****************************************************************************/
+ Get a directory listing.
+****************************************************************************/
+
static int cmd_dir(void)
{
uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
pstrcpy(mask,p);
else
pstrcat(mask,p);
- }
- else {
+ } else {
pstrcat(mask,"*");
}
return rc;
}
-
/****************************************************************************
- get a directory listing
- ****************************************************************************/
+ Get a directory listing.
+****************************************************************************/
+
static int cmd_du(void)
{
uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
return rc;
}
-
/****************************************************************************
- get a file from rname to lname
- ****************************************************************************/
+ Get a file from rname to lname
+****************************************************************************/
+
static int do_get(char *rname, char *lname, BOOL reget)
{
int handle = 0, fnum;
GetTimeOfDay(&tp_start);
if (lowercase) {
- strlower(lname);
+ strlower_m(lname);
}
fnum = cli_open(cli, rname, O_RDONLY, DENY_NONE);
while (1) {
int n = cli_read(cli, fnum, data, nread + start, read_size);
- if (n <= 0) break;
+ if (n <= 0)
+ break;
if (writefile(handle,data, n) != n) {
d_printf("Error writing local file\n");
return rc;
}
-
/****************************************************************************
- get a file
- ****************************************************************************/
+ Get a file.
+****************************************************************************/
+
static int cmd_get(void)
{
pstring lname;
return do_get(rname, lname, False);
}
-
/****************************************************************************
- do a mget operation on one file
- ****************************************************************************/
+ Do an mget operation on one file.
+****************************************************************************/
+
static void do_mget(file_info *finfo)
{
pstring rname;
slprintf(quest,sizeof(pstring)-1,
"Get file %s? ",finfo->name);
- if (prompt && !yesno(quest)) return;
+ if (prompt && !yesno(quest))
+ return;
if (!(finfo->mode & aDIR)) {
pstrcpy(rname,cur_dir);
unix_format(finfo->name);
if (lowercase)
- strlower(finfo->name);
+ strlower_m(finfo->name);
if (!directory_exist(finfo->name,NULL) &&
mkdir(finfo->name,0777) != 0) {
pstrcpy(cur_dir,saved_curdir);
}
-
/****************************************************************************
-view the file using the pager
+ View the file using the pager.
****************************************************************************/
+
static int cmd_more(void)
{
fstring rname,lname,pager_cmd;
return rc;
}
-
-
/****************************************************************************
-do a mget command
+ Do a mget command.
****************************************************************************/
+
static int cmd_mget(void)
{
uint16 attribute = aSYSTEM | aHIDDEN;
return 0;
}
-
/****************************************************************************
-make a directory of name "name"
+ Make a directory of name "name".
****************************************************************************/
+
static BOOL do_mkdir(char *name)
{
if (!cli_mkdir(cli, name)) {
}
/****************************************************************************
-show 8.3 name of a file
+ Show 8.3 name of a file.
****************************************************************************/
+
static BOOL do_altname(char *name)
{
fstring altname;
return(True);
}
-
/****************************************************************************
Exit client.
****************************************************************************/
+
static int cmd_quit(void)
{
cli_shutdown(cli);
return 0;
}
-
/****************************************************************************
- make a directory
- ****************************************************************************/
+ Make a directory.
+****************************************************************************/
+
static int cmd_mkdir(void)
{
pstring mask;
*ddir2 = 0;
pstrcpy(ddir,mask);
- trim_string(ddir,".",NULL);
+ trim_char(ddir,'.','\0');
p = strtok(ddir,"/\\");
while (p) {
pstrcat(ddir2,p);
return 0;
}
-
/****************************************************************************
- show alt name
- ****************************************************************************/
+ Show alt name.
+****************************************************************************/
+
static int cmd_altname(void)
{
pstring name;
return 0;
}
-
/****************************************************************************
- put a single file
- ****************************************************************************/
+ Put a single file.
+****************************************************************************/
+
static int do_put(char *rname, char *lname, BOOL reput)
{
int fnum;
d_printf("Error opening local file %s\n",lname);
return 1;
}
-
DEBUG(1,("putting file %s as %s ",lname,
rname));
return rc;
}
-
-
/****************************************************************************
- put a file
- ****************************************************************************/
+ Put a file.
+****************************************************************************/
+
static int cmd_put(void)
{
pstring lname;
}
/*************************************
- File list structure
+ File list structure.
*************************************/
static struct file_list {
} *file_list;
/****************************************************************************
- Free a file_list structure
+ Free a file_list structure.
****************************************************************************/
static void free_file_list (struct file_list * list)
{
struct file_list *tmp;
- while (list)
- {
+ while (list) {
tmp = list;
DLIST_REMOVE(list, list);
SAFE_FREE(tmp->file_path);
}
/****************************************************************************
- seek in a directory/file list until you get something that doesn't start with
- the specified name
- ****************************************************************************/
+ Seek in a directory/file list until you get something that doesn't start with
+ the specified name.
+****************************************************************************/
+
static BOOL seek_list(struct file_list *list, char *name)
{
while (list) {
}
/****************************************************************************
- set the file selection mask
- ****************************************************************************/
+ Set the file selection mask.
+****************************************************************************/
+
static int cmd_select(void)
{
pstrcpy(fileselection,"");
Recursive file matching function act as find
match must be always set to True when calling this function
****************************************************************************/
+
static int file_find(struct file_list **list, const char *directory,
const char *expression, BOOL match)
{
const char *dname;
dir = opendir(directory);
- if (!dir) return -1;
+ if (!dir)
+ return -1;
while ((dname = readdirname(dir))) {
- if (!strcmp("..", dname)) continue;
- if (!strcmp(".", dname)) continue;
+ if (!strcmp("..", dname))
+ continue;
+ if (!strcmp(".", dname))
+ continue;
if (asprintf(&path, "%s/%s", directory, dname) <= 0) {
continue;
}
/****************************************************************************
- mput some files
- ****************************************************************************/
+ mput some files.
+****************************************************************************/
+
static int cmd_mput(void)
{
fstring buf;
return 0;
}
-
/****************************************************************************
- cancel a print job
- ****************************************************************************/
+ Cancel a print job.
+****************************************************************************/
+
static int do_cancel(int job)
{
if (cli_printjob_del(cli, job)) {
}
}
-
/****************************************************************************
- cancel a print job
- ****************************************************************************/
+ Cancel a print job.
+****************************************************************************/
+
static int cmd_cancel(void)
{
fstring buf;
return 0;
}
-
/****************************************************************************
- print a file
- ****************************************************************************/
+ Print a file.
+****************************************************************************/
+
static int cmd_print(void)
{
pstring lname;
return do_put(rname, lname, False);
}
-
/****************************************************************************
- show a print queue entry
+ Show a print queue entry.
****************************************************************************/
+
static void queue_fn(struct print_job_info *p)
{
d_printf("%-6d %-9d %s\n", (int)p->id, (int)p->size, p->name);
}
/****************************************************************************
- show a print queue
+ Show a print queue.
****************************************************************************/
+
static int cmd_queue(void)
{
cli_print_queue(cli, queue_fn);
}
/****************************************************************************
-delete some files
+ Delete some files.
****************************************************************************/
+
static void do_del(file_info *finfo)
{
pstring mask;
}
/****************************************************************************
-delete some files
+ Delete some files.
****************************************************************************/
+
static int cmd_del(void)
{
pstring mask;
/****************************************************************************
****************************************************************************/
+
static int cmd_open(void)
{
pstring mask;
/****************************************************************************
-remove a directory
+ Remove a directory.
****************************************************************************/
+
static int cmd_rmdir(void)
{
pstring mask;
}
/****************************************************************************
-rename some files
+ Rename some file.
****************************************************************************/
+
static int cmd_rename(void)
{
pstring src,dest;
return 0;
}
-
/****************************************************************************
-toggle the prompt flag
+ Toggle the prompt flag.
****************************************************************************/
+
static int cmd_prompt(void)
{
prompt = !prompt;
return 1;
}
-
/****************************************************************************
-set the newer than time
+ Set the newer than time.
****************************************************************************/
+
static int cmd_newer(void)
{
fstring buf;
}
/****************************************************************************
-set the archive level
+ Set the archive level.
****************************************************************************/
+
static int cmd_archive(void)
{
fstring buf;
}
/****************************************************************************
-toggle the lowercaseflag
+ Toggle the lowercaseflag.
****************************************************************************/
+
static int cmd_lowercase(void)
{
lowercase = !lowercase;
return 0;
}
-
-
-
/****************************************************************************
-toggle the recurse flag
+ Toggle the recurse flag.
****************************************************************************/
+
static int cmd_recurse(void)
{
recurse = !recurse;
}
/****************************************************************************
-toggle the translate flag
+ Toggle the translate flag.
****************************************************************************/
+
static int cmd_translate(void)
{
translation = !translation;
return 0;
}
-
/****************************************************************************
-do a printmode command
+ Do a printmode command.
****************************************************************************/
+
static int cmd_printmode(void)
{
fstring buf;
}
}
- switch(printmode)
- {
+ switch(printmode) {
case 0:
fstrcpy(mode,"text");
break;
default:
slprintf(mode,sizeof(mode)-1,"%d",printmode);
break;
- }
+ }
DEBUG(2,("the printmode is now %s\n",mode));
}
/****************************************************************************
- do the lcd command
+ Do the lcd command.
****************************************************************************/
+
static int cmd_lcd(void)
{
fstring buf;
}
/****************************************************************************
- get a file restarting at end of local file
+ Get a file restarting at end of local file.
****************************************************************************/
+
static int cmd_reget(void)
{
pstring local_name;
}
/****************************************************************************
- put a file restarting at end of local file
+ Put a file restarting at end of local file.
****************************************************************************/
+
static int cmd_reput(void)
{
pstring local_name;
return do_put(remote_name, local_name, True);
}
-
/****************************************************************************
- list a share name
+ List a share name.
****************************************************************************/
+
static void browse_fn(const char *name, uint32 m,
const char *comment, void *state)
{
name,typestr,comment);
}
-
/****************************************************************************
-try and browse available connections on a host
+ Try and browse available connections on a host.
****************************************************************************/
+
static BOOL browse_host(BOOL sort)
{
int ret;
}
/****************************************************************************
-list a server name
+ List a server name.
****************************************************************************/
+
static void server_fn(const char *name, uint32 m,
const char *comment, void *state)
{
}
/****************************************************************************
-try and browse available connections on a host
+ Try and browse available connections on a host.
****************************************************************************/
+
static BOOL list_servers(char *wk_grp)
{
- if (!cli->server_domain) return False;
+ if (!cli->server_domain)
+ return False;
d_printf("\n\tServer Comment\n");
d_printf("\t--------- -------\n");
int (*fn)(void);
const char *description;
char compl_args[2]; /* Completion argument info */
-} commands[] =
-{
+} commands[] = {
{"?",cmd_help,"[command] give help on a command",{COMPL_NONE,COMPL_NONE}},
{"altname",cmd_altname,"<file> show alt name",{COMPL_NONE,COMPL_NONE}},
{"archive",cmd_archive,"<level>\n0=ignore archive bit\n1=only get archive files\n2=only get archive files and reset archive bit\n3=get all files and reset archive bit",{COMPL_NONE,COMPL_NONE}},
/* Yes, this must be here, see crh's comment above. */
{"!",NULL,"run a shell command on the local system",{COMPL_NONE,COMPL_NONE}},
- {"",NULL,NULL,{COMPL_NONE,COMPL_NONE}}
+ {NULL,NULL,NULL,{COMPL_NONE,COMPL_NONE}}
};
-
/*******************************************************************
- lookup a command string in the list of commands, including
- abbreviations
- ******************************************************************/
+ Lookup a command string in the list of commands, including
+ abbreviations.
+******************************************************************/
+
static int process_tok(fstring tok)
{
int i = 0, matches = 0;
}
/****************************************************************************
-help
+ Help.
****************************************************************************/
+
static int cmd_help(void)
{
int i=0,j;
}
/****************************************************************************
-process a -c command string
+ Process a -c command string.
****************************************************************************/
+
static int process_command_string(char *cmd)
{
pstring line;
line[1000] = '\0';
cmd += strlen(cmd);
} else {
- if (p - cmd > 999) p = cmd + 999;
+ if (p - cmd > 999)
+ p = cmd + 999;
strncpy(line, cmd, p - cmd);
line[p - cmd] = '\0';
cmd = p + 1;
{
pstring dirmask;
int i;
- completion_remote_t info = { "", NULL, 1, len, text, len };
+ completion_remote_t info = { "", NULL, 1, 0, NULL, 0 };
+ /* can't have non-static intialisation on Sun CC, so do it
+ at run time here */
+ info.samelen = len;
+ info.text = text;
+ info.len = len;
+
if (len >= PATH_MAX)
return(NULL);
if (i > 0) {
strncpy(info.dirmask, text, i+1);
info.dirmask[i+1] = 0;
- snprintf(dirmask, sizeof(dirmask), "%s%*s*", cur_dir, i-1, text);
+ pstr_sprintf(dirmask, "%s%*s*", cur_dir, i-1, text);
} else
- snprintf(dirmask, sizeof(dirmask), "%s*", cur_dir);
+ pstr_sprintf(dirmask, "%s*", cur_dir);
if (cli_list(cli, dirmask, aDIR | aSYSTEM | aHIDDEN, completion_remote_filter, &info) < 0)
goto cleanup;
return matches;
cleanup:
- while (i >= 0) {
+ for (i = 0; i < count; i++)
free(matches[i]);
- i--;
- }
+
free(matches);
return NULL;
}
}
/****************************************************************************
-make sure we swallow keepalives during idle time
+ Make sure we swallow keepalives during idle time.
****************************************************************************/
+
static void readline_callback(void)
{
fd_set fds;
t = time(NULL);
- if (t - last_t < 5) return;
+ if (t - last_t < 5)
+ return;
last_t = t;
cli_chkpath(cli, "\\");
}
-
/****************************************************************************
-process commands on stdin
+ Process commands on stdin.
****************************************************************************/
+
static void process_stdin(void)
{
const char *ptr;
}
}
-
/*****************************************************
-return a connection to a server
+ Return a connection to a server.
*******************************************************/
+
static struct cli_state *do_connect(const char *server, const char *share)
{
struct cli_state *c;
c->protocol = max_protocol;
c->use_kerberos = use_kerberos;
+ cli_setup_signing_state(c, cmdline_auth_info.signing_state);
+
if (!cli_session_request(c, &calling, &called)) {
char *p;
char *pass = getpass("Password: ");
if (pass) {
pstrcpy(password, pass);
+ got_pass = 1;
}
}
if (password[0] || !username[0] || use_kerberos ||
!cli_session_setup(c, "", "", 0, "", 0, lp_workgroup())) {
d_printf("session setup failed: %s\n", cli_errstr(c));
+ if (NT_STATUS_V(cli_nt_error(c)) ==
+ NT_STATUS_V(NT_STATUS_MORE_PROCESSING_REQUIRED))
+ d_printf("did you forget to run kinit?\n");
cli_shutdown(c);
return NULL;
}
return c;
}
-
/****************************************************************************
- process commands from the client
+ Process commands from the client.
****************************************************************************/
+
static int process(char *base_directory)
{
int rc = 0;
}
/****************************************************************************
-handle a -L query
+ Handle a -L query.
****************************************************************************/
+
static int do_host_query(char *query_host)
{
cli = do_connect(query_host, "IPC$");
return 1;
browse_host(True);
+
+ if (port != 139) {
+
+ /* Workgroups simply don't make sense over anything
+ else but port 139... */
+
+ cli_shutdown(cli);
+ port = 139;
+ cli = do_connect(query_host, "IPC$");
+ }
+
+ if (cli == NULL) {
+ d_printf("NetBIOS over TCP disabled -- no workgroup available\n");
+ return 1;
+ }
+
list_servers(lp_workgroup());
cli_shutdown(cli);
/****************************************************************************
-handle a tar operation
+ Handle a tar operation.
****************************************************************************/
+
static int do_tar_op(char *base_directory)
{
int ret;
}
/****************************************************************************
-handle a message operation
+ Handle a message operation.
****************************************************************************/
+
static int do_message_op(void)
{
struct in_addr ip;
* We don't actually do anything yet -- we just stash the name in a
* global variable and do the query when all options have been read.
**/
+
static void remember_query_host(const char *arg,
pstring query_host)
{
}
}
-
/****************************************************************************
main program
****************************************************************************/
+
int main(int argc,char *argv[])
{
+ extern BOOL AllowDebugChange;
fstring base_directory;
int opt;
pstring query_host;
poptContext pc;
char *p;
int rc = 0;
+ fstring new_workgroup;
struct poptOption long_options[] = {
POPT_AUTOHELP
{ "tar", 'T', POPT_ARG_STRING, NULL, 'T', "Command line tar", "<c|x>IXFqgbNan" },
{ "directory", 'D', POPT_ARG_STRING, NULL, 'D', "Start from directory", "DIR" },
{ "command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated commands" },
- { "send-buffer", 'b', POPT_ARG_INT, NULL, 'b', "Changes the transmit/send buffer", "BYTES" },
+ { "send-buffer", 'b', POPT_ARG_INT, &io_bufsize, 'b', "Changes the transmit/send buffer", "BYTES" },
{ "port", 'p', POPT_ARG_INT, &port, 'p', "Port to connect to", "PORT" },
POPT_COMMON_SAMBA
POPT_COMMON_CONNECTION
*query_host = 0;
*base_directory = 0;
+
+ /* initialize the workgroup name so we can determine whether or
+ not it was set by a command line option */
+
+ set_global_myworkgroup( "" );
- setup_logging(argv[0],True);
+ /* set default debug level to 0 regardless of what smb.conf sets */
+ setup_logging( "smbclient", True );
+ DEBUGLEVEL_CLASS[DBGC_ALL] = 1;
+ dbf = x_stderr;
+ x_setbuf( x_stderr, NULL );
- if (!lp_load(dyn_CONFIGFILE,True,False,False)) {
- fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n",
- argv[0], dyn_CONFIGFILE);
- }
-
pc = poptGetContext("smbclient", argc, (const char **) argv, long_options,
POPT_CONTEXT_KEEP_FIRST);
poptSetOtherOptionHelp(pc, "service <password>");
*/
name_type = 0x03;
pstrcpy(desthost,poptGetOptArg(pc));
- if( 0 == port ) port = 139;
+ if( 0 == port )
+ port = 139;
message = True;
break;
case 'I':
max_protocol = interpret_protocol(poptGetOptArg(pc), max_protocol);
break;
case 'T':
- if (!tar_parseargs(argc, argv, poptGetOptArg(pc), optind)) {
- poptPrintUsage(pc, stderr, 0);
- exit(1);
+ /* We must use old option processing for this. Find the
+ * position of the -T option in the raw argv[]. */
+ {
+ int i, optnum;
+ for (i = 1; i < argc; i++) {
+ if (strncmp("-T", argv[i],2)==0)
+ break;
+ }
+ i++;
+ if (!(optnum = tar_parseargs(argc, argv, poptGetOptArg(pc), i))) {
+ 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);
}
break;
case 'D':
fstrcpy(base_directory,poptGetOptArg(pc));
break;
- case 'b':
- io_bufsize = MAX(1, atoi(poptGetOptArg(pc)));
- break;
}
}
poptGetArg(pc);
+ /*
+ * Don't load debug level from smb.conf. It should be
+ * set by cmdline arg or remain default (0)
+ */
+ AllowDebugChange = False;
+
+ /* save the workgroup...
+
+ FIXME!! do we need to do tyhis for other options as well
+ (or maybe a generic way to keep lp_load() from overwriting
+ everything)? */
+
+ fstrcpy( new_workgroup, lp_workgroup() );
+
+ if (!lp_load(dyn_CONFIGFILE,True,False,False)) {
+ fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n",
+ argv[0], dyn_CONFIGFILE);
+ }
+
load_interfaces();
+
+ if ( strlen(new_workgroup) != 0 )
+ set_global_myworkgroup( new_workgroup );
if(poptPeekArg(pc)) {
pstrcpy(service,poptGetArg(pc));
}
}
- if (poptPeekArg(pc)) {
+ if (poptPeekArg(pc) && !cmdline_auth_info.got_pass) {
cmdline_auth_info.got_pass = True;
pstrcpy(cmdline_auth_info.password,poptGetArg(pc));
}
pstrcpy(username, cmdline_auth_info.username);
pstrcpy(password, cmdline_auth_info.password);
+
use_kerberos = cmdline_auth_info.use_kerberos;
got_pass = cmdline_auth_info.got_pass;
- DEBUG( 3, ( "Client started (version %s).\n", VERSION ) );
+ DEBUG(3,("Client started (version %s).\n", SAMBA_VERSION_STRING));
if (tar_type) {
if (cmdstr)