smbclient source code.( -k option )

ranji ranjith.rajendran at wipro.com
Sun Oct 10 01:54:59 MDT 2010


I found the same in path : ../samba-3.3.14/source/client/client.c 

But i see that it doesn't have the code for -k option. Pls confirm me in
this regard. 



int main(int argc,char *argv[])
{
	char *base_directory = NULL;
	int opt;
	char *query_host = NULL;
	bool message = false;
	char *term_code = NULL;
	static const char *new_name_resolve_order = NULL;
	poptContext pc;
	char *p;
	int rc = 0;
	fstring new_workgroup;
	bool tar_opt = false;
	bool service_opt = false;
	struct poptOption long_options[] = {
		POPT_AUTOHELP

		{ "name-resolve", 'R', POPT_ARG_STRING, &new_name_resolve_order, 'R', "Use
these name resolution services only", "NAME-RESOLVE-ORDER" },
		{ "message", 'M', POPT_ARG_STRING, NULL, 'M', "Send message", "HOST" },
		{ "ip-address", 'I', POPT_ARG_STRING, NULL, 'I', "Use this IP to connect
to", "IP" },
		{ "stderr", 'E', POPT_ARG_NONE, NULL, 'E', "Write messages to stderr
instead of stdout" },
		{ "list", 'L', POPT_ARG_STRING, NULL, 'L', "Get a list of shares available
on a host", "HOST" },
		{ "terminal", 't', POPT_ARG_STRING, NULL, 't', "Terminal I/O code
{sjis|euc|jis7|jis8|junet|hex}", "CODE" },
		{ "max-protocol", 'm', POPT_ARG_STRING, NULL, 'm', "Set the max protocol
level", "LEVEL" },
		{ "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, &io_bufsize, 'b', "Changes the
transmit/send buffer", "BYTES" },
		{ "port", 'p', POPT_ARG_INT, &port, 'p', "Port to connect to", "PORT" },
		{ "grepable", 'g', POPT_ARG_NONE, NULL, 'g', "Produce grepable output" },
                { "browse", 'B', POPT_ARG_NONE, NULL, 'B', "Browse SMB
servers using DNS" },
		POPT_COMMON_SAMBA
		POPT_COMMON_CONNECTION
		POPT_COMMON_CREDENTIALS
		POPT_TABLEEND
	};
	TALLOC_CTX *frame = talloc_stackframe();

	if (!client_set_cur_dir("\\")) {
		exit(ENOMEM);
	}

#ifdef KANJI
	term_code = talloc_strdup(frame,KANJI);
#else /* KANJI */
	term_code = talloc_strdup(frame,"");
#endif /* KANJI */
	if (!term_code) {
		exit(ENOMEM);
	}

	/* initialize the workgroup name so we can determine whether or
	   not it was set by a command line option */

	set_global_myworkgroup( "" );
	set_global_myname( "" );

        /* set default debug level to 1 regardless of what smb.conf sets */
	setup_logging( "smbclient", true );
	DEBUGLEVEL_CLASS[DBGC_ALL] = 1;
	if ((dbf = x_fdup(x_stderr))) {
		x_setbuf( dbf, NULL );
	}

	load_case_tables();

	/* skip argv(0) */
	pc = poptGetContext("smbclient", argc, (const char **) argv, long_options,
0);
	poptSetOtherOptionHelp(pc, "service <password>");

        lp_set_in_client(true); /* Make sure that we tell lp_load we are */

	while ((opt = poptGetNextOpt(pc)) != -1) {

		/* if the tar option has been called previouslt, now we need to eat out
the leftovers */
		/* I see no other way to keep things sane --SSS */
		if (tar_opt == true) {
			while (poptPeekArg(pc)) {
				poptGetArg(pc);
			}
			tar_opt = false;
		}

		/* if the service has not yet been specified lets see if it is available
in the popt stack */
		if (!service_opt && poptPeekArg(pc)) {
			service = talloc_strdup(frame, poptGetArg(pc));
			if (!service) {
				exit(ENOMEM);
			}
			service_opt = true;
		}

		/* if the service has already been retrieved then check if we have also a
password */
		if (service_opt && (!get_cmdline_auth_info_got_pass()) && poptPeekArg(pc))
{
			set_cmdline_auth_info_password(poptGetArg(pc));
		}

		switch (opt) {
		case 'M':
			/* Messages are sent to NetBIOS name type 0x3
			 * (Messenger Service).  Make sure we default
			 * to port 139 instead of port 445. srl,crh
			 */
			name_type = 0x03;
			cli_cm_set_dest_name_type( name_type );
			desthost = talloc_strdup(frame,poptGetOptArg(pc));
			if (!desthost) {
				exit(ENOMEM);
			}
			if( !port )
				cli_cm_set_port( 139 );
 			message = true;
 			break;
		case 'I':
			{
				if (!interpret_string_addr(&dest_ss, poptGetOptArg(pc), 0)) {
					exit(1);
				}
				have_ip = true;

				cli_cm_set_dest_ss(&dest_ss);
			}
			break;
		case 'E':
			if (dbf) {
				x_fclose(dbf);
			}
			dbf = x_stderr;
			display_set_stderr();
			break;

		case 'L':
			query_host = talloc_strdup(frame, poptGetOptArg(pc));
			if (!query_host) {
				exit(ENOMEM);
			}
			break;
		case 't':
			term_code = talloc_strdup(frame,poptGetOptArg(pc));
			if (!term_code) {
				exit(ENOMEM);
			}
			break;
		case 'm':
			max_protocol = interpret_protocol(poptGetOptArg(pc), max_protocol);
			break;
		case 'T':
			/* We must use old option processing for this. Find the
			 * position of the -T option in the raw argv[]. */
			{
				int i;
				for (i = 1; i < argc; i++) {
					if (strncmp("-T", argv[i],2)==0)
						break;
				}
				i++;
				if (!tar_parseargs(argc, argv, poptGetOptArg(pc), i)) {
					poptPrintUsage(pc, stderr, 0);
					exit(1);
				}
			}
			/* this must be the last option, mark we have parsed it so that we know
we have */
			tar_opt = true;
			break;
		case 'D':
			base_directory = talloc_strdup(frame, poptGetOptArg(pc));
			if (!base_directory) {
				exit(ENOMEM);
			}
			break;
		case 'g':
			grepable=true;
			break;
		case 'e':
			smb_encrypt=true;
			break;
		case 'B':
			return(do_smb_browse());

		}
	}

-- 
View this message in context: http://samba.2283325.n4.nabble.com/smbclient-source-code-k-option-tp2970066p2970086.html
Sent from the Samba - samba-technical mailing list archive at Nabble.com.


More information about the samba-technical mailing list