summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-11-27 22:34:12 +0000
committerLuke Leighton <lkcl@samba.org>1999-11-27 22:34:12 +0000
commit9fef73c27e07dbf658681e6c1027602328ed0add (patch)
tree5ef358490d5a4d922a650a574e9b55e6fb63c04e
parent4a6761a58d5718c386c7ab4fa89c34fa08dca53b (diff)
downloadsamba-9fef73c27e07dbf658681e6c1027602328ed0add.tar.gz
samba-9fef73c27e07dbf658681e6c1027602328ed0add.tar.bz2
samba-9fef73c27e07dbf658681e6c1027602328ed0add.zip
updated \PIPE\wkssvc commands to use new abstracted connection system.
modified resolve_srv_name() to return dest host of *SMBSERVER if server name is \\ip.add.ress.format (This used to be commit 3204829225792974c8b20efb6ba6e24661a4f658)
-rw-r--r--source3/include/proto.h3
-rw-r--r--source3/libsmb/namequery.c34
-rw-r--r--source3/rpc_client/cli_wkssvc.c17
-rw-r--r--source3/rpcclient/cmd_wkssvc.c14
4 files changed, 40 insertions, 28 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 24b50d9bcc..38b4be92ad 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2141,8 +2141,7 @@ BOOL svc_change_svc_cfg( POLICY_HND *hnd,
/*The following definitions come from rpc_client/cli_wkssvc.c */
-BOOL do_wks_query_info(struct cli_state *cli, uint16 fnum,
- char *server_name, uint32 switch_value,
+BOOL wks_query_info( char *srv_name, uint32 switch_value,
WKS_INFO_100 *wks100);
/*The following definitions come from rpc_client/msrpc_lsarpc.c */
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 114f656d8c..e774dbae15 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -589,10 +589,24 @@ static BOOL resolve_hosts(const char *name, struct in_addr *return_ip)
or NetBIOS name. This uses the name switch in the
smb.conf to determine the order of name resolution.
*********************************************************/
-BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type)
+BOOL is_ip_address(const char *name)
{
int i;
- BOOL pure_address = True;
+ for (i=0; name[i]; i++)
+ if (!(isdigit((int)name[i]) || name[i] == '.'))
+ return False;
+
+ return True;
+}
+
+/********************************************************
+ Resolve a name into an IP address. Use this function if
+ the string is either an IP address, DNS or host name
+ or NetBIOS name. This uses the name switch in the
+ smb.conf to determine the order of name resolution.
+*********************************************************/
+BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type)
+{
pstring name_resolve_list;
fstring tok;
char *ptr;
@@ -606,12 +620,8 @@ BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type)
return True;
}
- for (i=0; pure_address && name[i]; i++)
- if (!(isdigit((int)name[i]) || name[i] == '.'))
- pure_address = False;
-
/* if it's in the form of an IP address then get the lib to interpret it */
- if (pure_address) {
+ if (is_ip_address(name)) {
return_ip->s_addr = inet_addr(name);
return True;
}
@@ -654,6 +664,7 @@ BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type)
BOOL resolve_srv_name(const char* srv_name, fstring dest_host,
struct in_addr *ip)
{
+ BOOL ret;
DEBUG(10,("resolve_srv_name: %s\n", srv_name));
if (srv_name == NULL || strequal("\\\\.", srv_name))
@@ -669,7 +680,14 @@ BOOL resolve_srv_name(const char* srv_name, fstring dest_host,
}
fstrcpy(dest_host, &srv_name[2]);
- return resolve_name(dest_host, ip, 0x20);
+ ret = resolve_name(dest_host, ip, 0x20);
+
+ if (is_ip_address(dest_host))
+ {
+ fstrcpy(dest_host, "*SMBSERVER");
+ }
+
+ return ret;
}
/********************************************************
diff --git a/source3/rpc_client/cli_wkssvc.c b/source3/rpc_client/cli_wkssvc.c
index 06ba8b88c8..99141bae6c 100644
--- a/source3/rpc_client/cli_wkssvc.c
+++ b/source3/rpc_client/cli_wkssvc.c
@@ -34,16 +34,21 @@ extern int DEBUGLEVEL;
/****************************************************************************
do a WKS Open Policy
****************************************************************************/
-BOOL do_wks_query_info(struct cli_state *cli, uint16 fnum,
- char *server_name, uint32 switch_value,
+BOOL wks_query_info( char *srv_name, uint32 switch_value,
WKS_INFO_100 *wks100)
{
prs_struct rbuf;
prs_struct buf;
WKS_Q_QUERY_INFO q_o;
BOOL valid_info = False;
+ struct cli_connection *con = NULL;
- if (server_name == 0 || wks100 == NULL) return False;
+ if (wks100 == NULL) return False;
+
+ if (!cli_connection_init(srv_name, PIPE_WKSSVC, &con))
+ {
+ return False;
+ }
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
prs_init(&rbuf, 0 , 4, SAFETY_MARGIN, True );
@@ -53,13 +58,13 @@ BOOL do_wks_query_info(struct cli_state *cli, uint16 fnum,
DEBUG(4,("WKS Query Info\n"));
/* store the parameters */
- make_wks_q_query_info(&q_o, server_name, switch_value);
+ make_wks_q_query_info(&q_o, srv_name, switch_value);
/* turn parameters into data stream */
wks_io_q_query_info("", &q_o, &buf, 0);
/* send the data on \PIPE\ */
- if (rpc_api_pipe_req(cli, fnum, WKS_QUERY_INFO, &buf, &rbuf))
+ if (rpc_con_pipe_req(con, WKS_QUERY_INFO, &buf, &rbuf))
{
WKS_R_QUERY_INFO r_o;
BOOL p;
@@ -85,6 +90,8 @@ BOOL do_wks_query_info(struct cli_state *cli, uint16 fnum,
prs_mem_free(&rbuf);
prs_mem_free(&buf );
+ cli_connection_unlink(con);
+
return valid_info;
}
diff --git a/source3/rpcclient/cmd_wkssvc.c b/source3/rpcclient/cmd_wkssvc.c
index 23f7a88d27..474c53f347 100644
--- a/source3/rpcclient/cmd_wkssvc.c
+++ b/source3/rpcclient/cmd_wkssvc.c
@@ -33,8 +33,6 @@ extern int DEBUGLEVEL;
#define DEBUG_TESTING
-extern struct cli_state *smb_cli;
-
extern FILE* out_hnd;
@@ -43,7 +41,6 @@ workstation get info query
****************************************************************************/
void cmd_wks_query_info(struct client_info *info, int argc, char *argv[])
{
- uint16 nt_pipe_fnum;
fstring dest_wks;
WKS_INFO_100 ctr;
uint32 info_level = 100;
@@ -64,17 +61,8 @@ void cmd_wks_query_info(struct client_info *info, int argc, char *argv[])
DEBUG(4,("cmd_wks_query_info: server:%s info level: %d\n",
dest_wks, info_level));
- DEBUG(5, ("cmd_wks_query_info: smb_cli->fd:%d\n", smb_cli->fd));
-
- /* open LSARPC session. */
- res = res ? cli_nt_session_open(smb_cli, PIPE_WKSSVC, &nt_pipe_fnum) : False;
-
/* send info level: receive requested info. hopefully. */
- res = res ? do_wks_query_info(smb_cli, nt_pipe_fnum,
- dest_wks, info_level, &ctr) : False;
-
- /* close the session */
- cli_nt_session_close(smb_cli, nt_pipe_fnum);
+ res = res ? wks_query_info( dest_wks, info_level, &ctr) : False;
if (res)
{